├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── codeql-analysis.yml │ ├── create-docker-images.yml │ ├── create-release.yml │ ├── github.sh │ └── testing.yml ├── .gitignore ├── .goreleaser-nightly.yml ├── .goreleaser.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── SECURITY.md ├── buildscripts ├── docker │ ├── Dockerfile.client │ ├── Dockerfile.server │ ├── Dockerfile.suite │ ├── README.client.md │ ├── README.server.md │ ├── bitmaelum-client-config.yml │ ├── docker-entrypoint-client.sh │ ├── docker-entrypoint-server.sh │ ├── docker-entrypoint-suite.sh │ ├── generate-client.sh │ ├── generate-server.sh │ ├── generate-suite.sh │ └── server-config.yml └── signtool.exe ├── cmd ├── bm-bridge │ ├── internal │ │ ├── common.go │ │ ├── common_test.go │ │ ├── fetcher.go │ │ ├── imap │ │ │ └── backend │ │ │ │ ├── backend.go │ │ │ │ ├── bolt.go │ │ │ │ ├── mailbox.go │ │ │ │ ├── message.go │ │ │ │ ├── storage.go │ │ │ │ └── user.go │ │ └── smtp │ │ │ └── backend │ │ │ ├── backend.go │ │ │ └── session.go │ ├── main.go │ └── main_windows.go ├── bm-client │ ├── README.md │ ├── cmd │ │ ├── account.go │ │ ├── account_activate.go │ │ ├── account_create.go │ │ ├── account_deactivate.go │ │ ├── account_key.go │ │ ├── account_key_generate.go │ │ ├── account_key_list.go │ │ ├── account_list.go │ │ ├── account_redirect.go │ │ ├── account_setting.go │ │ ├── account_setting_delete.go │ │ ├── account_setting_list.go │ │ ├── account_setting_set.go │ │ ├── account_store.go │ │ ├── account_store_get.go │ │ ├── account_store_put.go │ │ ├── api.go │ │ ├── api_create.go │ │ ├── api_list.go │ │ ├── auth.go │ │ ├── auth_create.go │ │ ├── auth_list.go │ │ ├── config.go │ │ ├── config_edit.go │ │ ├── config_init.go │ │ ├── config_show.go │ │ ├── message.go │ │ ├── message_compose.go │ │ ├── message_list.go │ │ ├── message_read.go │ │ ├── organisation.go │ │ ├── organisation_create.go │ │ ├── organisation_invite.go │ │ ├── organisation_list.go │ │ ├── organisation_validate.go │ │ ├── organisation_validate_add.go │ │ ├── organisation_validate_list.go │ │ ├── organisation_validate_remove.go │ │ ├── otp.go │ │ ├── resolver.go │ │ ├── resolver_query.go │ │ ├── root.go │ │ ├── stdout.go │ │ ├── vault.go │ │ ├── vault_export.go │ │ ├── vault_import.go │ │ ├── vault_init.go │ │ ├── vault_password.go │ │ ├── webhook.go │ │ ├── webhook_create.go │ │ ├── webhook_create_http.go │ │ ├── webhook_create_slack.go │ │ ├── webhook_disable.go │ │ ├── webhook_edit.go │ │ ├── webhook_enable.go │ │ └── webhook_list.go │ ├── handlers │ │ ├── auth_create.go │ │ ├── compose.go │ │ ├── create_account.go │ │ ├── create_organisation.go │ │ ├── create_organisation_invite.go │ │ ├── list_accounts.go │ │ ├── list_messages.go │ │ ├── list_organisations.go │ │ ├── otp.go │ │ └── read_message.go │ ├── internal │ │ ├── cli.go │ │ ├── container │ │ │ └── container.go │ │ ├── error.go │ │ ├── lastread.go │ │ ├── options.go │ │ ├── spinner.go │ │ ├── stepper │ │ │ └── stepper.go │ │ └── template.go │ └── main.go ├── bm-config │ ├── README.md │ ├── cmd │ │ ├── acme.go │ │ ├── apikey.go │ │ ├── apikey_create.go │ │ ├── apikey_list.go │ │ ├── generate_cert.go │ │ ├── generate_key.go │ │ ├── generate_routing_id.go │ │ ├── init_config.go │ │ ├── invite.go │ │ ├── root.go │ │ ├── service.go │ │ ├── service_install.go │ │ ├── service_remove.go │ │ ├── service_restart.go │ │ ├── service_start.go │ │ └── service_stop.go │ ├── internal │ │ ├── fileio │ │ │ ├── fileio.go │ │ │ └── fileio_test.go │ │ └── letsencrypt │ │ │ └── letsencrypt.go │ └── main.go ├── bm-json │ ├── README.md │ ├── cmd │ │ ├── account.go │ │ ├── api.go │ │ ├── auth.go │ │ ├── box.go │ │ ├── message.go │ │ ├── organisation.go │ │ ├── root.go │ │ └── webhook.go │ ├── internal │ │ ├── cli.go │ │ ├── container │ │ │ └── container.go │ │ ├── error.go │ │ └── output │ │ │ └── json.go │ └── main.go ├── bm-mail │ ├── README.md │ ├── app │ │ └── app.go │ ├── gui │ │ ├── components │ │ │ ├── main_menu.go │ │ │ ├── menu_bar.go │ │ │ └── message_list.go │ │ ├── gui.go │ │ └── layout │ │ │ ├── account.go │ │ │ ├── help.go │ │ │ ├── mainmenu.go │ │ │ ├── message-overview.go │ │ │ ├── refresh.go │ │ │ └── unlock_vault.go │ └── main.go ├── bm-send │ ├── README.md │ └── main.go └── bm-server │ ├── handler │ ├── account.go │ ├── api_key.go │ ├── auth_key.go │ ├── boxes.go │ ├── homepage.go │ ├── incoming.go │ ├── message.go │ ├── mgmt │ │ ├── api_key.go │ │ ├── flush.go │ │ └── invite.go │ ├── store.go │ ├── ticket.go │ ├── utils.go │ └── webhooks.go │ ├── internal │ ├── account │ │ ├── box.go │ │ ├── file.go │ │ ├── file_account.go │ │ ├── file_box.go │ │ ├── file_key.go │ │ ├── file_message.go │ │ ├── mock.go │ │ └── repository.go │ ├── container │ │ ├── account.go │ │ ├── container.go │ │ └── proof-of-work.go │ ├── httputils │ │ └── http.go │ └── pow │ │ ├── bolt.go │ │ ├── redis.go │ │ └── storage.go │ ├── main.go │ ├── main_windows.go │ ├── middleware │ ├── auth │ │ ├── auth_apikey.go │ │ ├── auth_apikey_test.go │ │ ├── auth_jwt.go │ │ ├── auth_jwt_test.go │ │ ├── auth_onbehalf_jwt.go │ │ └── auth_onbehalf_jwt_test.go │ ├── authenticate.go │ ├── logger.go │ ├── prettyjson.go │ └── tracer.go │ └── processor │ ├── channels.go │ ├── channels_test.go │ ├── process.go │ ├── retry_queue.go │ ├── retry_queue_test.go │ ├── scoreboard.go │ ├── scoreboard_test.go │ └── stuck.go ├── codecov.yml ├── docs ├── README.md └── build.md ├── go.mod ├── go.sum ├── internal ├── api │ ├── account.go │ ├── apikey.go │ ├── apikey_test.go │ ├── authkey.go │ ├── client.go │ ├── client_test.go │ ├── jwt.go │ ├── jwt_test.go │ ├── mailbox.go │ ├── message.go │ ├── store.go │ ├── ticket.go │ ├── upload.go │ └── webhook.go ├── base64.go ├── base64_test.go ├── config │ ├── config.go │ ├── config_bridge.go │ ├── config_client.go │ ├── config_server.go │ ├── config_templates.go │ ├── config_templates_test.go │ ├── config_test.go │ ├── paths_unix.go │ ├── paths_windows.go │ ├── routing.go │ └── routing_test.go ├── console │ ├── mnemonic_phrase.go │ ├── password.go │ └── password_test.go ├── container │ ├── README.md │ ├── apikey.go │ ├── authkey.go │ ├── bitmaelum.go │ ├── container.go │ ├── container_test.go │ ├── resolver.go │ ├── store.go │ ├── subscription.go │ ├── ticket.go │ └── webhook.go ├── dispatcher │ ├── dispatcher.go │ └── worker.go ├── duration.go ├── duration_test.go ├── editor.go ├── editor_others.go ├── editor_test.go ├── editor_windows.go ├── http_logger.go ├── http_logger_test.go ├── key │ ├── README.md │ ├── api_key.go │ ├── api_key_repo.go │ ├── api_key_test.go │ ├── auth_key.go │ ├── auth_key_repo.go │ ├── auth_key_test.go │ ├── bolt_storage.go │ ├── mock_storage.go │ ├── mock_storage_test.go │ ├── redis_storage.go │ ├── redis_storage_test.go │ └── repository.go ├── key_permissions.go ├── logging.go ├── logging_other.go ├── logging_test.go ├── logging_windows.go ├── logo.go ├── logo_test.go ├── mailbox │ └── sort.go ├── message │ ├── account.go │ ├── catalog.go │ ├── catalog_test.go │ ├── checksum.go │ ├── checksum_test.go │ ├── compose.go │ ├── compose_test.go │ ├── compress.go │ ├── compress_test.go │ ├── envelope.go │ ├── header.go │ ├── message.go │ ├── paths.go │ ├── paths_test.go │ ├── retry.go │ ├── retry_test.go │ ├── signature.go │ ├── signature_test.go │ ├── upload.go │ └── upload_test.go ├── messages │ └── send.go ├── organisation │ ├── organisation.go │ ├── validate_dns.go │ ├── validation.go │ └── validation_test.go ├── parse_args.go ├── parse_args_test.go ├── parser.go ├── redis_result_wrapper.go ├── redis_result_wrapper_test.go ├── reload.go ├── reload_test.go ├── resolver │ ├── chain.go │ ├── chain_test.go │ ├── remote.go │ ├── repository.go │ ├── repository_test.go │ ├── resolver_mock.go │ ├── service.go │ ├── service_test.go │ ├── sqlite.go │ └── sqlite_test.go ├── routing.go ├── service.go ├── signature │ ├── invite.go │ └── invite_test.go ├── store │ ├── bolt.go │ ├── bolt_test.go │ ├── store.go │ └── store_test.go ├── subscription │ ├── bolt.go │ ├── redis.go │ ├── redis_test.go │ ├── subscription.go │ └── subscription_test.go ├── testing │ ├── redis_mock.go │ └── testing.go ├── ticket │ ├── bolt.go │ ├── bolt_test.go │ ├── redis.go │ ├── ticket.go │ └── ticket_test.go ├── time.go ├── time_test.go ├── vault │ ├── account.go │ ├── account_test.go │ ├── container.go │ ├── encrypt.go │ ├── migrate.go │ ├── organisation.go │ ├── organisation_test.go │ ├── vault.go │ └── vault_test.go ├── version.go ├── version_test.go ├── webhook │ ├── bolt.go │ ├── events.go │ ├── mock.go │ ├── mock_test.go │ ├── redis.go │ ├── redis_test.go │ ├── repository.go │ ├── webhook.go │ └── webhook_test.go ├── wordwrap.go ├── wordwrap_test.go └── work │ ├── proof_of_work.go │ └── repository.go ├── logo.png ├── pkg ├── address │ ├── address.go │ └── address_test.go ├── bmcrypto │ ├── aes_256_gcm.go │ ├── aes_256_gcm_test.go │ ├── bmcrypto.go │ ├── bmcrypto_test.go │ ├── dual_keyexchange.go │ ├── dual_keyexchange_test.go │ ├── encrypt_test.go │ ├── generate_test.go │ ├── jwt_ed25519_sign.go │ ├── jwt_ed25519_sign_test.go │ ├── key_ecdsa.go │ ├── key_ecdsa_test.go │ ├── key_ed25519.go │ ├── key_rsa.go │ ├── key_rsa_test.go │ ├── keyexchange_test.go │ ├── keytype.go │ ├── keytype_test.go │ ├── mnemonic.go │ ├── mnemonic_test.go │ └── sign_test.go ├── hash │ ├── hash.go │ └── hash_test.go └── proofofwork │ ├── pow.go │ └── pow_test.go ├── testdata ├── attachment.png ├── header-001.json ├── header-002.json ├── header-003.json ├── header-004.json ├── key-1.json ├── key-2.json ├── key-3.json ├── key-4.json ├── key-5.json ├── key-6.json ├── key-7.json ├── key-8.json ├── key-ed25519-1.json ├── key-ed25519-2.json ├── key-ed25519-3.json ├── key-ed25519-4.json ├── privkey.ecdsa ├── privkey.ed25519 ├── privkey.rsa ├── pubkey.ecdsa ├── pubkey.ed25519 ├── pubkey.rsa └── routing.json ├── tools ├── README.md ├── gen-key │ └── main.go ├── hash-address │ └── main.go ├── jwt-validate │ └── main.go ├── jwt │ └── main.go ├── proof-of-work │ └── main.go ├── resolve-auth │ └── main.go ├── toaster │ └── main.go ├── update-pow │ └── main.go ├── update-resolver │ └── main.go └── vault-edit │ ├── README.md │ └── main.go └── wix.json /.dockerignore: -------------------------------------------------------------------------------- 1 | /release/* 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/create-docker-images.yml: -------------------------------------------------------------------------------- 1 | name: Create docker images 2 | on: 3 | push: 4 | branches: [ main, docker-test ] 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-20.04 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | with: 13 | fetch-depth: 0 14 | - name: Install Go 15 | uses: actions/setup-go@v2 16 | with: 17 | go-version: 1.15.x 18 | - name: Build linux version 19 | run: | 20 | make -j linux-amd64 21 | - name: Archive production artifacts 22 | uses: actions/upload-artifact@v2 23 | with: 24 | name: release-binaries 25 | path: | 26 | release/linux-amd64 27 | 28 | docker-build: 29 | runs-on: ubuntu-20.04 30 | needs: build 31 | steps: 32 | - name: Checkout code 33 | uses: actions/checkout@v2 34 | with: 35 | fetch-depth: 0 36 | 37 | - name: Download release artifact 38 | uses: actions/download-artifact@v2 39 | with: 40 | name: release-binaries 41 | 42 | - name: Login to Docker Hub 43 | uses: docker/login-action@v1 44 | with: 45 | username: ${{ secrets.DOCKER_HUB_USERNAME }} 46 | password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} 47 | 48 | - name: Build docker client image 49 | run: | 50 | sh ./buildscripts/docker/generate-client.sh 51 | - name: Build docker server image 52 | run: | 53 | sh ./buildscripts/docker/generate-server.sh 54 | -------------------------------------------------------------------------------- /.github/workflows/github.sh: -------------------------------------------------------------------------------- 1 | reset="\e[0m" 2 | expand="\e[K" 3 | 4 | notice="\e[1;34m" 5 | success="\e[1;33;42m" 6 | fail="\e[1;33;41m" 7 | 8 | function section() { 9 | SECTION=$1 10 | echo -e "${notice}$1${reset}" 11 | } 12 | 13 | function status() { 14 | RC=$? 15 | if [ "$RC" == "0" ] ; then 16 | echo -e "${success} SUCCESS: ${SECTION} ${expand}${reset}\n" 17 | else 18 | echo -e "${fail} ERROR($RC): ${SECTION} ${expand}${reset}\n" 19 | fi 20 | } 21 | 22 | trap "status" EXIT 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | release/ 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We accept contributions from anyone willing to adhere our code of conduct. 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2021 BitMaelum Authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | We do not have a full security policy in place yet. Until that time, if you found any issues that might have security implications, please send 4 | a report to security@bitmaelum.com (via Email) or security@bitmaelum! (via BitMaelum). 5 | 6 | PLEASE DO NOT PUBLISH SECURITY REPORTS PUBLICLY IN GITHUB ISSUES. 7 | -------------------------------------------------------------------------------- /buildscripts/docker/Dockerfile.client: -------------------------------------------------------------------------------- 1 | FROM debian:buster-slim 2 | MAINTAINER jthijssen@bitmaelum.com 3 | 4 | # We need CA certificates otherwise we cannot connect to https:// 5 | RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates netbase && rm -rf /var/lib/apt/lists/* 6 | 7 | COPY bm-* /usr/local/bin/ 8 | COPY bitmaelum-client-config.yml /etc/bitmaelum/bitmaelum-client-config.yml 9 | 10 | COPY docker-entrypoint-client.sh /usr/local/bin/docker-entrypoint.sh 11 | ENTRYPOINT ["docker-entrypoint.sh"] 12 | -------------------------------------------------------------------------------- /buildscripts/docker/Dockerfile.server: -------------------------------------------------------------------------------- 1 | FROM debian:buster-slim 2 | MAINTAINER jthijssen@bitmaelum.com 3 | 4 | # We need CA certificates otherwise we cannot connect to https:// 5 | RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates netbase && rm -rf /var/lib/apt/lists/* 6 | 7 | COPY bm-* /usr/local/bin/ 8 | COPY bitmaelum-server-config.yml /etc/bitmaelum/bitmaelum-server-config.yml 9 | 10 | COPY docker-entrypoint-server.sh /usr/local/bin/docker-entrypoint.sh 11 | ENTRYPOINT ["docker-entrypoint.sh"] 12 | -------------------------------------------------------------------------------- /buildscripts/docker/Dockerfile.suite: -------------------------------------------------------------------------------- 1 | FROM debian:buster-slim 2 | MAINTAINER jthijssen@bitmaelum.com 3 | 4 | # We need CA certificates otherwise we cannot connect to https:// 5 | RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates netbase && rm -rf /var/lib/apt/lists/* 6 | 7 | COPY bm-* /usr/local/bin/ 8 | 9 | RUN mkdir /etc/bitmaelum && ln -sf /bitmaelum/server-config.yml /etc/bitmaelum/bitmaelum-server-config.yml 10 | COPY docker-entrypoint-suite.sh /usr/local/bin/docker-entrypoint.sh 11 | -------------------------------------------------------------------------------- /buildscripts/docker/README.client.md: -------------------------------------------------------------------------------- 1 | # BitMaelum client 2 | 3 | A docker image with the BitMaelum client software that allows you to easily test drive the BitMaelum mailing network. In order to work, you need to mount a local 4 | directory to the `/bitmaelum` directory: 5 | 6 | $ docker run -ti $PWD:/bitmaelum bitmaelum/client:latest account list 7 | 8 | 9 | ### Environment settings 10 | 11 | | Settings | Description | 12 | |-------------------------|----------------------------------------| 13 | | BITMAELUM_CLIENT_CONFIG | Path to custom client configuration | 14 | -------------------------------------------------------------------------------- /buildscripts/docker/README.server.md: -------------------------------------------------------------------------------- 1 | # BitMaelum server 2 | 3 | Server image. Do not use yet. 4 | 5 | 6 | ### Environment settings 7 | 8 | | Settings | Description | 9 | |-------------------------|----------------------------------------| 10 | | BITMAELUM_SERVER_CONFIG | Path to custom server configuration | 11 | -------------------------------------------------------------------------------- /buildscripts/docker/bitmaelum-client-config.yml: -------------------------------------------------------------------------------- 1 | # BitMaelum Client Configuration Template. Edit for your own needs. 2 | config: 3 | vault: 4 | # where are our accounts stored? 5 | path: "/bitmaelum/accounts.vault.json" 6 | composer: 7 | # Editor to use when composing messages. If not set, use the $EDITOR environment variable. 8 | editor: 9 | server: 10 | # Should we be able to connect to self-signed and other insecure servers? 11 | allow_insecure: false 12 | # Display HTTP communication between client and server 13 | debug_http: false 14 | 15 | # How can we resolve public keys and accounts 16 | resolver: 17 | remote: 18 | # Enable remote resolving 19 | enabled: true 20 | url: "https://resolver.bitmaelum.com" 21 | # Allow insecure connections (to selfsigned certs) 22 | allow_insecure: false 23 | 24 | -------------------------------------------------------------------------------- /buildscripts/docker/docker-entrypoint-client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Check if the /bitmaelum directory is mounted. If not, throw an error 4 | mount | grep 'on /bitmaelum type' 5 | if [ $? -eq 1 ] ; then 6 | echo "" 7 | echo "********************************* WARNING *********************************" 8 | echo "" 9 | echo "You are trying to run the bitmaelum docker image without mounting a local " 10 | echo "directory to /bitmaelum. This means your data will not be persisted and " 11 | echo "you could loose your vault data. Please mount the directory through docker:" 12 | echo "" 13 | echo " docker run -v /local/dir:/bitmaelum bitmaelum/client:latest" 14 | echo "" 15 | echo "********************************* WARNING *********************************" 16 | exit 0 17 | fi 18 | 19 | exec /usr/local/bin/bm-client "$@" 20 | -------------------------------------------------------------------------------- /buildscripts/docker/docker-entrypoint-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | 5 | exec /usr/local/bin/bm-server "$@" 6 | -------------------------------------------------------------------------------- /buildscripts/docker/docker-entrypoint-suite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | exec /usr/local/bin/bm-client "$@" 5 | -------------------------------------------------------------------------------- /buildscripts/docker/generate-client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f Makefile ] ; then 4 | echo "Please run this file in the root of the source: ./buildscripts/docker/generate-client.sh" 5 | exit 1 6 | fi 7 | 8 | if [ ! -f ./release/linux-amd64/bm-client ] ; then 9 | make -j linux-amd64 10 | fi 11 | 12 | TMPDIR="tmp-$$" 13 | mkdir $TMPDIR 14 | 15 | cp ./buildscripts/docker/bitmaelum-client-config.yml $TMPDIR 16 | cp ./buildscripts/docker/docker-entrypoint-client.sh $TMPDIR 17 | cp ./release/linux-amd64/bm-* $TMPDIR 18 | 19 | docker build -t bitmaelum/client -f ./buildscripts/docker/Dockerfile.client $TMPDIR 20 | docker push bitmaelum/client:latest 21 | 22 | if [ ! -z "$1" ] ; then 23 | echo "Tag found: $1" 24 | docker tag bitmaelum/client:latest bitmaelum/client:$1 25 | docker push bitmaelum/client:$1 26 | fi 27 | 28 | 29 | rm -rf $TMPDIR 30 | -------------------------------------------------------------------------------- /buildscripts/docker/generate-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f Makefile ] ; then 4 | echo "Please run this file in the root of the source: ./buildscripts/docker/generate-server.sh" 5 | exit 1 6 | fi 7 | 8 | if [ ! -f ./release/linux-amd64/bm-server ] ; then 9 | make -j linux-amd64 10 | fi 11 | 12 | TMPDIR="tmp-$$" 13 | mkdir $TMPDIR 14 | 15 | cp ./buildscripts/docker/bitmaelum-server-config.yml $TMPDIR 16 | cp ./buildscripts/docker/docker-entrypoint-server.sh $TMPDIR 17 | cp ./release/linux-amd64/bm-* $TMPDIR 18 | 19 | docker build -t bitmaelum/server -f ./buildscripts/docker/Dockerfile.server $TMPDIR 20 | docker push bitmaelum/server:latest 21 | 22 | if [ ! -z "$1" ] ; then 23 | echo "Tag found: $1" 24 | docker tag bitmaelum/server:latest bitmaelum/server:$1 25 | docker push bitmaelum/server:$1 26 | fi 27 | 28 | rm -rf $TMPDIR 29 | -------------------------------------------------------------------------------- /buildscripts/docker/generate-suite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f Makefile ] ; then 4 | echo "Please run this file in the root of the source: ./buildscripts/docker/generate-server.sh" 5 | exit 1 6 | fi 7 | 8 | if [ ! -f ./release/linux-amd64/bm-server ] ; then 9 | make -j linux-amd64 10 | fi 11 | 12 | TMPDIR="tmp-$$" 13 | mkdir $TMPDIR 14 | 15 | cp ./buildscripts/docker/docker-entrypoint-suite.sh $TMPDIR 16 | cp ./release/linux-amd64/bm-* $TMPDIR 17 | 18 | docker build -t bitmaelum/suite -f ./buildscripts/docker/Dockerfile.suite $TMPDIR 19 | docker push bitmaelum/suite:latest 20 | 21 | if [ ! -z "$1" ] ; then 22 | echo "Tag found: $1" 23 | docker tag bitmaelum/suite:latest bitmaelum/suite:$1 24 | docker push bitmaelum/suite:$1 25 | fi 26 | 27 | rm -rf $TMPDIR 28 | -------------------------------------------------------------------------------- /buildscripts/docker/server-config.yml: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /buildscripts/signtool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmaelum/bitmaelum-suite/95952d193fb9f2f4be9160453eb4c11954b629bf/buildscripts/signtool.exe -------------------------------------------------------------------------------- /cmd/bm-bridge/internal/imap/backend/storage.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package imapgw 21 | 22 | // Storable interface is the main interface to store and retrieve flags 23 | type Storable interface { 24 | // Retrieve retrieves the given messageid from the storage and returns its flags info 25 | Retrieve(messageid string) []string 26 | // Store stores the given proof of work in the storage 27 | Store(messageid string, flags []string) error 28 | } 29 | -------------------------------------------------------------------------------- /cmd/bm-bridge/main_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "github.com/Freman/eventloghook" 24 | "github.com/bitmaelum/bitmaelum-suite/internal" 25 | "github.com/sirupsen/logrus" 26 | ) 27 | 28 | func init() { 29 | internal.ParseOptions(&opts) 30 | 31 | if opts.Service { 32 | elog, err = eventlog.Open("BitMaelum Bridge") 33 | if err == nil { 34 | defer elog.Close() 35 | logrus.AddHook(eventloghook.NewHook(elog)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /cmd/bm-client/README.md: -------------------------------------------------------------------------------- 1 | # bm-client 2 | 3 | A simple client to create / manage accounts and to read and send mail. 4 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/account.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var accountCmd = &cobra.Command{ 27 | Use: "account", 28 | Short: "Account management", 29 | } 30 | 31 | func init() { 32 | rootCmd.AddCommand(accountCmd) 33 | } 34 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/account_key.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var accountKeyCmd = &cobra.Command{ 27 | Use: "key", 28 | Short: "Account key management", 29 | } 30 | 31 | var ( 32 | akAccount *string 33 | ) 34 | 35 | func init() { 36 | accountCmd.AddCommand(accountKeyCmd) 37 | 38 | akAccount = accountKeyCmd.PersistentFlags().String("account", "", "Account to key on") 39 | 40 | _ = accountKeyCmd.MarkPersistentFlagRequired("account") 41 | } 42 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/account_setting.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var accountSettingsCmd = &cobra.Command{ 27 | Use: "settings", 28 | Short: "Settings management", 29 | } 30 | 31 | var ( 32 | asAccount *string 33 | ) 34 | 35 | func init() { 36 | accountCmd.AddCommand(accountSettingsCmd) 37 | 38 | asAccount = accountSettingsCmd.PersistentFlags().String("account", "", "Account to set on") 39 | 40 | _ = accountSettingsCmd.MarkPersistentFlagRequired("account") 41 | } 42 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/account_setting_list.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/internal/vault" 27 | "github.com/olekukonko/tablewriter" 28 | "github.com/spf13/cobra" 29 | ) 30 | 31 | var accountSettingsListCmd = &cobra.Command{ 32 | Use: "list", 33 | Short: "Display settings", 34 | Run: func(cmd *cobra.Command, args []string) { 35 | v := vault.OpenDefaultVault() 36 | 37 | info, err := vault.GetAccount(v, *asAccount) 38 | if err != nil { 39 | fmt.Println("cannot find account in vault") 40 | os.Exit(1) 41 | } 42 | 43 | table := tablewriter.NewWriter(os.Stdout) 44 | table.SetHeader([]string{"Key", "Value"}) 45 | 46 | table.Append([]string{"Name", info.Name}) 47 | 48 | if info.Settings != nil { 49 | for k, v := range info.Settings { 50 | table.Append([]string{k, v}) 51 | } 52 | } 53 | 54 | table.Render() 55 | }, 56 | } 57 | 58 | func init() { 59 | accountSettingsCmd.AddCommand(accountSettingsListCmd) 60 | } 61 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/api.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var apiCmd = &cobra.Command{ 27 | Use: "api", 28 | Short: "Manage API keys", 29 | Long: `Manage your API keys`, 30 | } 31 | 32 | var apiAddress *string 33 | 34 | func init() { 35 | rootCmd.AddCommand(apiCmd) 36 | 37 | apiAddress = apiCmd.PersistentFlags().StringP("account", "a", "", "Account") 38 | _ = apiCmd.MarkPersistentFlagRequired("account") 39 | } 40 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/auth.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var authCmd = &cobra.Command{ 27 | Use: "auth", 28 | Short: "Authorization management", 29 | } 30 | 31 | var ( 32 | authAccount *string 33 | ) 34 | 35 | func init() { 36 | rootCmd.AddCommand(authCmd) 37 | 38 | authAccount = authCmd.PersistentFlags().StringP("account", "a", "", "Account") 39 | 40 | _ = authCmd.MarkPersistentFlagRequired("account") 41 | } 42 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/config.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var configCmd = &cobra.Command{ 27 | Use: "config", 28 | Short: "Config management", 29 | Long: ``, 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(configCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/config_edit.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | bminternal "github.com/bitmaelum/bitmaelum-suite/internal" 27 | "github.com/bitmaelum/bitmaelum-suite/internal/config" 28 | "github.com/spf13/cobra" 29 | ) 30 | 31 | var configEditCmd = &cobra.Command{ 32 | Use: "edit", 33 | Short: "Edits the current configuration file", 34 | Long: ``, 35 | Run: func(cmd *cobra.Command, args []string) { 36 | 37 | err := bminternal.EditFile(config.LoadedClientConfigPath) 38 | if err != nil { 39 | fmt.Println("cannot open editor. Please edit this file manually.") 40 | os.Exit(1) 41 | } 42 | }, 43 | } 44 | 45 | func init() { 46 | configCmd.AddCommand(configEditCmd) 47 | } 48 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/config_show.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/internal/config" 27 | "github.com/spf13/cobra" 28 | "gopkg.in/yaml.v3" 29 | ) 30 | 31 | var configShowCmd = &cobra.Command{ 32 | Use: "show", 33 | Short: "Displays the current configuration settings", 34 | Long: ``, 35 | Run: func(cmd *cobra.Command, args []string) { 36 | b, err := yaml.Marshal(config.Client) 37 | if err != nil { 38 | fmt.Println("cannot display configuration") 39 | os.Exit(1) 40 | } 41 | 42 | fmt.Println(string(b)) 43 | }, 44 | Annotations: map[string]string{ 45 | "dont_display_logo": "true", 46 | }, 47 | } 48 | 49 | func init() { 50 | configCmd.AddCommand(configShowCmd) 51 | } 52 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/message.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var messageCmd = &cobra.Command{ 27 | Use: "message", 28 | Aliases: []string{"msg"}, 29 | Short: "Message management", 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(messageCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/organisation.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var organisationCmd = &cobra.Command{ 27 | Use: "organisation", 28 | Aliases: []string{"org"}, 29 | Short: "Organisation management", 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(organisationCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/organisation_validate.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var organisationValidateCmd = &cobra.Command{ 27 | Use: "validate", 28 | Aliases: []string{"org"}, 29 | Short: "Organisation validation management", 30 | } 31 | 32 | var ( 33 | ovOrganisation *string 34 | ) 35 | 36 | func init() { 37 | organisationCmd.AddCommand(organisationValidateCmd) 38 | 39 | ovOrganisation = organisationValidateCmd.PersistentFlags().StringP("organisation", "o", "", "Organisation") 40 | 41 | _ = organisationValidateCmd.MarkPersistentFlagRequired("organisation") 42 | } 43 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/resolver.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var resolverCmd = &cobra.Command{ 27 | Use: "resolver", 28 | Short: "Index the resolver", 29 | Long: ``, 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(resolverCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/stdout.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | ) 26 | 27 | func fatal(args ...interface{}) { 28 | fmt.Println(append([]interface{}{"Error: "}, args...)...) 29 | os.Exit(1) 30 | } 31 | 32 | func warn(args ...interface{}) { 33 | fmt.Println(append([]interface{}{"Warning: "}, args...)...) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/vault.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var vaultCmd = &cobra.Command{ 27 | Use: "vault", 28 | Short: "Vault management", 29 | Long: ``, 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(vaultCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/vault_password.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/internal/console" 27 | "github.com/bitmaelum/bitmaelum-suite/internal/vault" 28 | "github.com/spf13/cobra" 29 | ) 30 | 31 | var vaultPasswordCmd = &cobra.Command{ 32 | Use: "password", 33 | Short: "Changes the password for the vault", 34 | Run: func(cmd *cobra.Command, args []string) { 35 | v := vault.OpenDefaultVault() 36 | 37 | pwd, err := console.AskDoublePassword() 38 | if err != nil { 39 | fmt.Println("error: cannot change password: ", err) 40 | os.Exit(1) 41 | } 42 | 43 | v.SetPassword(pwd) 44 | err = v.Persist() 45 | if err != nil { 46 | fmt.Println("error: cannot change password: ", err) 47 | os.Exit(1) 48 | } 49 | 50 | fmt.Println("successfully changed password") 51 | }, 52 | } 53 | 54 | func init() { 55 | vaultCmd.AddCommand(vaultPasswordCmd) 56 | } 57 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/webhook.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var webhookCmd = &cobra.Command{ 27 | Use: "webhook", 28 | Short: "Webhook management", 29 | } 30 | 31 | var ( 32 | whAccount *string 33 | ) 34 | 35 | func init() { 36 | rootCmd.AddCommand(webhookCmd) 37 | 38 | whAccount = webhookCmd.PersistentFlags().StringP("account", "a", "", "Account") 39 | 40 | _ = webhookCmd.MarkPersistentFlagRequired("account") 41 | } 42 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/webhook_disable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/internal" 27 | "github.com/sirupsen/logrus" 28 | 29 | "github.com/spf13/cobra" 30 | ) 31 | 32 | var webhookDisableCmd = &cobra.Command{ 33 | Use: "disable", 34 | Short: "Disable webhook", 35 | Long: ``, 36 | Run: func(cmd *cobra.Command, args []string) { 37 | // Get generic structs 38 | _, info, client, err := internal.GetClientAndInfo(*whAccount) 39 | if err != nil { 40 | logrus.Fatal(err) 41 | os.Exit(1) 42 | } 43 | 44 | err = client.DisableWebhook(info.Address.Hash(), *whdID) 45 | if err != nil { 46 | logrus.Fatal("cannot disable webhook: ", err) 47 | os.Exit(1) 48 | } 49 | 50 | fmt.Println("Webhook is disabled") 51 | }, 52 | } 53 | 54 | var whdID *string 55 | 56 | func init() { 57 | whdID = webhookDisableCmd.Flags().String("id", "", "webhook ID to disable") 58 | 59 | webhookCmd.AddCommand(webhookDisableCmd) 60 | } 61 | -------------------------------------------------------------------------------- /cmd/bm-client/cmd/webhook_enable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/internal" 27 | "github.com/sirupsen/logrus" 28 | 29 | "github.com/spf13/cobra" 30 | ) 31 | 32 | var webhookEnableCmd = &cobra.Command{ 33 | Use: "enable", 34 | Short: "Enable webhook", 35 | Long: ``, 36 | Run: func(cmd *cobra.Command, args []string) { 37 | // Get generic structs 38 | _, info, client, err := internal.GetClientAndInfo(*whAccount) 39 | if err != nil { 40 | logrus.Fatal(err) 41 | os.Exit(1) 42 | } 43 | 44 | err = client.EnableWebhook(info.Address.Hash(), *wheID) 45 | if err != nil { 46 | logrus.Fatal("cannot enable webhook: ", err) 47 | os.Exit(1) 48 | } 49 | 50 | fmt.Println("Webhook is enabled") 51 | }, 52 | } 53 | 54 | var wheID *string 55 | 56 | func init() { 57 | wheID = webhookEnableCmd.Flags().String("id", "", "webhook ID to enable") 58 | 59 | webhookCmd.AddCommand(webhookEnableCmd) 60 | } 61 | -------------------------------------------------------------------------------- /cmd/bm-client/handlers/compose.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package handlers 21 | 22 | import ( 23 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/internal" 24 | "github.com/bitmaelum/bitmaelum-suite/internal/api" 25 | "github.com/bitmaelum/bitmaelum-suite/internal/message" 26 | "github.com/bitmaelum/bitmaelum-suite/internal/messages" 27 | ) 28 | 29 | // ComposeMessage composes a new message from the given account Info to the "to" with given subject, blocks and attachments 30 | func ComposeMessage(addressing message.Addressing, subject string, b, a []string) error { 31 | envelope, err := message.Compose(addressing, subject, b, a) 32 | if err != nil { 33 | return err 34 | } 35 | 36 | // Setup API connection to the server 37 | client, err := api.NewAuthenticated(*addressing.Sender.Address, *addressing.Sender.PrivKey, addressing.Sender.Host, internal.JwtErrorFunc) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | // and finally send 43 | err = messages.Send(*client, envelope) 44 | if err != nil { 45 | return err 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /cmd/bm-client/internal/lastread.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "io/ioutil" 24 | "strconv" 25 | "time" 26 | 27 | "github.com/mitchellh/go-homedir" 28 | ) 29 | 30 | const readTimeFile = "~/.bm-lastread" 31 | 32 | // GetReadTime will return the last saved reading time or 0 when no time-file is found 33 | func GetReadTime() time.Time { 34 | p, err := homedir.Expand(readTimeFile) 35 | if err != nil { 36 | return time.Time{} 37 | } 38 | 39 | b, err := ioutil.ReadFile(p) 40 | if err != nil { 41 | return time.Time{} 42 | } 43 | 44 | ts, err := strconv.ParseInt(string(b), 10, 64) 45 | if err != nil { 46 | return time.Time{} 47 | } 48 | 49 | return time.Unix(ts, 0) 50 | } 51 | 52 | // SaveReadTime will save the read time to disk 53 | func SaveReadTime(t time.Time) { 54 | p, err := homedir.Expand(readTimeFile) 55 | if err != nil { 56 | return 57 | } 58 | 59 | ts := strconv.FormatInt(t.Unix(), 10) 60 | _ = ioutil.WriteFile(p, []byte(ts), 0600) 61 | } 62 | -------------------------------------------------------------------------------- /cmd/bm-client/internal/options.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | type options struct { 23 | Config string `short:"c" long:"config" description:"Path to your configuration file"` 24 | Password string `short:"p" long:"password" description:"Vault password" default:""` 25 | Vault string `long:"vault" description:"Custom vault file" default:""` 26 | Version bool `short:"v" long:"version" description:"Display version information"` 27 | Debug bool `long:"debug" description:"Display HTTP traffic"` 28 | } 29 | 30 | // Opts are the options set through the command line 31 | var Opts options 32 | -------------------------------------------------------------------------------- /cmd/bm-client/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "math/rand" 25 | "os" 26 | "time" 27 | 28 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/cmd" 29 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/internal" 30 | bminternal "github.com/bitmaelum/bitmaelum-suite/internal" 31 | "github.com/bitmaelum/bitmaelum-suite/internal/vault" 32 | ) 33 | 34 | func main() { 35 | rand.Seed(time.Now().UnixNano()) 36 | 37 | bminternal.ParseOptions(&internal.Opts) 38 | if internal.Opts.Version { 39 | bminternal.WriteVersionInfo("BitMaelum Client", os.Stdout) 40 | fmt.Println() 41 | os.Exit(1) 42 | } 43 | 44 | // Set default vault info if set in config 45 | vault.VaultPassword = internal.Opts.Password 46 | if internal.Opts.Vault != "" { 47 | vault.VaultPath = internal.Opts.Vault 48 | } 49 | 50 | cmd.Execute() 51 | } 52 | -------------------------------------------------------------------------------- /cmd/bm-config/README.md: -------------------------------------------------------------------------------- 1 | # Tool: bm-config 2 | 3 | Allows you to easily configure certain aspects of your mail server. 4 | 5 | Current supported the following configuration settings: 6 | 7 | 8 | * `invite`: Enables an account to be registered on the mailserver. 9 | 10 | ./bm-config uninvite --address [address] --days <30> 11 | 12 | Each address invite is valid for a maximum of a number of days (default 30). After this, the address 13 | should be registered again with invite command. 14 | 15 | This command returns a token that must be used while registring an account in the mail client. 16 | 17 | * `uninvite`: Removes an account invite 18 | 19 | ./bm-config uninvite --address [address] 20 | 21 | * `init-config`: Generates either a server or client configuration (or both) that can be your starting point. 22 | 23 | ./bm-config init-config [--server] [--client] 24 | 25 | * `generate-cert`: Generates a self-signed certificate 26 | 27 | ./bm-config generate-cert --domain bitmaelum.mydomain.com 28 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/apikey.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | // apiKeyCmd represents the apiKey command 27 | var apiKeyCmd = &cobra.Command{ 28 | Use: "apikey", 29 | Short: "Api key management", 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(apiKeyCmd) 34 | } 35 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/apikey_list.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | 25 | "github.com/spf13/cobra" 26 | ) 27 | 28 | // apiKeyListCmd represents the apiKey command 29 | var apiKeyListCmd = &cobra.Command{ 30 | Use: "list", 31 | Short: "List all current keys", 32 | Run: func(cmd *cobra.Command, args []string) { 33 | fmt.Println("listing keys not yet supported") 34 | }, 35 | } 36 | 37 | func init() { 38 | apiKeyCmd.AddCommand(apiKeyListCmd) 39 | 40 | // mgAdmin = apiKeyCreateCmd.Flags().Bool("admin", false, "Admin key") 41 | // mgPerms = apiKeyCreateCmd.Flags().StringSlice("permissions", []string{}, "List of permissions") 42 | // mgValid = apiKeyCreateCmd.Flags().String("valid", "", "Days (or duration) the key is valid. Accepts 10d, or even 1h30m50s") 43 | // mgAddrHash = apiKeyCreateCmd.Flags().String("addr", "", "Account hash for this specific api key") 44 | // mgDesc = apiKeyCreateCmd.Flags().String("desc", "", "Description of this key") 45 | } 46 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/generate_key.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto" 26 | "github.com/sirupsen/logrus" 27 | "github.com/spf13/cobra" 28 | ) 29 | 30 | // generateKeyCmd represents the generatekey command 31 | var generateKeyCmd = &cobra.Command{ 32 | Use: "generate-key", 33 | Short: "Generates a new key", 34 | Long: `This command generates a new key`, 35 | Run: func(cmd *cobra.Command, args []string) { 36 | kt, err := bmcrypto.FindKeyType(*keyType) 37 | if err != nil { 38 | logrus.Fatal(err) 39 | } 40 | privKey, pubKey, err := bmcrypto.GenerateKeyPair(kt) 41 | if err != nil { 42 | logrus.Fatal(err) 43 | } 44 | 45 | fmt.Println("Private key : ", privKey.String()) 46 | fmt.Println("Public key : ", pubKey.String()) 47 | }, 48 | } 49 | 50 | var keyType *string 51 | 52 | func init() { 53 | rootCmd.AddCommand(generateKeyCmd) 54 | 55 | keyType = generateKeyCmd.Flags().StringP("keytype", "k", "ed25519", "The keytype (defaults to ed25519)") 56 | } 57 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/root.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/spf13/cobra" 27 | ) 28 | 29 | var rootCmd = &cobra.Command{ 30 | Use: "bm-config", 31 | Short: "Configuration application for your mail server and client", 32 | Long: `This tool allows you to easily manage certain aspects of your BitMaelum server and client.`, 33 | } 34 | 35 | // Execute runs the given command 36 | func Execute() { 37 | if err := rootCmd.Execute(); err != nil { 38 | fmt.Println(err) 39 | os.Exit(1) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/service_restart.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | 25 | "github.com/sirupsen/logrus" 26 | "github.com/spf13/cobra" 27 | ) 28 | 29 | // serviceRestartCmd represents the serviceStartCmd command 30 | var serviceRestartCmd = &cobra.Command{ 31 | Use: "restart", 32 | Short: "Restarts the service", 33 | Run: func(cmd *cobra.Command, args []string) { 34 | fmt.Print("Stopping service... ") 35 | err := stopService(getServiceName(cmd)) 36 | if err != nil { 37 | fmt.Println("ERR") 38 | logrus.Fatalf("Unable to stop service: %v", err) 39 | } 40 | 41 | fmt.Println("OK") 42 | 43 | fmt.Print("Starting service... ") 44 | err = startService(getServiceName(cmd)) 45 | if err != nil { 46 | fmt.Println("ERR") 47 | logrus.Fatalf("Unable to start service: %v", err) 48 | } 49 | 50 | fmt.Println("OK") 51 | }, 52 | } 53 | 54 | func init() { 55 | serviceCmd.AddCommand(serviceRestartCmd) 56 | } 57 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/service_start.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | 25 | "github.com/kardianos/service" 26 | "github.com/sirupsen/logrus" 27 | "github.com/spf13/cobra" 28 | ) 29 | 30 | // serviceStartCmd represents the serviceStartCmd command 31 | var serviceStartCmd = &cobra.Command{ 32 | Use: "start", 33 | Short: "Starts the service", 34 | Run: func(cmd *cobra.Command, args []string) { 35 | fmt.Print("Starting service... ") 36 | err := startService(getServiceName(cmd)) 37 | if err != nil { 38 | fmt.Println("ERR") 39 | logrus.Fatalf("Unable to start service: %v", err) 40 | } 41 | 42 | fmt.Println("OK") 43 | }, 44 | } 45 | 46 | func startService(svc *service.Config) error { 47 | s, err := service.New(nil, svc) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | return service.Control(s, "start") 53 | } 54 | 55 | func init() { 56 | serviceCmd.AddCommand(serviceStartCmd) 57 | } 58 | -------------------------------------------------------------------------------- /cmd/bm-config/cmd/service_stop.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | 25 | "github.com/kardianos/service" 26 | "github.com/sirupsen/logrus" 27 | "github.com/spf13/cobra" 28 | ) 29 | 30 | // serviceStopCmd represents the serviceStopCmd command 31 | var serviceStopCmd = &cobra.Command{ 32 | Use: "stop", 33 | Short: "Stops the service", 34 | Run: func(cmd *cobra.Command, args []string) { 35 | fmt.Print("Stopping service... ") 36 | err := stopService(getServiceName(cmd)) 37 | if err != nil { 38 | fmt.Println("ERR") 39 | logrus.Fatalf("Unable to stop service: %v", err) 40 | } 41 | 42 | fmt.Println("OK") 43 | }, 44 | } 45 | 46 | func stopService(svc *service.Config) error { 47 | s, err := service.New(nil, svc) 48 | if err != nil { 49 | return err 50 | } 51 | 52 | return service.Control(s, "stop") 53 | } 54 | 55 | func init() { 56 | serviceCmd.AddCommand(serviceStopCmd) 57 | } 58 | -------------------------------------------------------------------------------- /cmd/bm-config/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "math/rand" 25 | "os" 26 | "time" 27 | 28 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-config/cmd" 29 | "github.com/bitmaelum/bitmaelum-suite/internal" 30 | "github.com/bitmaelum/bitmaelum-suite/internal/config" 31 | ) 32 | 33 | type options struct { 34 | Version bool `short:"v" long:"version" description:"Display version information"` 35 | AsJSON bool `long:"json" description:"Return results as JSON"` 36 | } 37 | 38 | var opts options 39 | 40 | func main() { 41 | rand.Seed(time.Now().UnixNano()) 42 | 43 | internal.ParseOptions(&opts) 44 | if opts.Version { 45 | internal.WriteVersionInfo("BitMaelum Server", os.Stdout) 46 | fmt.Println() 47 | os.Exit(1) 48 | } 49 | 50 | if !opts.AsJSON { 51 | fmt.Println(internal.GetASCIILogo()) 52 | } 53 | 54 | _ = config.LoadClientConfigOrPass("") 55 | _ = config.LoadServerConfigOrPass("") 56 | _ = config.ReadRouting(config.Server.Server.RoutingFile) 57 | 58 | cmd.Execute() 59 | } 60 | -------------------------------------------------------------------------------- /cmd/bm-json/README.md: -------------------------------------------------------------------------------- 1 | # bm-client 2 | 3 | A simple client to create / manage accounts and to read and send mail. 4 | 5 | Commands: 6 | 7 | create-account 8 | list-accounts 9 | fetch-messages 10 | read 11 | compose 12 | -------------------------------------------------------------------------------- /cmd/bm-json/cmd/root.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package cmd 21 | 22 | import ( 23 | "os" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-json/internal/output" 26 | "github.com/spf13/cobra" 27 | ) 28 | 29 | var rootCmd = &cobra.Command{ 30 | Use: "bm-json", 31 | Short: "BitMaelum JSON outputer", 32 | Long: `This program will retrieve information and returns it nicely in a JSON format`, 33 | } 34 | 35 | // Execute runs the given command 36 | func Execute() { 37 | if err := rootCmd.Execute(); err != nil { 38 | output.JSONErrorOut(err) 39 | os.Exit(1) 40 | } 41 | } 42 | 43 | func init() { 44 | rootCmd.PersistentFlags().StringP("config", "c", "", "configuration file") 45 | rootCmd.PersistentFlags().StringP("password", "p", "", "password to unlock your account vault") 46 | } 47 | -------------------------------------------------------------------------------- /cmd/bm-json/internal/error.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "bytes" 24 | "io/ioutil" 25 | "net/http" 26 | "os" 27 | 28 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-json/internal/output" 29 | "github.com/bitmaelum/bitmaelum-suite/internal/api" 30 | ) 31 | 32 | // JwtJSONErrorFunc is the generic error handler that will catch any timing issues with the clock 33 | func JwtJSONErrorFunc(_ *http.Request, resp *http.Response) { 34 | if resp.StatusCode != 401 { 35 | return 36 | } 37 | 38 | // Read body 39 | b, _ := ioutil.ReadAll(resp.Body) 40 | _ = resp.Body.Close() 41 | 42 | err := api.GetErrorFromResponse(b) 43 | if err != nil && err.Error() == "token time not valid" { 44 | output.JSONErrorStrOut("JWT token time mismatch") 45 | os.Exit(1) 46 | } 47 | 48 | // Whoops.. not an error. Let's pretend nothing happened and create a new buffer so we can read the body again 49 | resp.Body = ioutil.NopCloser(bytes.NewReader(b)) 50 | } 51 | -------------------------------------------------------------------------------- /cmd/bm-json/internal/output/json.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package output 21 | 22 | import ( 23 | "encoding/json" 24 | "errors" 25 | "fmt" 26 | ) 27 | 28 | // JSONT is a simple type for generating JSON output 29 | type JSONT map[string]interface{} 30 | 31 | // JSONOut outputs a specific interface 32 | func JSONOut(v interface{}) { 33 | b, err := json.MarshalIndent(v, "", " ") 34 | if err != nil { 35 | return 36 | } 37 | 38 | fmt.Print(string(b)) 39 | } 40 | 41 | // JSONErrorOut outputs an error 42 | func JSONErrorOut(err error) { 43 | v := map[string]interface{}{ 44 | "error": err.Error(), 45 | } 46 | 47 | JSONOut(v) 48 | } 49 | 50 | // JSONErrorStrOut outputs an error string 51 | func JSONErrorStrOut(s string) { 52 | JSONErrorOut(errors.New(s)) 53 | } 54 | -------------------------------------------------------------------------------- /cmd/bm-mail/README.md: -------------------------------------------------------------------------------- 1 | # bm-mail 2 | 3 | A curses based mail client 4 | -------------------------------------------------------------------------------- /cmd/bm-send/README.md: -------------------------------------------------------------------------------- 1 | # bm-send 2 | 3 | A simple tool that will let you send messages on behalf of a bitmaelum address. 4 | 5 | $ ./bm-send --priv "PRIVKEY" --subject "a mail" --from "from!" --to "to!" --body "...." --attachment foo.zip 6 | 7 | will use the following environment variables: 8 | 9 | BITMAELUM_SEND_PRIVKEY 10 | BITMAELUM_SEND_FROM 11 | 12 | -------------------------------------------------------------------------------- /cmd/bm-server/handler/mgmt/flush.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package mgmt 21 | 22 | import ( 23 | "net/http" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-server/handler" 26 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-server/internal/httputils" 27 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-server/processor" 28 | "github.com/bitmaelum/bitmaelum-suite/internal" 29 | ) 30 | 31 | // FlushQueues handler will flush all the queues normally on tickers 32 | func FlushQueues(w http.ResponseWriter, req *http.Request) { 33 | k := handler.GetAPIKey(req) 34 | if !k.HasPermission(internal.PermFlush, nil) { 35 | httputils.ErrorOut(w, http.StatusUnauthorized, "unauthorized") 36 | return 37 | } 38 | 39 | // Reload configuration and such 40 | internal.Reload() 41 | 42 | // Flush queues. Note that this means that multiple queue processing can run multiple times 43 | go processor.ProcessRetryQueue(true) 44 | go processor.ProcessStuckIncomingMessages() 45 | go processor.ProcessStuckProcessingMessages() 46 | 47 | _ = httputils.JSONOut(w, http.StatusOK, httputils.StatusOk("Flushing queues")) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/bm-server/internal/account/box.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package account 21 | 22 | // Folder constants 23 | const ( 24 | BoxInbox = iota + 1 // BoxInbox is the mandatory inbox where all incoming messages are stored 25 | BoxOutbox // BoxOutbox is the mandatory outbox where send messages are stored 26 | BoxTrash // BoxTrash is the mandatory trashcan where deleted messages are stored (before actual deletion) 27 | ) 28 | 29 | // MandatoryBoxes is a list of all boxes that are mandatory. Makes it easier to range on them 30 | var MandatoryBoxes = []int{ 31 | BoxInbox, 32 | BoxOutbox, 33 | BoxTrash, 34 | } 35 | 36 | // MaxMandatoryBoxID is the largest box that must be present. Everything below this box (including this box) is 37 | // mandatory and cannot be removed. 38 | const MaxMandatoryBoxID = 99 39 | -------------------------------------------------------------------------------- /cmd/bm-server/internal/account/mock.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package account 21 | 22 | import ( 23 | "github.com/spf13/afero" 24 | ) 25 | 26 | // NewMockRepository returns a new mock repository by creating a file system with the afero memory mapped fs 27 | func NewMockRepository() Repository { 28 | repo := NewFileRepository("/mockstorage") 29 | repo.(*fileRepo).SetFileSystem(afero.NewMemMapFs(), false) 30 | return repo 31 | } 32 | -------------------------------------------------------------------------------- /cmd/bm-server/internal/container/account.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package container 21 | 22 | import ( 23 | "sync" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-server/internal/account" 26 | "github.com/bitmaelum/bitmaelum-suite/internal/config" 27 | ) 28 | 29 | var ( 30 | accountOnce sync.Once 31 | accountRepository account.Repository 32 | ) 33 | 34 | func setupAccountRepo() (interface{}, error) { 35 | accountOnce.Do(func() { 36 | accountRepository = account.NewFileRepository(config.Server.Paths.Accounts) 37 | }) 38 | 39 | return accountRepository, nil 40 | } 41 | 42 | func init() { 43 | Instance.SetShared("account", setupAccountRepo) 44 | } 45 | -------------------------------------------------------------------------------- /cmd/bm-server/internal/container/proof-of-work.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package container 21 | 22 | import ( 23 | "os" 24 | "sync" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/cmd/bm-server/internal/pow" 27 | "github.com/bitmaelum/bitmaelum-suite/internal/config" 28 | "github.com/go-redis/redis/v7" 29 | ) 30 | 31 | var ( 32 | proofOnce sync.Once 33 | proofService pow.Storable 34 | ) 35 | 36 | func setupProofService() (interface{}, error) { 37 | proofOnce.Do(func() { 38 | //If redis.host is set on the config file it will use redis instead of bolt 39 | if config.Server.Redis.Host != "" { 40 | opts := redis.Options{ 41 | Addr: config.Server.Redis.Host, 42 | DB: config.Server.Redis.Db, 43 | } 44 | 45 | proofService = pow.NewRedis(&opts) 46 | } else { 47 | if config.Server.Bolt.DatabasePath == "" { 48 | config.Server.Bolt.DatabasePath = os.TempDir() 49 | } 50 | 51 | proofService = pow.NewBolt(&config.Server.Bolt.DatabasePath) 52 | } 53 | 54 | }) 55 | 56 | return proofService, nil 57 | } 58 | 59 | func init() { 60 | Instance.SetShared("proof-of-work", setupProofService) 61 | } 62 | -------------------------------------------------------------------------------- /cmd/bm-server/internal/pow/storage.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package pow 21 | 22 | import ( 23 | "time" 24 | ) 25 | 26 | // ProofOfWork is the structure that keeps information about proof-of-work done for incoming messages. It connects 27 | // the proof-of-work with a message ID which can be used for uploading. 28 | type ProofOfWork struct { 29 | Challenge string `json:"challenge"` 30 | Bits int `json:"bits"` 31 | Proof uint64 `json:"proof"` 32 | Expires time.Time `json:"expires"` 33 | MsgID string `json:"msg_id"` 34 | Valid bool `json:"valid"` 35 | } 36 | 37 | // Storable interface is the main interface to store and retrieve proof-of-work 38 | type Storable interface { 39 | // Retrieve retrieves the given challenge from the storage and returns its proof-of-work info 40 | Retrieve(challenge string) (*ProofOfWork, error) 41 | // Store stores the given proof of work in the storage 42 | Store(pow *ProofOfWork) error 43 | // Remove removes the given challenge from the storage 44 | Remove(challenge string) error 45 | } 46 | -------------------------------------------------------------------------------- /cmd/bm-server/main_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "github.com/Freman/eventloghook" 24 | "github.com/bitmaelum/bitmaelum-suite/internal" 25 | "github.com/sirupsen/logrus" 26 | ) 27 | 28 | func init() { 29 | internal.ParseOptions(&opts) 30 | 31 | if opts.Service { 32 | elog, err = eventlog.Open("BitMaelum Server") 33 | if err == nil { 34 | defer elog.Close() 35 | logrus.AddHook(eventloghook.NewHook(elog)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /cmd/bm-server/middleware/logger.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package middleware 21 | 22 | import ( 23 | "net/http" 24 | "time" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/internal" 27 | "github.com/sirupsen/logrus" 28 | ) 29 | 30 | // Logger is a middleware that logs the timing of the given call 31 | type Logger struct{} 32 | 33 | // Middleware Logs the request time 34 | func (*Logger) Middleware(next http.Handler) http.Handler { 35 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 36 | t := internal.TimeNow() 37 | next.ServeHTTP(w, req) 38 | logrus.Tracef("execution time: %s", time.Since(t).String()) 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /cmd/bm-server/middleware/prettyjson.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package middleware 21 | 22 | import ( 23 | "net/http" 24 | ) 25 | 26 | // PrettyJSON is a middleware that will set a response header based on the request URI. This can be used to output 27 | // json data either indented or not. 28 | type PrettyJSON struct { 29 | http.ResponseWriter 30 | } 31 | 32 | // Middleware sets header based on query param 33 | func (*PrettyJSON) Middleware(next http.Handler) http.Handler { 34 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 35 | q := req.URL.Query() 36 | w.Header().Set("x-pretty-json", q.Get("pretty")) 37 | 38 | next.ServeHTTP(w, req) 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /cmd/bm-server/middleware/tracer.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package middleware 21 | 22 | import ( 23 | "net/http" 24 | 25 | "github.com/sirupsen/logrus" 26 | ) 27 | 28 | // Tracer is a middleware that logs the URL / status code of the call 29 | type Tracer struct { 30 | http.ResponseWriter 31 | status int 32 | } 33 | 34 | // WriteHeader writes the given header to the response writer 35 | func (t *Tracer) WriteHeader(code int) { 36 | t.status = code 37 | t.ResponseWriter.WriteHeader(code) 38 | } 39 | 40 | // Middleware Prints request in log 41 | func (*Tracer) Middleware(next http.Handler) http.Handler { 42 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 43 | t := Tracer{w, 200} 44 | next.ServeHTTP(&t, req) 45 | logrus.Debugf("%s %s (Returned: %d)", req.Method, req.URL, t.status) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /cmd/bm-server/processor/channels.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package processor 21 | 22 | import "github.com/sirupsen/logrus" 23 | 24 | var ( 25 | // IncomingChannel Message with given msgID is incoming from a client 26 | IncomingChannel chan string 27 | ) 28 | 29 | // QueueIncomingMessage queues message on the uploaded channel so it can be picked up for processing by the main loop 30 | func QueueIncomingMessage(msgID string) { 31 | logrus.Tracef("queueing incoming message %s", msgID) 32 | IncomingChannel <- msgID 33 | } 34 | -------------------------------------------------------------------------------- /cmd/bm-server/processor/channels_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package processor 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestQueueIncomingMessage(t *testing.T) { 29 | IncomingChannel = make(chan string, 1) 30 | 31 | QueueIncomingMessage("12345") 32 | 33 | id := <-IncomingChannel 34 | assert.Equal(t, "12345", id) 35 | } 36 | -------------------------------------------------------------------------------- /cmd/bm-server/processor/scoreboard.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package processor 21 | 22 | import "sync" 23 | 24 | type scoreboardType struct { 25 | mux sync.Mutex 26 | v map[string]int 27 | } 28 | 29 | var scoreboard scoreboardType 30 | 31 | // IsInScoreboard will check if the given message ID in the section is present 32 | func IsInScoreboard(section int, msgID string) bool { 33 | s, found := scoreboard.v[msgID] 34 | 35 | return found && s == section 36 | } 37 | 38 | // AddToScoreboard will set the message ID in the section in the scoreboard 39 | func AddToScoreboard(section int, msgID string) { 40 | scoreboard.mux.Lock() 41 | scoreboard.v[msgID] = section 42 | scoreboard.mux.Unlock() 43 | } 44 | 45 | // RemoveFromScoreboard will remove the message ID from the section in the scoreboard 46 | func RemoveFromScoreboard(section int, msgID string) { 47 | scoreboard.mux.Lock() 48 | delete(scoreboard.v, msgID) 49 | scoreboard.mux.Unlock() 50 | } 51 | 52 | func init() { 53 | scoreboard.v = make(map[string]int) 54 | } 55 | -------------------------------------------------------------------------------- /cmd/bm-server/processor/scoreboard_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package processor 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestScoreboard(t *testing.T) { 29 | assert.False(t, IsInScoreboard(0, "1234")) 30 | 31 | AddToScoreboard(0, "1234") 32 | assert.True(t, IsInScoreboard(0, "1234")) 33 | assert.False(t, IsInScoreboard(1, "1234")) 34 | assert.False(t, IsInScoreboard(0, "5678")) 35 | 36 | RemoveFromScoreboard(0, "1234") 37 | assert.False(t, IsInScoreboard(0, "1234")) 38 | } 39 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | wait_for_ci: false 4 | require_ci_to_pass: yes 5 | 6 | coverage: 7 | status: 8 | project: 9 | default: 10 | target: auto 11 | threshold: 5% 12 | patch: 13 | default: 14 | target: 0% 15 | threshold: 5% 16 | precision: 2 17 | round: down 18 | range: "50...75" 19 | 20 | parsers: 21 | gcov: 22 | branch_detection: 23 | conditional: yes 24 | loop: yes 25 | method: no 26 | macro: no 27 | 28 | comment: 29 | layout: "reach,diff,flags,tree" 30 | behavior: default 31 | require_changes: no 32 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Additional documentation 2 | 3 | Most of the (technical) documentation can be found on the wiki: https://github.com/bitmaelum/bitmaelum-suite/wiki 4 | -------------------------------------------------------------------------------- /docs/build.md: -------------------------------------------------------------------------------- 1 | # Build 2 | 3 | **Note: Minimum requirements for building BitMaelum is go 1.17.** 4 | 5 | We are using `make` to build our suite. 6 | 7 | The suite itself consists of several main apps and some additional tools. The tools are not needed for running BitMaelum, but can come in handy during debugging and development. 8 | 9 | To test the current suite: 10 | 11 | make test 12 | 13 | To build the current suite on your own platform and archicture: 14 | 15 | make build 16 | 17 | The binaries will be compiled into `release` directory. 18 | 19 | If you want to build a specific app or tool, just supply the name: 20 | 21 | make bm-server 22 | 23 | This will rebuild only the `bm-server` binary. 24 | 25 | 26 | ## Cross platform builds 27 | It's possible to build different platforms and architectures: 28 | 29 | make build-all 30 | 31 | All binaries will be compiled into the `release/-` directory. 32 | 33 | Currently, the following platforms are automatically build: 34 | 35 | - windows-amd64 36 | - linux-amd64 37 | - darwin-amd64 38 | 39 | It's possible to compile only a single platform: 40 | 41 | make linux-amd64 42 | 43 | It's not possible to build cross-compile a single binary (ie: `make linux-amd bm-server` will not work) 44 | -------------------------------------------------------------------------------- /internal/base64.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import "encoding/base64" 23 | 24 | // Encode data into base64 25 | func Encode(src []byte) []byte { 26 | dst := make([]byte, base64.StdEncoding.EncodedLen(len(src))) 27 | 28 | base64.StdEncoding.Encode(dst, src) 29 | 30 | return dst 31 | } 32 | 33 | // Decode base64 back into bytes 34 | func Decode(src []byte) ([]byte, error) { 35 | dst := make([]byte, base64.StdEncoding.DecodedLen(len(src))) 36 | 37 | _, err := base64.StdEncoding.Decode(dst, src) 38 | return dst, err 39 | } 40 | -------------------------------------------------------------------------------- /internal/base64_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestEncodeDecode(t *testing.T) { 29 | b := Encode([]byte("foobar")) 30 | assert.Equal(t, []byte{0x5a, 0x6d, 0x39, 0x76, 0x59, 0x6d, 0x46, 0x79}, b) 31 | 32 | s, err := Decode(b) 33 | assert.NoError(t, err) 34 | assert.Equal(t, "foobar", string(s)) 35 | } 36 | -------------------------------------------------------------------------------- /internal/config/paths_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | //go:build !windows 21 | // +build !windows 22 | 23 | package config 24 | 25 | func getSearchPaths() []string { 26 | return []string{ 27 | "./", 28 | "~/", 29 | "/etc/bitmaelum/", 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /internal/config/paths_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | //go:build windows 21 | // +build windows 22 | 23 | package config 24 | 25 | func getSearchPaths() []string { 26 | return []string{ 27 | "./", 28 | "~/", 29 | "%ProgramData%/BitMaelum/etc/bitmaelum/", 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /internal/config/routing_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package config 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/spf13/afero" 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestGenerate(t *testing.T) { 30 | r, err := GenerateRouting() 31 | assert.NoError(t, err) 32 | 33 | assert.NotEmpty(t, r.RoutingID) 34 | assert.NotEmpty(t, r.KeyPair) 35 | } 36 | 37 | func TestReadSaveRouting(t *testing.T) { 38 | r, err := GenerateRouting() 39 | assert.NoError(t, err) 40 | 41 | fs = afero.NewMemMapFs() 42 | 43 | err = SaveRouting("/generated/routing.json", r) 44 | assert.NoError(t, err) 45 | 46 | err = ReadRouting("/generated/routing.json") 47 | assert.NoError(t, err) 48 | assert.Equal(t, r.RoutingID, Routing.RoutingID) 49 | } 50 | -------------------------------------------------------------------------------- /internal/console/mnemonic_phrase.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package console 21 | 22 | import ( 23 | "bufio" 24 | "fmt" 25 | "os" 26 | "strings" 27 | ) 28 | 29 | // AskMnemonicPhrase asks for the mnemonic phrase 30 | func AskMnemonicPhrase() string { 31 | fmt.Print("Please enter your mnemonic words:") 32 | 33 | reader := bufio.NewReader(os.Stdin) 34 | mnemonic, _ := reader.ReadString('\n') 35 | 36 | return strings.TrimSpace(strings.ToLower(mnemonic)) 37 | } 38 | -------------------------------------------------------------------------------- /internal/container/README.md: -------------------------------------------------------------------------------- 1 | This is more or less a service locator / DI system. 2 | 3 | I'm not sure if this is the way forward when it comes to idiomatic golang. I 4 | haven't seen this is larger projects so maybe the need for this is not there. 5 | -------------------------------------------------------------------------------- /internal/container/store.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package container 21 | 22 | import ( 23 | "sync" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/internal/config" 26 | "github.com/bitmaelum/bitmaelum-suite/internal/store" 27 | ) 28 | 29 | var ( 30 | storeOnce sync.Once 31 | storeRepository store.Repository 32 | ) 33 | 34 | func setupStoreRepo() (interface{}, error) { 35 | storeOnce.Do(func() { 36 | storeRepository = store.NewBoltRepository(config.Server.Paths.Accounts) 37 | }) 38 | 39 | return storeRepository, nil 40 | } 41 | 42 | func init() { 43 | Instance.SetShared("store", setupStoreRepo) 44 | } 45 | -------------------------------------------------------------------------------- /internal/editor_others.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | //go:build !windows 21 | // +build !windows 22 | 23 | package internal 24 | 25 | func getEditorPaths() []string { 26 | return []string{ 27 | "/usr/bin/editor", 28 | "/usr/bin/nano", 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /internal/editor_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "os" 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestFindEditor(t *testing.T) { 30 | ed, err := FindEditor("edit.exe") 31 | assert.NoError(t, err) 32 | assert.Equal(t, "edit.exe", ed) 33 | 34 | _ = os.Setenv("EDITOR", "foo-edit.exe") 35 | ed, err = FindEditor("") 36 | assert.NoError(t, err) 37 | assert.Equal(t, "foo-edit.exe", ed) 38 | } 39 | 40 | func TestGetEditorPaths(t *testing.T) { 41 | assert.Greater(t, len(getEditorPaths()), 0) 42 | } 43 | -------------------------------------------------------------------------------- /internal/editor_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | //go:build windows 21 | // +build windows 22 | 23 | package internal 24 | 25 | func getEditorPaths() []string { 26 | return []string{ 27 | "c:\\windows\\system32\\notepad.exe", 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /internal/key/mock_storage_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package key 21 | 22 | import ( 23 | "testing" 24 | "time" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 27 | "github.com/stretchr/testify/assert" 28 | ) 29 | 30 | func TestMockRepo(t *testing.T) { 31 | repo := NewAPIMockRepository() 32 | 33 | h := hash.New("example!") 34 | k := NewAPIAccountKey(h, []string{"foo", "bar"}, time.Time{}, "my desc") 35 | err := repo.Store(k) 36 | assert.NoError(t, err) 37 | 38 | k2, err := repo.Fetch(k.ID) 39 | assert.NoError(t, err) 40 | assert.Equal(t, []string{"foo", "bar"}, k2.Permissions) 41 | assert.Equal(t, "my desc", k2.Desc) 42 | 43 | h = hash.New("example!") 44 | k = NewAPIAccountKey(h, []string{"foo", "bar"}, time.Time{}, "my desc 2") 45 | err = repo.Store(k) 46 | assert.NoError(t, err) 47 | 48 | keys, err := repo.FetchByHash(h.String()) 49 | assert.NoError(t, err) 50 | assert.Len(t, keys, 2) 51 | 52 | err = repo.Remove(k) 53 | assert.NoError(t, err) 54 | 55 | keys, err = repo.FetchByHash(h.String()) 56 | assert.NoError(t, err) 57 | assert.Len(t, keys, 1) 58 | } 59 | -------------------------------------------------------------------------------- /internal/key_permissions.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | const ( 23 | // PermFlush Permission to restart/reload the system including flushing/forcing the queues 24 | PermFlush string = "flush" 25 | // PermGenerateInvites Permission to generate invites remotely 26 | PermGenerateInvites string = "invite" 27 | // PermAPIKeys Permission to create api keys 28 | PermAPIKeys string = "apikey" 29 | // PermGetHeaders allows you to fetch header and catalog from messages 30 | PermGetHeaders string = "get-headers" 31 | ) 32 | 33 | // ManagementPermissions is a list of all permissions available for remote management 34 | var ManagementPermissions = []string{ 35 | PermAPIKeys, 36 | PermFlush, 37 | PermGenerateInvites, 38 | } 39 | 40 | // AccountPermissions is a set of permissions for specific accounts 41 | var AccountPermissions = []string{ 42 | PermGetHeaders, 43 | } 44 | -------------------------------------------------------------------------------- /internal/logging_other.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | //go:build !windows 21 | // +build !windows 22 | 23 | package internal 24 | 25 | import ( 26 | "log/syslog" 27 | 28 | "github.com/sirupsen/logrus" 29 | logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" 30 | ) 31 | 32 | func setupSyslogHook(proto, host string) (logrus.Hook, error) { 33 | return logrus_syslog.NewSyslogHook(proto, host, syslog.LOG_DAEMON, "BitMaelum") 34 | } 35 | -------------------------------------------------------------------------------- /internal/logging_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | //go:build windows 21 | // +build windows 22 | 23 | package internal 24 | 25 | import ( 26 | "errors" 27 | 28 | "github.com/sirupsen/logrus" 29 | ) 30 | 31 | var errSyslogNotImplemented = errors.New("syslog not implemented on windows") 32 | 33 | func setupSyslogHook(proto, host string) (logrus.Hook, error) { 34 | return nil, errSyslogNotImplemented 35 | } 36 | -------------------------------------------------------------------------------- /internal/logo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "os" 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestLogo(t *testing.T) { 30 | assert.NotContains(t, GetMonochromeASCIILogo(), "\033[") 31 | 32 | _ = os.Setenv("COLORTERM", "truecolor") 33 | assert.Contains(t, GetASCIILogo(), "\033[38;5;209m") 34 | 35 | _ = os.Setenv("COLORTERM", "d") 36 | _ = os.Setenv("TERM", "xterm") 37 | assert.Contains(t, GetASCIILogo(), "\033[32m") 38 | 39 | _ = os.Unsetenv("COLORTERM") 40 | _ = os.Unsetenv("TERM") 41 | _ = os.Unsetenv("WSL_DISTRO_NAME") 42 | assert.NotContains(t, GetASCIILogo(), "\033[") 43 | } 44 | -------------------------------------------------------------------------------- /internal/message/account.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package message 21 | 22 | // Flags represents the .flags.json file which holds all current flags for the given mailbox/message 23 | type Flags struct { 24 | Flags []string `json:"flags"` 25 | } 26 | 27 | // List is a message list 28 | type List struct { 29 | ID string `json:"id"` 30 | Dt string `json:"datetime"` 31 | Flags []string `json:"flags"` 32 | } 33 | -------------------------------------------------------------------------------- /internal/message/checksum_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package message 21 | 22 | import ( 23 | "bytes" 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestChecksum(t *testing.T) { 30 | r := bytes.NewBufferString("foobar") 31 | c, err := CalculateChecksums(r) 32 | assert.NoError(t, err) 33 | 34 | assert.Equal(t, "a06e327ea7388c18e4740e350ed4e60f2e04fc41", c["ripemd160"]) 35 | assert.Equal(t, "c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2", c["sha256"]) 36 | } 37 | -------------------------------------------------------------------------------- /internal/message/compose_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package message 21 | 22 | import ( 23 | "testing" 24 | 25 | testing2 "github.com/bitmaelum/bitmaelum-suite/internal/testing" 26 | "github.com/bitmaelum/bitmaelum-suite/pkg/address" 27 | "github.com/stretchr/testify/assert" 28 | ) 29 | 30 | func TestCompose(t *testing.T) { 31 | privKey, _, _ := testing2.ReadTestKey("../../testdata/key-ed25519-1.json") 32 | _, pubKey, _ := testing2.ReadTestKey("../../testdata/key-ed25519-2.json") 33 | 34 | sender, _ := address.NewAddress("from!") 35 | recipient, _ := address.NewAddress("too!") 36 | 37 | // Setup addressing 38 | addressing := NewAddressing(SignedByTypeOrigin) 39 | addressing.AddSender(sender, nil, "", *privKey, "12345678") 40 | addressing.AddRecipient(recipient, nil, pubKey) 41 | 42 | env, err := Compose(addressing, "foobar", []string{"default,foobar"}, nil) 43 | assert.NoError(t, err) 44 | assert.Equal(t, "4f16cf359aeca741b5516b2c8609919e9f0008b66beb97209fbc694d7f272e08", env.Header.From.Addr.String()) 45 | assert.Len(t, env.BlockReaders, 1) 46 | assert.Len(t, env.AttachmentReaders, 0) 47 | } 48 | -------------------------------------------------------------------------------- /internal/message/compress.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package message 21 | 22 | import ( 23 | "compress/zlib" 24 | "io" 25 | ) 26 | 27 | // ZlibCompress compresses a stream through zlib compression 28 | func ZlibCompress(r io.Reader) io.Reader { 29 | zpr, zpw := io.Pipe() 30 | 31 | writer, err := zlib.NewWriterLevel(zpw, zlib.BestCompression) 32 | if err != nil { 33 | return nil 34 | } 35 | 36 | go func() { 37 | _, err := io.Copy(writer, r) 38 | _ = writer.Close() 39 | 40 | if err != nil { 41 | _ = zpw.CloseWithError(err) 42 | } else { 43 | _ = zpw.Close() 44 | } 45 | }() 46 | 47 | return zpr 48 | } 49 | 50 | // ZlibDecompress will return a reader that automatically decompresses the stream 51 | func ZlibDecompress(r io.Reader) (io.Reader, error) { 52 | return zlib.NewReader(r) 53 | } 54 | -------------------------------------------------------------------------------- /internal/organisation/organisation.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package organisation 21 | 22 | import ( 23 | "github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto" 24 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 25 | ) 26 | 27 | // Organisation is a structure that defines an organisation 28 | type Organisation struct { 29 | Hash hash.Hash `json:"hash"` 30 | FullName string `json:"name"` 31 | PublicKey bmcrypto.PubKey `json:"public_key"` 32 | Validation []ValidationType `json:"validations"` 33 | } 34 | -------------------------------------------------------------------------------- /internal/parser.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/jessevdk/go-flags" 27 | ) 28 | 29 | // ParseOptions will parse the commandline options given by opts. It will exit when issues arise or help is wanted 30 | func ParseOptions(opts interface{}) { 31 | parser := flags.NewParser(opts, flags.IgnoreUnknown) 32 | _, err := parser.Parse() 33 | 34 | if err != nil { 35 | flagsError, _ := err.(*flags.Error) 36 | if flagsError.Type == flags.ErrHelp { 37 | os.Exit(1) 38 | } 39 | 40 | fmt.Println() 41 | parser.WriteHelp(os.Stdout) 42 | fmt.Println() 43 | os.Exit(1) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /internal/reload.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import "github.com/sirupsen/logrus" 23 | 24 | // Reload will reload any configuration changes without restarting the server 25 | func Reload() { 26 | logrus.Info("Reloading configurations (not implemented)") 27 | } 28 | -------------------------------------------------------------------------------- /internal/reload_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "testing" 24 | ) 25 | 26 | func TestReload(t *testing.T) { 27 | Reload() 28 | } 29 | -------------------------------------------------------------------------------- /internal/resolver/chain_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package resolver 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestChainRepository(t *testing.T) { 29 | r := NewChainRepository() 30 | 31 | m, err := NewMockRepository() 32 | assert.NoError(t, err) 33 | err = r.(*ChainRepository).Add(m) 34 | assert.NoError(t, err) 35 | 36 | testRepoAddress(t, r) 37 | testRepoRouting(t, r) 38 | testRepoOrganisation(t, r) 39 | } 40 | -------------------------------------------------------------------------------- /internal/resolver/sqlite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package resolver 21 | 22 | import ( 23 | "testing" 24 | 25 | _ "github.com/mattn/go-sqlite3" // SQLite driver 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestSqLiteAddress(t *testing.T) { 30 | r, err := NewSqliteRepository(":memory:") 31 | assert.NoError(t, err) 32 | 33 | testRepoAddress(t, r) 34 | } 35 | 36 | func TestSqLiteRouting(t *testing.T) { 37 | r, err := NewSqliteRepository(":memory:") 38 | assert.NoError(t, err) 39 | 40 | testRepoRouting(t, r) 41 | } 42 | 43 | func TestSqLiteOrganisation(t *testing.T) { 44 | r, err := NewSqliteRepository(":memory:") 45 | assert.NoError(t, err) 46 | 47 | testRepoOrganisation(t, r) 48 | } 49 | -------------------------------------------------------------------------------- /internal/routing.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto" 24 | "github.com/bitmaelum/bitmaelum-suite/pkg/proofofwork" 25 | ) 26 | 27 | // RoutingInfo represents a routing configuration for a server 28 | type RoutingInfo struct { 29 | RoutingID string `json:"routing_id"` // ID 30 | PrivKey bmcrypto.PrivKey `json:"priv_key"` // PEM encoded private key 31 | PubKey bmcrypto.PubKey `json:"pub_key"` // PEM encoded public key 32 | Pow *proofofwork.ProofOfWork `json:"pow,omitempty"` // Proof of work 33 | Route string `json:"route"` // Route to server 34 | } 35 | -------------------------------------------------------------------------------- /internal/subscription/redis.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package subscription 21 | 22 | import ( 23 | "context" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/internal" 26 | "github.com/go-redis/redis/v7" 27 | ) 28 | 29 | type redisRepo struct { 30 | client internal.RedisResultWrapper 31 | context context.Context 32 | } 33 | 34 | // NewRedisRepository initializes a new repository 35 | func NewRedisRepository(opts *redis.Options) Repository { 36 | c := redis.NewClient(opts) 37 | 38 | return &redisRepo{ 39 | client: &internal.RedisBridge{Client: *c}, 40 | context: c.Context(), 41 | } 42 | } 43 | 44 | func (r redisRepo) Has(sub *Subscription) bool { 45 | i, err := r.client.Exists(r.context, createKey(sub)) 46 | 47 | return err == nil && i > 0 48 | } 49 | 50 | func (r redisRepo) Store(sub *Subscription) error { 51 | _, err := r.client.Set(r.context, createKey(sub), sub, 0) 52 | 53 | return err 54 | } 55 | 56 | func (r redisRepo) Remove(sub *Subscription) error { 57 | _, err := r.client.Del(r.context, createKey(sub)) 58 | 59 | return err 60 | } 61 | -------------------------------------------------------------------------------- /internal/subscription/subscription_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package subscription 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestSubscription(t *testing.T) { 30 | from := hash.New("foo!") 31 | to := hash.New("bar!") 32 | sub := New(from, to, "foobar") 33 | 34 | assert.Equal(t, from, sub.From) 35 | assert.Equal(t, to, sub.To) 36 | assert.Equal(t, "foobar", sub.SubscriptionID) 37 | } 38 | 39 | func TestCreateKey(t *testing.T) { 40 | from := hash.New("foo!") 41 | to := hash.New("bar!") 42 | sub := New(from, to, "foobar") 43 | 44 | assert.Equal(t, "sub-a6ca63d14d1c6c31ab71f60e7cd453aeac441e78372cddaa19667c05e45761e8", createKey(&sub)) 45 | } 46 | -------------------------------------------------------------------------------- /internal/ticket/bolt_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package ticket 21 | 22 | import ( 23 | "os" 24 | "testing" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 27 | "github.com/stretchr/testify/assert" 28 | ) 29 | 30 | func TestBoltStorage(t *testing.T) { 31 | path := os.TempDir() 32 | b := NewBoltRepository(path) 33 | assert.NotNil(t, b) 34 | 35 | from := hash.New("foo!") 36 | to := hash.New("bar!") 37 | tckt := New(from, to, "foobar") 38 | 39 | err := b.Store(tckt) 40 | assert.Nil(t, err) 41 | 42 | tckt2, err := b.Fetch(tckt.ID) 43 | assert.Nil(t, err) 44 | assert.Equal(t, tckt2, tckt) 45 | 46 | b.Remove(tckt.ID) 47 | 48 | _, err = b.Fetch(tckt.ID) 49 | assert.NotNil(t, err) 50 | } 51 | -------------------------------------------------------------------------------- /internal/time.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import "time" 23 | 24 | var timeNow = time.Now 25 | 26 | // SetMockTime will set the mocked time. Use in tests only 27 | func SetMockTime(t func() time.Time) { 28 | timeNow = t 29 | } 30 | 31 | // TimeNow returns the current time in UTC zone WITHOUT nanoseconds. This is useful when marshalling times to JSON 32 | func TimeNow() time.Time { 33 | ct := timeNow().Unix() 34 | return time.Unix(ct, 0).UTC() 35 | } 36 | -------------------------------------------------------------------------------- /internal/time_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "testing" 24 | "time" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestSetMockTime(t *testing.T) { 30 | mockTimeNow := func() time.Time { 31 | return time.Date(2010, 01, 01, 12, 34, 56, 0, time.UTC) 32 | } 33 | 34 | SetMockTime(mockTimeNow) 35 | 36 | assert.Equal(t, "2010-01-01 12:34:56 +0000 UTC", TimeNow().String()) 37 | } 38 | 39 | func TestTimeNow(t *testing.T) { 40 | timeNow = func() time.Time { 41 | return time.Date(2010, 01, 01, 12, 34, 56, 0, time.UTC) 42 | } 43 | 44 | assert.Equal(t, "2010-01-01 12:34:56 +0000 UTC", TimeNow().String()) 45 | } 46 | -------------------------------------------------------------------------------- /internal/vault/organisation_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package vault 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestVaultAddOrganisation(t *testing.T) { 30 | v := New() 31 | assert.Len(t, v.Store.Organisations, 0) 32 | 33 | org := OrganisationInfo{ 34 | Addr: "example", 35 | FullName: "Example Org", 36 | } 37 | v.AddOrganisation(org) 38 | assert.Len(t, v.Store.Organisations, 1) 39 | assert.Equal(t, "example", v.Store.Organisations[0].Addr) 40 | 41 | a := hash.New("example") 42 | assert.True(t, v.HasOrganisation(a)) 43 | 44 | a = hash.New("notexist") 45 | assert.False(t, v.HasOrganisation(a)) 46 | 47 | a = hash.New("example") 48 | o, err := v.GetOrganisationInfo(a) 49 | assert.NoError(t, err) 50 | assert.Equal(t, "example", o.Addr) 51 | 52 | a = hash.New("notexist") 53 | o, err = v.GetOrganisationInfo(a) 54 | assert.Error(t, err) 55 | assert.Nil(t, o) 56 | } 57 | -------------------------------------------------------------------------------- /internal/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "bytes" 24 | "fmt" 25 | "io" 26 | "strings" 27 | 28 | "github.com/coreos/go-semver/semver" 29 | ) 30 | 31 | var ( 32 | // BuildDate as filled in during compilation 33 | BuildDate string 34 | // GitCommit sha as filled in during compilation 35 | GitCommit string 36 | // VersionTag is the v0.0.0 version to use 37 | VersionTag = "0.0.0" 38 | ) 39 | 40 | // Version is a structure with the current version of the software 41 | var Version = semver.New(strings.Replace(VersionTag, "v", "", 1)) 42 | 43 | // WriteVersionInfo writes a string with all version information 44 | func WriteVersionInfo(name string, w io.Writer) { 45 | s := fmt.Sprintf("%s version %d.%d.%d\nBuilt: %s\nCommit: %s", name, Version.Major, Version.Minor, Version.Patch, BuildDate, GitCommit) 46 | _, _ = w.Write([]byte(s)) 47 | } 48 | 49 | // VersionString returns a string with all version information 50 | func VersionString(name string) string { 51 | var b bytes.Buffer 52 | WriteVersionInfo(name, &b) 53 | 54 | return strings.Replace(b.String(), "\n", " * ", -1) 55 | } 56 | -------------------------------------------------------------------------------- /internal/version_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "bytes" 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestVersion(t *testing.T) { 30 | buf := new(bytes.Buffer) 31 | WriteVersionInfo("foobar", buf) 32 | s := buf.String() 33 | 34 | assert.Contains(t, s, "foobar version") 35 | } 36 | 37 | func TestVersionString(t *testing.T) { 38 | assert.Equal(t, "foo version 0.0.0 * Built: * Commit: ", VersionString("foo")) 39 | } 40 | -------------------------------------------------------------------------------- /internal/webhook/mock.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package webhook 21 | 22 | import ( 23 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 24 | ) 25 | 26 | type mockRepo struct { 27 | Webhooks map[string]Type 28 | } 29 | 30 | // FetchByHash will retrieve all keys for the given account 31 | func (r mockRepo) FetchByHash(h hash.Hash) ([]Type, error) { 32 | var webhooks []Type 33 | 34 | for _, w := range r.Webhooks { 35 | if w.Account.String() == h.String() { 36 | webhooks = append(webhooks, w) 37 | } 38 | } 39 | 40 | return webhooks, nil 41 | } 42 | 43 | // Fetch a key from the repository, or err 44 | func (r mockRepo) Fetch(ID string) (*Type, error) { 45 | w, ok := r.Webhooks[ID] 46 | if !ok { 47 | return nil, errWebhookNotFound 48 | } 49 | 50 | return &w, nil 51 | } 52 | 53 | // Store the given key in the repository 54 | func (r mockRepo) Store(w Type) error { 55 | r.Webhooks[w.ID] = w 56 | return nil 57 | } 58 | 59 | // Remove the given key from the repository 60 | func (r mockRepo) Remove(w Type) error { 61 | delete(r.Webhooks, w.ID) 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /internal/webhook/webhook_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package webhook 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/bitmaelum/bitmaelum-suite/pkg/hash" 26 | "github.com/google/uuid" 27 | "github.com/stretchr/testify/assert" 28 | ) 29 | 30 | func TestWebhook(t *testing.T) { 31 | cfg := ConfigHTTP{ 32 | URL: "https://foo.bar/test", 33 | } 34 | 35 | a, err := NewWebhook(hash.New("example!"), EventLocalDelivery, TypeHTTP, cfg) 36 | assert.NoError(t, err) 37 | 38 | u, err := uuid.Parse(a.ID) 39 | assert.NoError(t, err) 40 | assert.Equal(t, "VERSION_4", u.Version().String()) 41 | assert.Equal(t, "2e4551de804e27aacf20f9df5be3e8cd384ed64488b21ab079fb58e8c90068ab", a.Account.String()) 42 | assert.Equal(t, TypeHTTP, a.Type) 43 | assert.Equal(t, "{\"URL\":\"https://foo.bar/test\"}", string(a.Config)) 44 | assert.False(t, a.Enabled) 45 | assert.Equal(t, EventLocalDelivery, a.Event) 46 | } 47 | -------------------------------------------------------------------------------- /internal/wordwrap.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import "strings" 23 | 24 | // WordWrap wraps sentences to a maximum length of limit. 25 | func WordWrap(s string, limit int) string { 26 | if strings.TrimSpace(s) == "" { 27 | return s 28 | } 29 | 30 | words := strings.Fields(strings.ToUpper(s)) 31 | 32 | var result, line string 33 | for len(words) > 0 { 34 | if len(line)+len(words[0]) > limit { 35 | result += strings.TrimSpace(line) + "\n" 36 | line = "" 37 | } 38 | 39 | line = line + words[0] + " " 40 | words = words[1:] 41 | } 42 | if line != "" { 43 | result += strings.TrimSpace(line) 44 | } 45 | 46 | return result 47 | } 48 | -------------------------------------------------------------------------------- /internal/wordwrap_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package internal 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestWordWrap(t *testing.T) { 29 | s := "NEWS PLAY ELSE CABLE UNLOCK SUSPECT TOAST MIXTURE SCARE POTTERY MONTH ESSAY IMMUNE BURGER STING RATE PLANET TOWN" 30 | 31 | assert.Equal(t, "", WordWrap("", 40)) 32 | assert.Equal(t, "NEWS PLAY ELSE CABLE UNLOCK SUSPECT\nTOAST MIXTURE SCARE POTTERY MONTH ESSAY\nIMMUNE BURGER STING RATE PLANET TOWN", WordWrap(s, 40)) 33 | assert.Equal(t, "NEWS PLAY ELSE CABLE UNLOCK SUSPECT TOAST MIXTURE SCARE\nPOTTERY MONTH ESSAY IMMUNE BURGER STING RATE PLANET TOWN", WordWrap(s, 60)) 34 | assert.Equal(t, "NEWS PLAY\nELSE CABLE\nUNLOCK\nSUSPECT\nTOAST\nMIXTURE\nSCARE\nPOTTERY\nMONTH\nESSAY\nIMMUNE\nBURGER\nSTING RATE\nPLANET\nTOWN", WordWrap(s, 10)) 35 | assert.Equal(t, "\nNEWS\nPLAY\nELSE\nCABLE\nUNLOCK\nSUSPECT\nTOAST\nMIXTURE\nSCARE\nPOTTERY\nMONTH\nESSAY\nIMMUNE\nBURGER\nSTING\nRATE\nPLANET\nTOWN", WordWrap(s, 3)) 36 | } 37 | -------------------------------------------------------------------------------- /internal/work/repository.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package work 21 | 22 | // Repository is the main interface for work types 23 | type Repository interface { 24 | GetName() string 25 | GetWorkOutput() map[string]interface{} 26 | GetWorkProofOutput() map[string]interface{} 27 | ValidateWork(data []byte) bool 28 | Work() 29 | } 30 | 31 | // GetPreferredWork will fetch work by taken the preference into account 32 | func GetPreferredWork(preferences []string) (Repository, error) { 33 | // The preference list is just that: the preference of the client. The server ultimately decides what kind of 34 | // work needs to be done. 35 | 36 | // Currently, only POW is supported 37 | return NewPow() 38 | } 39 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmaelum/bitmaelum-suite/95952d193fb9f2f4be9160453eb4c11954b629bf/logo.png -------------------------------------------------------------------------------- /pkg/bmcrypto/jwt_ed25519_sign_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package bmcrypto 21 | 22 | import ( 23 | "crypto/ed25519" 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestSigningMethodEdDSAAlg(t *testing.T) { 30 | m := &SigningMethodEdDSA{} 31 | assert.Equal(t, "EdDSA", m.Alg()) 32 | } 33 | 34 | func TestSigningMethodEdDSASign(t *testing.T) { 35 | m := &SigningMethodEdDSA{} 36 | 37 | privKey, _ := PrivateKeyFromString("ed25519 MC4CAQAwBQYDK2VwBCIEILq+V/CUlMdbmoQC1odEgOEmtMBQu0UpIICxJbQM1vhd") 38 | pubKey, _ := PublicKeyFromString("ed25519 MCowBQYDK2VwAyEARdZSwluYtMWTGI6Rvl0Bhu40RBDn6D88wyzFL1IR3DU=") 39 | 40 | s, err := m.Sign("foobar", privKey.K.(ed25519.PrivateKey)) 41 | assert.NoError(t, err) 42 | 43 | err = m.Verify("foobar", s, pubKey.K.(ed25519.PublicKey)) 44 | assert.NoError(t, err) 45 | 46 | err = m.Verify("foobarfoofofoo", s, pubKey.K.(ed25519.PublicKey)) 47 | assert.Error(t, err) 48 | } 49 | -------------------------------------------------------------------------------- /pkg/bmcrypto/key_rsa_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package bmcrypto 21 | 22 | import ( 23 | "io/ioutil" 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestString(t *testing.T) { 30 | k := NewRsaKey(2048) 31 | assert.Equal(t, "rsa", k.String()) 32 | 33 | k = NewRsaKey(4096) 34 | assert.Equal(t, "rsa4096", k.String()) 35 | 36 | k = NewRsaKey(2048) 37 | assert.Equal(t, "RS256", k.JWTSignMethod().Alg()) 38 | 39 | data, err := ioutil.ReadFile("../../testdata/privkey.rsa") 40 | assert.NoError(t, err) 41 | privKey, err := PrivateKeyFromString(string(data)) 42 | assert.NoError(t, err) 43 | data, err = ioutil.ReadFile("../../testdata/pubkey.rsa") 44 | assert.NoError(t, err) 45 | pubKey, err := PublicKeyFromString(string(data)) 46 | assert.NoError(t, err) 47 | 48 | b, err := k.KeyExchange(*privKey, *pubKey) 49 | assert.Error(t, err) 50 | assert.Nil(t, b) 51 | 52 | b, tx, err := k.DualKeyExchange(*pubKey) 53 | assert.Error(t, err) 54 | assert.Nil(t, b) 55 | assert.Nil(t, tx) 56 | 57 | } 58 | -------------------------------------------------------------------------------- /testdata/attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmaelum/bitmaelum-suite/95952d193fb9f2f4be9160453eb4c11954b629bf/testdata/attachment.png -------------------------------------------------------------------------------- /testdata/header-001.json: -------------------------------------------------------------------------------- 1 | { 2 | "from": { 3 | "address": "000000000000000000018f66a0f3591a883f2b9cc3e95a497e7cf9da1071b4cc" 4 | }, 5 | "to": { 6 | "address": "000000000000000000000000000097026f0daeaec1aeb8351b096637679cf350" 7 | }, 8 | "catalog": { 9 | "size": 983, 10 | "checksum": { 11 | "ripemd160": "cc83e77af0fae70c3b655f36f110ec4d2eebaf1c", 12 | "sha256": "79213f8941437dc22a315636a50d6920507a58fcf97b9ff32b4c15cd26a8209a" 13 | }, 14 | "txid": "", 15 | "encrypted_key": "Zm9vYmFy" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/header-002.json: -------------------------------------------------------------------------------- 1 | { 2 | "from": { 3 | "address": "111100000000000000018f66a0f3591a883f2b9cc3e95a497e7cf9da1071b4cc" 4 | }, 5 | "to": { 6 | "address": "111100000000000000000000000097026f0daeaec1aeb8351b096637679cf350" 7 | }, 8 | "catalog": { 9 | "size": 983, 10 | "checksum": { 11 | "ripemd160": "cc83e77af0fae70c3b655f36f110ec4d2eebaf1c", 12 | "sha256": "79213f8941437dc22a315636a50d6920507a58fcf97b9ff32b4c15cd26a8209a" 13 | }, 14 | "txid": "", 15 | "encrypted_key": "Zm9vYmFy" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/header-003.json: -------------------------------------------------------------------------------- 1 | { 2 | "from": { 3 | "address": "000000000000000000018f66a0f3591a883f2b9cc3e95a497e7cf9da1071b4cc", 4 | "signed_by": "authorized" 5 | }, 6 | "to": { 7 | "address": "000000000000000000000000000097026f0daeaec1aeb8351b096637679cf350" 8 | }, 9 | "catalog": { 10 | "size": 983, 11 | "checksum": { 12 | "ripemd160": "cc83e77af0fae70c3b655f36f110ec4d2eebaf1c", 13 | "sha256": "79213f8941437dc22a315636a50d6920507a58fcf97b9ff32b4c15cd26a8209a" 14 | }, 15 | "txid": "", 16 | "encrypted_key": "Zm9vYmFy" 17 | }, 18 | "authorized_by": { 19 | "signature": "V/cdCpxF6Ktv7hDvvDzJm9okoJMo8ikx1lnaWyFNbkKGAWADQVexdMLtP2OeqMa8f9EVqWFimb3uznzeJ9EfHKvjg33vzfOfsYRmsRVtMyDyypb9ilFCzI2px3IevsWut8TQ78aQ7eNTUe++LCGQgKOyAwNuUR9ctQqh88KlCS2udFw0FF9P94xZrAaxiA0LSDigAyMzANQGG55BxKg+PSdPZDBh+zNLBfG2fTS4zKa4hzhycE4pVexQPqmsBgnHws9YQqQTouxDovym/7FRRAc8bqxzrWS0F0OCZcj0twS8qXSFwof/FGJTKrE1Kr4nNXNdqxHnFonWaWRwOv/uUA==", 20 | "public_key": "ed25519 MCowBQYDK2VwAyEA4KhfZWs/+B9Xx6eU+zN+A1USGtXsCs5zJNRq8JOM9EA=" 21 | }, 22 | "signatures": { 23 | "client": "hviVRC4zb+RK7f1iHc8Cu/acH1QyI4uIrjqm4OukfGb/z3zFSvLS2G0bDmkBt1kPiSZYTgR33zZRC/kIV1YGAw==", 24 | "server": "yjBaPd8nWoz6wCJx8kmh7jeU0QcoT9C2oA8Qsh9cq1PRNeE0PLIpDjI4jb3ftP+3PdCRF5TWNOzk8OYbwJkpAg==" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/header-004.json: -------------------------------------------------------------------------------- 1 | { 2 | "from": { 3 | "address": "000000000000000000018f66a0f3591a883f2b9cc3e95a497e7cf9da1071b4cc", 4 | "signed_by": "authorized" 5 | }, 6 | "to": { 7 | "address": "000000000000000000000000000097026f0daeaec1aeb8351b096637679cf350" 8 | }, 9 | "catalog": { 10 | "size": 983, 11 | "checksum": { 12 | "ripemd160": "cc83e77af0fae70c3b655f36f110ec4d2eebaf1c", 13 | "sha256": "79213f8941437dc22a315636a50d6920507a58fcf97b9ff32b4c15cd26a8209a" 14 | }, 15 | "txid": "", 16 | "encrypted_key": "Zm9vYmFy" 17 | }, 18 | "signatures": { 19 | "client": "Se4sVKA8DkVfwcIJ3HIqVIds6+ewQC86pwUWX10K4fS8860AhlWJd75XnL4AFs9ofSIwEgVr7D+OvY2eyh8ECw==", 20 | "server": "yjBaPd8nWoz6wCJx8kmh7jeU0QcoT9C2oA8Qsh9cq1PRNeE0PLIpDjI4jb3ftP+3PdCRF5TWNOzk8OYbwJkpAg==" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/key-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDTi87QrrSXLiILJ8/o8t48rS4XwtizoYbIfjV2K16ps9EmrNJvaQKW4MX5k6yBEocQTlxWq5YlYBM8V2NC8+W5TKzGT+MQuANZPiUNuZM/b3EgYFAciVAiudhqgEdT5vgt6BzKkymux3D0SJX1blH8X9tMyQnJoIPiT1xnML5P4gSG6SG9sSHNgrHrZwLjUr0yon9YGoDrCnYfvEn90ko+MK6k1tdf2XdBuPSvbRnjc3l5/uKaN+0SHaTCJA2e96qHq+mdiXUHcBkL5HxnAuKE/9BoEOWH6di7L8ndJF8zrIVhmflhB0cqZSPTwdYZXGdK4VkV4pMfDahDmYv6XKLpAgMBAAECggEAR57Ryj0bzwNDa1tzPH7dVtWbAVhqXYaWR1LTbsqIJhRG/z0LkcSPp905qaGhiaFoMNEW2hEFqGm6mXdMl+JTKEUZSZrKWWKzX4d2rArkG1nzhu6UsNScWOVqq8P6YiGUbJZlCQCB4DaNu2bHvmw3PaaGbJyzv5ukiv4rXpRWGlzhb3Iw//FGmbDAbQPnYrGLNXv0WDFlhME1gIZvOSytg6QDeCN3xYIJcmTJDCRuPemRN/MqCMSQ3qhqYLlqB+8vH902ozGeX8eO5ZiBJqc6oEjlKKwU45ER52QsXVmjsNCxf7L3IgN5CXNeuh/LKmFrOFWxjXHfOXqF7gwM91t2cQKBgQDp5YjADjGm88UyUicTYu9Ta2o2gxfMiyPb73IhfPJ/ijqlUSCUN9Ji/6Vyrd5/OjqLENWKUsjrMMFFhqOmLem27yuRNAGUQeoO4fibf2oNSNMxvsEFfwlVJAq4ixPJDNyOne2vWEwb9u7w4YK+ssr3cOZL+mG2xk/5XcK36g5S3wKBgQDniZEcqkGzTiQFjgf+7qHtCwaDNiNzvQCPL0ZsQfiur4NQrL/osGIZ4jHV5eU/k/LuHcrZx5x+UAQqVISScFkkew2VvgfKaxdie8zhJSh8ic5RBGZg/B3gw5xHWIyJSxUp8PztuH2Raj0ECh+lzDtwYpPKGyQLDxwdeB1/Pq7LNwKBgG+juHb7D2YBuqD/J1mQgm0Nux+TyNs/mnkSvCYRzmlj4AQiSeuVDV1lamHnbWjKsUDJYzNnujDQD6AQ2LGr/n7rf58J9KsAHyjFYPVPhp4aoXt/8f+emCTEVD2rXGE9O1TzOozUF1fNsFTXPqGpE0mx4KppMxSbaXa78wH3vKh/AoGBAJf4645tEgKm323l88mYyB/WhMfK2So2fA9/cDHOe3PtL7vcJ3qLi1iB50QGSZqZeXJhi6u2ITmnO5StNPcJVvli61/GA0cRU6AIskl1IkXcDdePk8NEuDe3LPSHYncbGSEWVG2UEpdHrBTisDMbAkiZ63dUqSu5FzMgi/vhIMmxAoGBAOHgQ7xMwPOw7mpczSdT8gUqNwGFWKIVMo0YJFW20WntJgr/aFY70XoW4ENIHJyZFEl2GSuHiI6S8d2yLJdbSmjlj06wgwCsEk2Bc8e81BSVHisH8e2kSApyjMOxjgfUZoWcEHrWJeIcZykowiPrF39HDMbOtwv94n96+v90T4Nq", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA04vO0K60ly4iCyfP6PLePK0uF8LYs6GGyH41diteqbPRJqzSb2kCluDF+ZOsgRKHEE5cVquWJWATPFdjQvPluUysxk/jELgDWT4lDbmTP29xIGBQHIlQIrnYaoBHU+b4LegcypMprsdw9EiV9W5R/F/bTMkJyaCD4k9cZzC+T+IEhukhvbEhzYKx62cC41K9MqJ/WBqA6wp2H7xJ/dJKPjCupNbXX9l3Qbj0r20Z43N5ef7imjftEh2kwiQNnveqh6vpnYl1B3AZC+R8ZwLihP/QaBDlh+nYuy/J3SRfM6yFYZn5YQdHKmUj08HWGVxnSuFZFeKTHw2oQ5mL+lyi6QIDAQAB" 4 | } 5 | 6 | -------------------------------------------------------------------------------- /testdata/key-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDCP51HJbnk1e4E8X39g4E/xVcvdA1h6wYHIS4qJkw4mRKcyD3YV8oAXsR+UY+ncZEQXbsMYIm6tgOoEcW4HEWQneBRUPoB5BOVUaC8nsw6HKGky4ggKpLDZYln4/c8zx3x+odqabCDSmWwsXJm+uEVJs3pP8dhNpl97SM7iIjGpHlLCFNjQk4pQuYNWNW7kGBf2PM0D6eSvc5DcdS7GDCY4zAImTP1ASG/z99E5k0dHvGMMn2IJRKzCo8iWmEkQfaF1X9RVXFftuLfrLN7UiWJH1Wk7JL9WaUQT0zeTWZDqv+8icYd1YGuYDyuLkn4S2FrBYDd23ASC736JUKqtVWTAgMBAAECggEACgt6GZzE0SWS6mSGjF6Jh3+v838/1eluZV384ica1+5qfPsJ368ifgRoitOy5wjDZKJEMu6nEKWq6L0KiWvE2Sag2/OhCgn+TUFsW3SmwPaMEVaJEojBECOnCF1MgrN/K+01pXYTr6ZgPdPfQ54Dl7FrAn3O1KMbKtzhbomv8P2nNnSkwiqxTGvBj5a/nKmjnI6XGLYuocqVpHaOF7VaowF+Go18RbNA+eYty5zh7uebs0KyzCUyGebSlmg3G8IscNTMgRahv2R3jaCEvXqMuyd/9Tl+5DRjVdeQnbp3s8mPIRLt9eqNHYp+OYcqA7fz8zftdFDJoaobRKfwOOnkuQKBgQDy0IORnj7KX2Ru9c9Ts8e6DQTZlrn0o/sle+/sgF5TEoZvWV2cbeG6mbrCgJgj48b+VlHoK4sSRdMRrbqSRgkgYlkLHApDNyKJbJUH644IZEMKYNlTeT9/fcx6yrvpJZBNRwMCPeYrm6AvZisl+PUVt+VGTGAPuoz+muWmNZP7pQKBgQDMy/W/EISmhxa+JcphXeDzz62tWFjYejAoSOPWrz+K28leZ83sV/JoCy3WJ2+orGxgEkS+PWeZTyh/GZ2Aw2JxcgcxXXhKB8eRkU1tBBLPIpOxajAYVYyfUrBCm04AFQUZch9tBGGfpApS7RwtrNn7/l8Z/inf0Q5tR5beCUCm1wKBgQCzSO68qIFoX8MCgxFQlmAUqeQ43Sf00Ndxt+9RSv9ai0UkFnIePKv9YeEaGGU9qsOVrBrSOMR4+4F7fjFSK9A1Tyi8IToaoy0nFzt7G5xF6fHuSdBt6ArQkgxXZjYVUh0YUiSQlS/MZx6BoQifAxHDtYLewynysyXEII8MiGb52QKBgAT7KPz+r9tFCd6SGLwJhoEnmffPYEnTnvw72Z7NIGSGN/2d1Lpc4T56lyDQULzvhKtJhnaCE9T8weVlgBkzp19PALHIrjZOviHiQNnX8YUsOB9mj8jnu8XcQwE7ucfyuu8FgZIrOxyg5sdhkP/jZmHkq/d74RTahtlNlnPMEdB9AoGAGrhoV20eXYlJtmM0ulDOR24vdli/GEuGS73UlJun9WmwaFtvS0cE8dph/X46F2xqPshWXiIVcDUEt3Or8e4s21O+sy3BvJM/5wZl9U4iCN1H8zPYilOB+G1YuwNW4Gb6Sqb21WmIbtmsbN+japqnmoBDnIAKDRLi4Hsh/TMH+Og=", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwj+dRyW55NXuBPF9/YOBP8VXL3QNYesGByEuKiZMOJkSnMg92FfKAF7EflGPp3GREF27DGCJurYDqBHFuBxFkJ3gUVD6AeQTlVGgvJ7MOhyhpMuIICqSw2WJZ+P3PM8d8fqHammwg0plsLFyZvrhFSbN6T/HYTaZfe0jO4iIxqR5SwhTY0JOKULmDVjVu5BgX9jzNA+nkr3OQ3HUuxgwmOMwCJkz9QEhv8/fROZNHR7xjDJ9iCUSswqPIlphJEH2hdV/UVVxX7bi36yze1IliR9VpOyS/VmlEE9M3k1mQ6r/vInGHdWBrmA8ri5J+EthawWA3dtwEgu9+iVCqrVVkwIDAQAB" 4 | } 5 | 6 | -------------------------------------------------------------------------------- /testdata/key-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCrM61R5XlfmxgPGD3cPJW0qE4wfhc21bV9vQ3jOkbCSJNIbpRbujdSJJUDl42vtJK88rgwf0P+GwNGhrLQniVoKcSEafouhgJAkfcnEI40osLD4mpqNJlIcxTydG+l6i2QfHRKnSA8viDdli5PSqR4L0s5CmtpWp/V/mTCiYlO2Vj8TMEPOw6F/dza1VXjDC+beV1sEgP5AW97UqntpdowtVD+VhE1JNAzF7lrJAG7XZ0hX2/YNpsfA+GIbFxLjZOBCSzeHioSw7BSlgAegxfC1KmuC6Ze28ZQEvisvJB37XJoAx+Xro7slXNmPbhe5FfLYK9vsm+QJKHo14LKHZH1AgMBAAECggEBAKpKSMgBXW0/s/qvvjhm+vIrxzps8WJVyKU9e6bdvKxbzERr2Z4z5/sI8EAWa5SuJJdVRujWbic/b06jhRIFfGfTw+mCEJxeJ7daeWCeExVAIEL/36GsmBt8fQV90+BQwunJIVNmXz6MT9yZGY89S8NQJ56hQp4Uyo/s7wSiEbYe0tYIQohR8/foQl8OIiboPYrHA9jEHj9fLphPrCd19KgS1P9oY9sv9uZTEMcGSZy1GjpkWiLXC4rHNAdDCYKLLPDYVGWY1Sepuzo2vtLI44yZsM/LEy1JTJWZhHfPC6ufPUN7JIY4zeWrRyOoReJ4NIgIR4+JBRzdeKUN1cgydDECgYEA1dprJ7GRjyiPP9aVNipO5tB35WLf8X8GEssoKPUa6osY+3G2PUfl85Mz1LmQKWwg80HkLj6BK8omUYdGkIH/sCGrWYiocKbBivOstCumYdA+PcCFkZr+6/LuXVDCp/8eUk0aGn0GW2ZOIaWRsKYQHx5bFHQROrSs6S6SxVFjeLsCgYEAzPFci+7SVpgmNE6YruZU3mdddndHwO+l4oabvnD4iINiUZ0Iv0mcmfb8Us0qSCxOdyMEe51hPoCqW5dvBo/eydyq4tieyn64sqL/4ZzH+2+PEIPGcUlFuw+xOHAt25yo81NRStgYY+mVIrnPShxVZUVn8RDVczpeJHIsQVn4DQ8CgYEAzf040CA7fDDuYuh4C5ePLsdJZdvqqDzZhcrIoUMPLTLU2oa6qqaRuiBlgZdIZI3x4z7p4x1z4NE0Pb3W26VMu8SCv5hh3zjRHt3+0gFln7wt59+FCS7KNE5pCdub1KRp+Y6pATDCqdGOmtxXzFb5GnBr/PScD/cuwuGIoKX38bcCgYB+c6pLuRbVUVm5SomQ2ROiipqzftOqKvPqum2cau4epRpkCwWbqZrTsP5tRKQDFjtv7Q5WC3w16YOzsdNSdDDd0qcqAsivXtMtfb9ugKMv89yNLxGhUrmQuxT5ItZYu+fPAyiUipM6CqT3YTiSnLrgGpwQtPdO+sOdr0i5Jf8UZwKBgFUacyCugSk9EXwGVLvs8KAMCfDXJUWTC9K6sNFMsTGNz+epfhVtp4qgXV66yIGMjRxptKcDHsmJe9bso76nyPSieKimpn3oya4Qqh7/3YQjOSFwrs1FQ7XFAsn9uB3UlLOfynbcu2b9cC3e82bNiUYvgHklPAVMo565Mlb4UFC1", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqzOtUeV5X5sYDxg93DyVtKhOMH4XNtW1fb0N4zpGwkiTSG6UW7o3UiSVA5eNr7SSvPK4MH9D/hsDRoay0J4laCnEhGn6LoYCQJH3JxCONKLCw+JqajSZSHMU8nRvpeotkHx0Sp0gPL4g3ZYuT0qkeC9LOQpraVqf1f5kwomJTtlY/EzBDzsOhf3c2tVV4wwvm3ldbBID+QFve1Kp7aXaMLVQ/lYRNSTQMxe5ayQBu12dIV9v2DabHwPhiGxcS42TgQks3h4qEsOwUpYAHoMXwtSprgumXtvGUBL4rLyQd+1yaAMfl66O7JVzZj24XuRXy2Cvb7JvkCSh6NeCyh2R9QIDAQAB" 4 | } 5 | 6 | -------------------------------------------------------------------------------- /testdata/key-4.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCdQjEXQCxheqHqQztnL6+3WhXW4bWDdVlwAoxsDU+yfdEzUTXEgqUZ4GAwbMEf0OaKCX7yuK7f/EMqJIOhHOSFZWNudml8wR+wzmT0+6YZXsJ4B6bt0DQpxjSOSeuI9inHtncac01Geqssd4JOw+Kfnpo80IG/bkPSOX5NkIVyJXVEjbliwq4tO/Y5DJHdg1ycP1WAChBCcoWRpUlC9FOti0GFSwhkg7rNORC+uzucNOuRz783sqK4qVTOl/n4uPYMRBqmxbTlDwaAuVpyr1TX70Vjr8hzChqkUBFe2W0el7ImgCsdKDKljs6FNtuFiXwnSbx8i4dVMZCUXW3vWstfAgMBAAECggEBAJZjgLLtigPG1SVFGn/5mJ9NpWkT/RQ0m02FAmkq6baWoAPle/frwJxYeWSV/LLCglYr8p2IhKRriIe6166yBNCVP1uaHhNSVU4uc1ndduD4QB2to7P10ozIoeYZRwh58UaudoRzE8l88knaGGHe7tEbSgEynYJGntFibikbNqMLM65Gk3WIzFM9TPdBcQkds9ekphztoY5eBA10IX+eDHM8JCJzssRhpwzBkzD7zAP9xmAPz3KRPHTdfT6fw5ub2YHGiEV6eYN0L1KsTjxTQGMbUzS6+Do5ldMTe4b968a535V/DbNe9CsiJet7TjQjPLUvHDUbwk/V+C8JF3g1DsECgYEAygx1R+fzJe9O951u9LzwTaTDEpQQwYNVEXngggzHKT7FT7ps92JyfsWiompaszfZ8H8XT5Sr1gdRwgs1407LLmLSl3ALlVB9Zv2x95mbBA6Y3ABsvPNkky64Gisd6er1quOCuQiXAyzFh0f9LSdl8HOeE0DQUNiWUaIC/6ZNK1ECgYEAxz/+fZo6hHFrCYUM719/zLNNgn8k4WSTsY99BhEhdXyRlQcytheTRFHcJcrgVBwRBeG4cj3EDXVMW0Ct2WnLUUQxh97GFldZg3JqAoWNAVjfYEuN0oeOIdbZ+IPww8bq+oMVWiaeVv6MYV2vWB52NxMlONsruvo3PN4ayDUNf68CgYEAxHmC3o6GWiAwqQb1q5XDE62haAKFnLfKVDkxASXN0aTRmCsP5SxdbDthYBCN7HLmQkBD+cX3pyPs9AWUvFqVp6C/ajWxfdwMZcdTdRNws2xCZsUe+EqyRZGLwx6kcyBhDnE4YBgjSRoTZu6xGmSSc1TqpYxERimnWvBxfApKRlECgYBNeBMxsKp53kM4s1OBKoddBoXnbBnhzKIkEl8Q4c45iNJtuBu+ctIeaRmIVCX+bd8sg0Ocn2k/tlCW1kIB20Fi+nmrkzE/dHzoP676BgT59hz7qsSci3n2rDuZhWsyI4AvIJJHt+YuetAH9036m/VomngJcCXDkA+0CcMt/nqeHwKBgG4OM4t6m7meXYF0QlrEwLzjhc35hxSbAmONqrjKl1Bz0ICl9M3X02/u/Aslfwpu/5AaRjxXwm+33MVnSwEwri2JZ0DE1P8s8rQbO/mp5CjfeRhUurqSq8HUsDLYBiPmS+Q1X9Wf0VJWJ+BOWdenjOf3EJC2C6PnAYf1YO1larj/", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnUIxF0AsYXqh6kM7Zy+vt1oV1uG1g3VZcAKMbA1Psn3RM1E1xIKlGeBgMGzBH9Dmigl+8riu3/xDKiSDoRzkhWVjbnZpfMEfsM5k9PumGV7CeAem7dA0KcY0jknriPYpx7Z3GnNNRnqrLHeCTsPin56aPNCBv25D0jl+TZCFciV1RI25YsKuLTv2OQyR3YNcnD9VgAoQQnKFkaVJQvRTrYtBhUsIZIO6zTkQvrs7nDTrkc+/N7KiuKlUzpf5+Lj2DEQapsW05Q8GgLlacq9U1+9FY6/IcwoapFARXtltHpeyJoArHSgypY7OhTbbhYl8J0m8fIuHVTGQlF1t71rLXwIDAQAB" 4 | } 5 | 6 | -------------------------------------------------------------------------------- /testdata/key-5.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDe1RRdNWlJ379vF29q/XleR75grWxZJkq2W6q424iwX32/U2aCAku/pxUjxbtyrSZXx2b45RlcKWQqS6s8PT7bl/dJJybP23Of1rsRTU/uXw8pG2EsElWDXuECHJAoYkltv7D5v5K+5o5wXm5AzKIQZNp0R2gIaIsMBw56CierHeit4r6asZfA+9VqnTum0Dsk3F7nRjo2xALP76uDfdfJFY2tQdKdeAZJH+zOm9TmivZCDd3tJkM8ZWedRNL7ql7TsIrq4gUS3SSlyQTkeUbkfpbqWYDXwbRfZOez2m34mHWXrx+EmOalE7bl4+KdNVWA5h5nDSBMBd3tx7vkCR6VAgMBAAECggEAKvaygnY14sR9SJIgLWTJ7d+vWTyW02mKpjZuaE4LwNXojOcrsI14xW8VqFwLlETGS85qkDq79QUWBwGn9mlooTZfu38NAK6zUHI6h098xd0WMzrQNYsjabz1bU7MjLzGo55+JOlHBf+2HvxWDbBm3vpTFHBgIp7lkGAb7nPeyiMR8i6k6lKJBm/tslEAIizzBSTsJsiUym+LQP6fp1/A1g+R9je7SKPXo+D54joNz1ZYnDVUi1FkqpzZZvEBJbJOfAXi6txAaafo35rM1IVe5433ZVD/y3A9Zh4Z1uwPjJesvA1GYd3FEtcg28YFTp+4otJGLJ46eIul60ntObmJ0QKBgQDj+jEGk2aLJ3zBw1lzhwKpw1sIByXS17X8beLsWz9xNu15a6o9gOvBefN47sLY4BOJdBFXgJseynPzFd0W8C/BmqQJ/6PH+UAwRK1fX9VpqlxDWVL4gBfmWXMzqtl4k/jeHm2p8rn+iUNeg5v3/++WWUYXgRWZO9thfQDViTOQXwKBgQD6OP2CCZLIBYBKJYyBJsAXYDW0UZC7RA/vhPBzggvUGRO88RY3BL2IzlnMYmbM/q8Esx+ZdHIu0WAnOP4PDevSLLk3uehaUPSq9+1IqXfKfQ3YUl/58wNVy7AQJ63DYRLNIGWiUgJsRQ7ptTSwQPLwx53mV+YKsbah5tpWrlQliwKBgD8KDchttetArgS+SdviN2BN/rwHjfPxZgc5M4h76t0ZfS0YEmkTXx2O5T5Jd2OVApH9oFX73+jxvoI3R31ySSJV6opBQD6ps5AlTXOUAmVHkF+nMYQ5l2JA1dQxqBTpheWVsGlQDxJNTm2yIsy+3rdKVFFnhltq68zXTgW9/J4tAoGASwc5pHtAYu+bVyBJMBSxdpDnqYjnj+9Jo/VFsCznZRKb44Sat6aZOmM9c9ZxorgfPJaFPBs5faZUYY5qR5NSCbRVWUtKS4KIypcKtEX0YGf89cdFdgoTDu/DfCSZqsL5wz4am4Bhr5tJbHRkNxFShzYjt4TVupEtBQDWqTUekB8CgYEA4CJ3oWDdSHam6X2Qsc4i5IvK0PUSwgOACgjTT+j4/9lRQierp/BVIc5/uhfykWPYP8+bVUcDAbcWf0rgLEU8T/O6Rkb6l51MBOOpHpSu/rHRosozOyUHxRwMHTx9UhTUsCTeYHcuQrbFh3qgyu8sOl/FTXRM5SRhqyv+A6J6mRs=", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3tUUXTVpSd+/bxdvav15Xke+YK1sWSZKtluquNuIsF99v1NmggJLv6cVI8W7cq0mV8dm+OUZXClkKkurPD0+25f3SScmz9tzn9a7EU1P7l8PKRthLBJVg17hAhyQKGJJbb+w+b+SvuaOcF5uQMyiEGTadEdoCGiLDAcOegonqx3oreK+mrGXwPvVap07ptA7JNxe50Y6NsQCz++rg33XyRWNrUHSnXgGSR/szpvU5or2Qg3d7SZDPGVnnUTS+6pe07CK6uIFEt0kpckE5HlG5H6W6lmA18G0X2Tns9pt+Jh1l68fhJjmpRO25ePinTVVgOYeZw0gTAXd7ce75AkelQIDAQAB" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-6.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSWUKFcCjlu6GXRF/WQXlSEO6w0HeW6u1VsQHfh7IqLaiOCKcvZZaoTSi3bGQNuRfnk2PUHGCqCNXMrh3HSwsrn/nP+SQRFnfDRyTkRaJ1d53kz9HsXxwv5Bvh15/jkGPmJfPVGZR0BQg13LtBp3HYHw021pFqJOshmbCVFQbYJsbqpzaP9XN3hn3E/J7QLiQCXpEQ+FRyAGPApIROYG3NaBrfbY3CUoiY4qct7uSRwZgzZy+eb58AzMIwK7+Y8+jCOTrFSi2CSkvbiF9Av3qG0HjHVSlvg0KPjCBUqiHMHfGcq7qz+jQkOwEXOHdsGyaGWb7BJrHDjVOnM3s1sW2LAgMBAAECggEBAK90Jql5EZP2euXa8XmcqV6Lox029dmbYZXtjFtwK2tFJGg8zX8aZJ1DpufAcICF2GugJE/Dz9lkfzk4LrySWuHrkYspDC14qTLof9wsPUNwH/LAaiCYgMFtqtgpbEN7p+hL1eP1bz+LBvsuf79WtP4JgJMyTJ7V5o7jTEg9/rSBt99A5xwcYLjzzOD73R/BaQchylhvXwAfz5w2wtmcG+33U+2yvok5n9uCtxkroFvlvK/ikje0MBem8Lx4PTd3VZZEvIFGLnb+xsCH+MqYqcSxdGwpvEAUMTJYfFiviiIAx+AaN3aJhS6xhP/2m643qx++rCrTyJh2jZ6Vv0N0DuECgYEA9wCJnX7haE6owsGIMJ4CrcBJ2iLojqAgCr9lG+yyyyRxhHMEThHEgOomXi5y74JXghtn4w3VvebvdOouMVfkfyosgaVLr6GYR0CphMHCkTD0Lr+G7GaNiFFjqk+JqXcefHbRMGhqFk2KxdxfsyAkB2MfUGurE2o3iGN4fckMorECgYEA2gLndvDtPsGS61WccS0a2PEhVn/x+0/tPv/qfBJ23nn8dLqKUcybCztQWgHm5uycABqTkIicIM0HeJg036Ia2SkbNEonDsQxbnNEYFJLlwr2j4duvUSGxS9DP+bT8eIbyTuhJ+oVvpyx1ZwUFsHNw4tQqqd5a5Lvqky/kOXjCvsCgYEA5HaA00Zqo5ouCoYLvDxK6f9zz+p+BH4jZQ2HLf8PmUpKHWJtVvCkO0FY38BC2zpKSrOisac4ToBueEurEkTjuqN9qyUDDp5/RViP85Vsq/MFyL+qwrpQqwftEbij8jWV4zXbY9UQWzS56S1e70YJTTPn4PDVug2C9ApdhqsRnuECgYBYUqrhphQHw7a4/vMlauegkng2Khmn/iaYymd+IqDj2znrNJPLNgBuWXZhMLoSPjOpWxsDiETwiQAI3Gk3XN5RsnSiB5SxR8za+XnvKAgVxkxDs9OqfDO5eT9eiS6+pSMqsKzGlfB/S85EQzpkSdoJ6cwhhz4K1fmg3f0SQAButwKBgQDO4ComuJVQKAAKZgSt7sbYhpscIfNZOhUiofPbHy1BOA1jKIWqfnQjLvkvKUkKv6/oxxgGlh9jEcnQgztG0ksYrq7EX+4tnHKdve4rH8UK5KJ56qvcJgDq5ojqBm6QPjkW77UO5R06fiFlBBCzNFmIE/YcpR1rcQ76W+w7IS/YVg==", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0llChXAo5buhl0Rf1kF5UhDusNB3lurtVbEB34eyKi2ojginL2WWqE0ot2xkDbkX55Nj1BxgqgjVzK4dx0sLK5/5z/kkERZ3w0ck5EWidXed5M/R7F8cL+Qb4def45Bj5iXz1RmUdAUINdy7Qadx2B8NNtaRaiTrIZmwlRUG2CbG6qc2j/Vzd4Z9xPye0C4kAl6REPhUcgBjwKSETmBtzWga322NwlKImOKnLe7kkcGYM2cvnm+fAMzCMCu/mPPowjk6xUotgkpL24hfQL96htB4x1Upb4NCj4wgVKohzB3xnKu6s/o0JDsBFzh3bBsmhlm+wSaxw41TpzN7NbFtiwIDAQAB" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-7.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDhadmSzGdfR/d6FE6sQ5fBjxSXQglmo0lNCuhV++c7SmUNnfzGo/ScAjhUFzJSt53Yz0gdjKhQfzOK5VQEZabm23cccweUGrZK6F6LAOVEvLYmMpCIQWV9jVJZIj+Ejo6o0SCSga9Q+e3GC/Tkc+Dzt8KlzjAfchau2QO5FJTHwO1Pq7zPm5EEMB+/mgDsL11iRu1mCYqVmv37+WefeyvMtN7uKj2q5A1Oa+ADNo3KePyOhu77pedHC8YK+Sdm7qOi2+jVRv+aGefghMzZQl863d3nWMawNJCemKR7mqEIVJlXzMLh/FA5/Xg9UDRUcZagnhqjjqHWstCabXigZHhPAgMBAAECggEAOpBoscYfeVbWSkZqZkEtdWF6JQ5IKP11dunFkUlgOzxJ4u7QFL/WNo4xGk/oiCsifIjmIJ9Bv6A8wPJyEK5kXYhZeu+74VPLVszme1DhQCmTXXs3p97twl/sLDJEtGjhUaT7xHSjGvPEPfcvSgd9Q3TTwoY+ZH0cvZKub/CT8w2E/cpWb8zdR1dsJlrNdexXbcl/zF303IvdTLc76RPF6d1fSJfxhu15buW647wiEd5PPE87ow221diQXDt/A+JyeHNoWf/+op13OJSvv4lNP83yG8Ys1RNOesVUSW86V3Rclwp5C+1dkuvyp6Q3gzZukPc1d4tE7fnyiTg6oWBTEQKBgQD2OB+6IP1jgZUm/Fq4YOKs7g+I3E7q1cK40rKvCDBhWvIZ5oHvoH0Tn/c7wW3MriNfiUGg5uPpXz0H/HK6Tz4RPfIu1Fj9ziOHLKiBLYpfAfCuCjFIbcImZ3AJD76UXu0OEq/LnaFsmlEb4AWMYSAr2IETQfAEfz0P10kTIJMoFwKBgQDqXiVkwMKyS7PFodcb6NW+FrcTYaJt6oDIvQRB1x7InZVYyzqEkwZXHjkTjb2KjIEjUYVay9zzfi5cjuVHI3w2/5BzuWNj669D0dtMX8LvOzV57iO11wkC+CZpQNY7+0JYzoBkAj19AYNKrKm8F0CcguVZEeSrmyoHf8oGEDqciQKBgFjlnp7nNlVs/dsble2oHW9ubHFviZbEIw/0EsubW0xrN6oeTZ+lBEPHp84NYoVaAi+GMQnVE0i5OCHgBdQ6tCApi31Y8eCBQtaVSymItcLjwnA0AeMyrbyL8Cl1Y8vSEijYmlwbx6KcfNhho98xWho6iy/WyL/26KcFhb7ALiF1AoGBAMUsL4l0IlieF8BNSAvS9v/VXHCR03VltLMtUkeSE/Pzn5H0aGbgypTAeIRa2vuU+ZAdJXQdzuWLYrW8Ami3EemzWHQDo/qMbgdApp66ceWSiorqLmDtaEd3PdmPEq2j1U2hbaK1v8VLYImSebokVddWyF0HELrO760fdXdkb+sBAoGAOx3tqF/2E8T6Y94NRh1WJfSsRzNt+rBJM58MyrfJTSypjeP27Sh2yk2v83ZGcYA1hHumycAQWzsLNB5dHjMstT0Bi3CfbaPn/GkvPSFxHPRgU00bD9oWB7yEz+PPlITOafQe1Yv5zJxDLhkzr8NzLSx6TrsFZgZMFiyM//hjBgA=", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4WnZksxnX0f3ehROrEOXwY8Ul0IJZqNJTQroVfvnO0plDZ38xqP0nAI4VBcyUred2M9IHYyoUH8ziuVUBGWm5tt3HHMHlBq2SuheiwDlRLy2JjKQiEFlfY1SWSI/hI6OqNEgkoGvUPntxgv05HPg87fCpc4wH3IWrtkDuRSUx8DtT6u8z5uRBDAfv5oA7C9dYkbtZgmKlZr9+/lnn3srzLTe7io9quQNTmvgAzaNynj8jobu+6XnRwvGCvknZu6jotvo1Ub/mhnn4ITM2UJfOt3d51jGsDSQnpike5qhCFSZV8zC4fxQOf14PVA0VHGWoJ4ao46h1rLQmm14oGR4TwIDAQAB" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-8.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "rsa MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDHs3CFlSf7G2sWv41P38haAHrkfPGgWH29yK2ewIyaJJ4+fuY1f3GfBqkm+IsclY6z3EE/b9HxIjbVA5oLCU990iMro6jFa/qmO8GEogfcTvw+OCP0EaU3vzFMQEfDwtMDR2j+yT7TeyvaqgDDBokBuZcn7ZjVbeeA+HJDF9tET5Tj8QBw922pu/rcLGZgILFQLqm2Qym5uG5vEFC/upSI9rPneGMljHwU5ZY+CnFDJEcVtfWF75DJXxO8aYDNhfxDBUIFz6bg5bNNYO21DV0YQLvQOHigKl6JCg0SQM3rruoc8N1OD7svMazIA8hUfQrC8YNREQYzAwwmQThWGyeNAgMBAAECggEBAKV5sdZu5uczLAR4iz7RXvH9DdgBFDLawK6e+Abg5GDh0OJWQqm3xc2RNl7demAgKVQuQT6wiJU31Zmi12UnvN+0XYJOpY2ZUOOoBk3B+aN7K5be7CPU70OHQPE/Hng/GpzP8leVKGMS4B7b2a/A3Yw5XeAvCAJqhHcg54Vi4kTx+QRD2/lVjODPKQxk0aBZOkLznI1xdkuUyemNHOdTzxrQgnIidMMc7fyNMDX0/lz6ZwHvCOSglaAawemx/6xNH31XEWi8fHA832Q7dsyXhlA8hMuDx3vMJd5lqq0pArvQiH4M6ojPDqqyptKjidlfXASXtm40xXCjrMu1pGC5QCECgYEA0xwjHB2SVusInDdHbOnreMjOYbtlzO7NJlCeL9lQo49BGaEIQ0tidek/muwQIojGMDOSUKHBFXbXr9BDnbXoU+w8gQIwUNEuacuTLcZ1gXvHpIcgyYY7eBKbExyNdGzAhIoobgDk2Qay1weo35crY5E6tbVibYj5XGD+iAXVHckCgYEA8io/7NpJa7N1Esb6ZTKEw4+036MxB6HIhuUrUM66DQpS4OAavPdcMPVQCjFMbjy+ALm19ix3Ln5CiS92FPTs9tAMJeuy4oFu3uMt3GetrNuWHGQH7e7aRw6WpTScptFLhJgeDfJjxWhvqs3vTW3AzizpYrALyWDAbV2fk0I9zaUCgYEAm87Ldue4ZuAGtczysUaf3MBP2b/GbY7d6GZdqbD5HA4RnQnFoG0V2TJyGDQb4HET3OVjGpGXgPD6VS8fiFmGg9H6AbkM0cjhOYHfOUyc0xj5CswUfcfNQlxxCZTsLb5KBEg3eKC+RhL0kVF86LCYfF7mds/NOkx6xhxsHxY26UkCgYATLmOH2DZukHVaemZE875uWwihmiR9DUR74tUOfoFgHQw5gaa8hv9HZXbkh8kdBjSqjAssp5L9HMUaZqb8u/W1Cv+bVVMC++uTPf1Y8uFfyrjWINo772pcrHwkM8mgsP1BUGc5BZT/guktZ0hoIqRd8FLAHV+hoMc9ImhMWrfYfQKBgQCZrTqt+HWp83qOwWHbMfo+INTCA3073g1Tpptys614R/F/LUCQmsxF4OKUHObF/gqgNiF15YKKZ2Ym3Y5RR840JfpJkpn8ak35EGFQJzolx3aEMgvNhDIZqCi6KOUrbxEeTRRDTFU7NixNStGhnfPZ+ChxbLUVG/Mc3NP/ZZaDdQ==", 3 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx7NwhZUn+xtrFr+NT9/IWgB65HzxoFh9vcitnsCMmiSePn7mNX9xnwapJviLHJWOs9xBP2/R8SI21QOaCwlPfdIjK6OoxWv6pjvBhKIH3E78Pjgj9BGlN78xTEBHw8LTA0do/sk+03sr2qoAwwaJAbmXJ+2Y1W3ngPhyQxfbRE+U4/EAcPdtqbv63CxmYCCxUC6ptkMpubhubxBQv7qUiPaz53hjJYx8FOWWPgpxQyRHFbX1he+QyV8TvGmAzYX8QwVCBc+m4OWzTWDttQ1dGEC70Dh4oCpeiQoNEkDN667qHPDdTg+7LzGsyAPIVH0KwvGDUREGMwMMJkE4VhsnjQIDAQAB" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-ed25519-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "ed25519 MC4CAQAwBQYDK2VwBCIEILq+V/CUlMdbmoQC1odEgOEmtMBQu0UpIICxJbQM1vhd", 3 | "public_key": "ed25519 MCowBQYDK2VwAyEARdZSwluYtMWTGI6Rvl0Bhu40RBDn6D88wyzFL1IR3DU=" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-ed25519-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "ed25519 MC4CAQAwBQYDK2VwBCIEIBhWZBF7Fbmr0jltIBUIywgei+xQDDIfPatGvgoALocK", 3 | "public_key": "ed25519 MCowBQYDK2VwAyEA4KhfZWs/+B9Xx6eU+zN+A1USGtXsCs5zJNRq8JOM9EA=" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-ed25519-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "ed25519 MC4CAQAwBQYDK2VwBCIEIJmrlGqx1wOd7CPLM6XL6WAmgZVWInf3Z6Ru1pDZ3ilb", 3 | "public_key": "ed25519 MCowBQYDK2VwAyEASqHY0CaqJpmTdTcjk/+emW1ZCufzu5gWqbs6sntxdVc=" 4 | } 5 | -------------------------------------------------------------------------------- /testdata/key-ed25519-4.json: -------------------------------------------------------------------------------- 1 | { 2 | "private_key": "ed25519 MC4CAQAwBQYDK2VwBCIEIJadTjYVYqkkvAHypVwX9zSupDivABbHy5Ux7vw/4xrZ", 3 | "public_key": "ed25519 MCowBQYDK2VwAyEAJ8iDQtXhyBSP6ujW++BbiHUglCXyY/ou6RLkoHjCVxI=" 4 | } 5 | 6 | 7 | -------------------------------------------------------------------------------- /testdata/privkey.ecdsa: -------------------------------------------------------------------------------- 1 | ecdsa MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDAhWlJBCJ4TIMG+nU9f9u1G/K2uK1IDaNL/L3PdTQM6p9jt3ze58APSa6yLlvvHEfmhZANiAAQPSxUHtwrKicVXxKpusmJgdm2Q8GGVPht8IJK6g67X8ceZWGm/bdJW76P0wyxWOWWZPOG5NE3XzsUSqD7ui4rGbAqyuMwJijIxTIb/uoBXJocre1V8b/ltyFoX2wxgk4A= 2 | -------------------------------------------------------------------------------- /testdata/privkey.ed25519: -------------------------------------------------------------------------------- 1 | ed25519 MC4CAQAwBQYDK2VwBCIEIBhWZBF7Fbmr0jltIBUIywgei+xQDDIfPatGvgoALocK 2 | -------------------------------------------------------------------------------- /testdata/privkey.rsa: -------------------------------------------------------------------------------- 1 | rsa MIICXQIBAAKBgQC57qC/BeoYcM6ijazuaCdJkbT8pvPpFEDVzf9ZQ9axswXU3mywSOaR3wflriSjmvRfUNs/BAjshgtJqgviUXx7lE5aG9mcUyvomyFFpfCR2l2Lvow0H8y7JoL6yxMSQf8gpAcaQzPB8dsfGe+DqA+5wjxXPOhC1QUcllt08yBB3wIDAQABAoGBAKSWDKsrtB5wdSnFmcfsYKKqHXjs3Mp9CCt6z0eYWoswesAFKFcgISINOLNi5MICX8GkFIACtVeSDJnnsd9j3HkRD7kwxmvVVXltaIrbrEunKgdRK1ACk2Bkb7UUDImDjiZztJvCSL+WLu9Fphn8IfPzwAIPWAKKBoD1kuI6yfFBAkEA6dJpoTMKDlCEMeJWZVUnhL7K/OBphWLO7cZfaxowBeGGXuMBWiaySsdeIDV7S/PDnoHBKwIkSsSfjzWYptuq4QJBAMuRXwoqZHKPHjMTCyz3C7nwFCzgmmKM5PReZU0s4/tdFu/VGOSnVDSzC5JFcY48Cs03TBwZ2wPhv/3r4a7YRL8CQQCxedRTVro7Q0IT2whYwdnNGERazLtLU0RdlkS2tpnc3OFxBDzygIyz1b/MEswTSmMg3LwSOP3zAmtZ+AR2IiYBAkBENgnqlhniaSJtaswr3PwI6fFYuEoDC8MMPzUijxA1ghPVeUpGE+ubXQNbl/lc97GG4iiWofNJcbOrmgadV8pxAkBhsn2T9DSoDdeImRecxs3/Xej4EYQpj/3X436RrFntjT06wD6wF9s5CvPmz/ftUBJ71IVlBQUd3jOgQPRzEhNC 2 | -------------------------------------------------------------------------------- /testdata/pubkey.ecdsa: -------------------------------------------------------------------------------- 1 | ecdsa MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAED0sVB7cKyonFV8SqbrJiYHZtkPBhlT4bfCCSuoOu1/HHmVhpv23SVu+j9MMsVjllmTzhuTRN187FEqg+7ouKxmwKsrjMCYoyMUyG/7qAVyaHK3tVfG/5bchaF9sMYJOA 2 | -------------------------------------------------------------------------------- /testdata/pubkey.ed25519: -------------------------------------------------------------------------------- 1 | ed25519 MCowBQYDK2VwAyEA4KhfZWs/+B9Xx6eU+zN+A1USGtXsCs5zJNRq8JOM9EA= 2 | -------------------------------------------------------------------------------- /testdata/pubkey.rsa: -------------------------------------------------------------------------------- 1 | rsa MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC57qC/BeoYcM6ijazuaCdJkbT8pvPpFEDVzf9ZQ9axswXU3mywSOaR3wflriSjmvRfUNs/BAjshgtJqgviUXx7lE5aG9mcUyvomyFFpfCR2l2Lvow0H8y7JoL6yxMSQf8gpAcaQzPB8dsfGe+DqA+5wjxXPOhC1QUcllt08yBB3wIDAQAB 2 | -------------------------------------------------------------------------------- /testdata/routing.json: -------------------------------------------------------------------------------- 1 | { 2 | "routing_id": "863b0cbe15f59868a28b701458d6474c8099f44aa39602fc36aa8ad7e83e6fbe", 3 | "private_key": "rsa MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDi1VTDslQVi5uwmk9HFfksn6utY/y6SObPgkqo9wnw/KnI0Kqjd9C4LCkzK3mCMRSDLWSbZRDRGn3YQEPgDKW/uNd4MAjMkB+DmSSXDa9WA1oCF4ZqpxJBzPYQJJqzWGozBUvFHa9ddxY563eib49sQvmGxBca25Bh0eYvwHQJzkSmTI6irlqKhy+f0toUeJlpL4w0GaQ1XBdZTq07ZNJxXrXekvOKlcz3nK0fa3BfGhVdsYLDaIY56PycKiaI4ezbgzFzGlhKl0oFlfbHHjtOzALywnCs53xqVR3eo8CKH+e3qcmJtE5cBig3In/oIW7G0BVl7/b4ntTJU3reDWYdAgMBAAECggEAXr+7g28G3mUNaGxcdxX/mhssC+Y7F9kByGXlJ8Tg+y+fAAnhbRzMK1IO95fOToqPxed9IcfKiX2mWWEmuPyvc3ETV9nAoyoEb+TVOt91gNkvjLYk6IHXB3NEySNxFz70RVGN/81RhhoLR7BKragp4Y/sSNW5zPcvzRxvKT0be0hLSu5JBYYY3Ra8SAbjbpjhltwX0Ntd/66NXqk+BbRHeAlDyPmseBs/rtMtv24LbxkzWhdpq0zVx61GvWj/our1exQ5Ec1YqvZDSUG03HwsOk0kli3SVFPbsO9Up58oouG7IAgUYdBVOWxIC1yhZlke0ShcMKEUMBdEt0FaH/rTAQKBgQD448/nPeg0mvxvjeqThII3jCcKc8POsROYaCbA9S/zt4Jk1eDiqKvhkSYH0K5o+CWKRpHUGChxuZ1jUmVNWcfJHr8qWa564cpC/JoIDuGjM7UihOFMjVRcJUpUaUgxiWsi4ZnyPHCiRe0frye1VeIOLk7JcK/f0j6dNYukCIJKwQKBgQDpUDbfaViI075SJOYaDbXfir38q0+p0PYNO+Ng8f4YmaDN/N7wqxQgEVi0tpvJBpJdtExbbHfjwX5+4dZ0/eNwOUaTHHdQ8gur6IPzTNe2OQ7J4ScdRs2LmZSTxXcWWRp1RmaVI+em8fooycVsiCSaJvc1L90Ym29Uwjq4U32+XQKBgQC8jVGmvLaai8Or+1Z3tU41KL824ua3Ql02+8hILDfMqfxlycYZ0HCObTjjeMt4iG1gKQA3LqoNJfI/GV/XTqnVCq8GNXTCcSWaw+UpL6Tuz7Bs20AXj4YWXMXH1w6zQIjinwjSg8lMli8C7t3lOZAM8DYN04nZxVxcGwGUHkIewQKBgQDF2wF9up+bAT3/+UytQX0/wi/Viw22q/9NP8FWoEFkaTvmE5CYNeyOOUepkMZR1uHe1xx912FgYuG8BhbRBdGPhPLlpJlGqszdDwR/GmZAIOj6qJZ8DGQZA7ftDOMtr4hxda9ewKEdgU0ss9dZb6bilzLDBwEPchkantAfKqaS/QKBgQDShrSAMp1uE8ytzAY1OCqR6lci/Z2G0ocXh08brXPN0K0BP07rF/AW6F9C8a1YSFuDn/9Xis7V9Z68TPbvQYUIOCtX0CEPa01TdVqovuHfQDJJyBn49J8vSf8wMjh8WgmeTlGJz5lttTgMNYR5Yuj1MmY5DlaxUU9aByddrUz6JA==", 4 | "public_key": "rsa MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4tVUw7JUFYubsJpPRxX5LJ+rrWP8ukjmz4JKqPcJ8PypyNCqo3fQuCwpMyt5gjEUgy1km2UQ0Rp92EBD4Aylv7jXeDAIzJAfg5kklw2vVgNaAheGaqcSQcz2ECSas1hqMwVLxR2vXXcWOet3om+PbEL5hsQXGtuQYdHmL8B0Cc5EpkyOoq5aiocvn9LaFHiZaS+MNBmkNVwXWU6tO2TScV613pLzipXM95ytH2twXxoVXbGCw2iGOej8nComiOHs24MxcxpYSpdKBZX2xx47TswC8sJwrOd8alUd3qPAih/nt6nJibROXAYoNyJ/6CFuxtAVZe/2+J7UyVN63g1mHQIDAQAB" 5 | } 6 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | Various tools. Most of them are used for development purposes and should not be used for normal daily use. 2 | 3 | gen-key Generates a custom keypair 4 | hash-address Displays the hash for the given address 5 | jwt Generates a JWT token for authentication to a mailserver 6 | jwt-validate Validates a JWT token 7 | proof-of-work Does proof of work for X bits on given data. 8 | resolve-auth Generates authentication key for updating / deleting resolver key 9 | toaster Checks mailbox and displays a graphical toast message if new mail arrives 10 | update-pow Updates proof-of-work for all accounts to X bits. 11 | update-resolver Uploads organisation or account to the resolver 12 | vault-edit Allows you to manually edit the vault's JSON data and automatically encrypts it back again. 13 | -------------------------------------------------------------------------------- /tools/gen-key/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | 26 | "github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto" 27 | ) 28 | 29 | func main() { 30 | if len(os.Args) != 2 { 31 | fmt.Printf("Usage: %s ", os.Args[0]) 32 | os.Exit(1) 33 | } 34 | 35 | keyType := os.Args[1] 36 | 37 | fmt.Printf("Generating key for %s...\n", keyType) 38 | kt, err := bmcrypto.FindKeyType(keyType) 39 | if err != nil { 40 | panic(err) 41 | } 42 | 43 | priv, pub, err := bmcrypto.GenerateKeyPair(kt) 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | fmt.Println("Priv: ", priv.String()) 49 | fmt.Println("Pub : ", pub.String()) 50 | } 51 | -------------------------------------------------------------------------------- /tools/hash-address/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "bufio" 24 | "fmt" 25 | "os" 26 | "strings" 27 | 28 | "github.com/bitmaelum/bitmaelum-suite/pkg/address" 29 | ) 30 | 31 | func main() { 32 | reader := bufio.NewReader(os.Stdin) 33 | 34 | for { 35 | fmt.Print("\U0001F4E8 Enter address: ") 36 | addr, _ := reader.ReadString('\n') 37 | addr = strings.Trim(addr, "\n") 38 | 39 | if addr == "" { 40 | break 41 | } 42 | 43 | a, err := address.NewAddress(addr) 44 | if err != nil { 45 | panic(err) 46 | } 47 | fmt.Printf("Hash: %s\n", a.Hash().String()) 48 | fmt.Printf(" Local: %s\n", a.LocalHash().String()) 49 | fmt.Printf(" Org: %s\n", a.OrgHash().String()) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tools/proof-of-work/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 BitMaelum Authors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | // the Software, and to permit persons to whom the Software is furnished to do so, 8 | // subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | "strconv" 26 | 27 | pow "github.com/bitmaelum/bitmaelum-suite/pkg/proofofwork" 28 | ) 29 | 30 | func main() { 31 | if len(os.Args) != 3 { 32 | fmt.Printf("Usage: %s ", os.Args[0]) 33 | os.Exit(1) 34 | } 35 | 36 | bits, _ := strconv.Atoi(os.Args[1]) 37 | data := os.Args[2] 38 | 39 | fmt.Printf("Working on %d bits proof...\n", bits) 40 | work := pow.NewWithoutProof(bits, data) 41 | 42 | work.WorkMulticore() 43 | fmt.Printf("Proof: %d\n", work.Proof) 44 | } 45 | -------------------------------------------------------------------------------- /tools/vault-edit/README.md: -------------------------------------------------------------------------------- 1 | # Tool: vault-edit 2 | 3 | Vault manipulation tool 4 | 5 | Usage: 6 | 7 | $ vault-edit -p 8 | 9 | Make sure you have your EDITOR environment setting pointed to an editor. 10 | 11 | 12 | -------------------------------------------------------------------------------- /wix.json: -------------------------------------------------------------------------------- 1 | { 2 | "product": "BitMaelum Software Suite", 3 | "company": "BitMaelum", 4 | "license": "LICENSE", 5 | "upgrade-code": "b9d54351-3d27-4716-bb6b-51dd7aa30c47", 6 | "files": { 7 | "guid": "70ac3314-051b-49ee-83f1-bd2d077337e0", 8 | "items": [ 9 | "bm-client.exe", 10 | "bm-config.exe", 11 | "bm-json.exe", 12 | "bm-send.exe", 13 | "bm-server.exe", 14 | "bm-bridge.exe", 15 | "bm-mail.exe" 16 | ] 17 | }, 18 | "env": { 19 | "guid": "afff18b3-b4a8-4f84-8954-87fb3d508491", 20 | "vars": [ 21 | { 22 | "name": "PATH", 23 | "value": "[INSTALLDIR]", 24 | "permanent": "yes", 25 | "system": "no", 26 | "action": "set", 27 | "part": "last" 28 | } 29 | ] 30 | }, 31 | "shortcuts": {}, 32 | "choco": {} 33 | } 34 | --------------------------------------------------------------------------------