Code Monkey home page Code Monkey logo

openmonetizationwallet's Introduction

Open Monetization Wallet

Tools for managing your vanity Web Monetization wallet

Summary

Open Monetization Wallet (OMW) makes it easier to accept payments with the Web Monetization API at scale. Some features:

  • Custom wallet URLs: own your own "Payment Pointer", e.g. $wallet.signalnerve.com, instead of $pay.stronghold.co/abcdef123
  • Change between wallets/providers with no downtime
  • Logs of incoming payment requests
  • Revenue sharing between multiple wallets, e.g. for multiple team members
  • Infinitely scalable with serverless technology
  • Free and open-source

Example

Prerequisites

  • A Cloudflare Workers unlimited plan to deploy your OMW instance
  • If deploying in front of a domain, a configured Cloudflare zone (see the "Origin" section of "Configuration" below)
  • wrangler cli tool installed and configured (see the Quick Start in the docs)
  • A configured Web Monetization wallet + payment pointer for use in your account, e.g. from Stronghold

Configuration

wrangler.toml

Copy wrangler.toml.example to wrangler.toml and begin filling out the file to prepare your OMW instance for deployment.

KV Namespace

OMW assumes the existence of DB, a KV namespace that is used for writing wallet and log information from your application. To create this namespace, use wrangler:

$ wrangler kv:namespace create DB

This will create a KV namespace for your project and give you the appropriate code to copy into wrangler.toml. Note that the example wrangler.toml includes most of this definition already, so you can simply replace the $BINDING_ID value with your unique binding ID to configure the namespace.

Instance Password

OMW instances are password-protected by default to prevent unauthorized access to your admin panel. To set a randomly generated password, run the included bin/generate_secret command. This password will only be shown once, so make sure you write it down somewhere!

$ bin/generate_secret
# If deploying multiple environments, pass the environment name
# as an argument to generate a new secret for that env
# $ bin/generate_secret [optional_environment]

Generally, it's recommended that you fork OMW for your own instance, which will allow you to opt into the automatic GitHub Actions deployment (see "Deploying") and not need to manage your own instance locally. Better instructions here are in the works!

To prepare your OMW instance for deployment with GitHub Actions, you should generate two GitHub secrets in your repository's Settings section: CF_ACCOUNT_ID, which represents your Cloudflare account ID, and CF_API_TOKEN, a unique API token created for deploying Cloudflare Workers projects. For more help finding these values, check out the Workers Quick Start.

Custom domains

If you'd like to deploy your OMW instance to a custom domain, you'll need to configure it inside of the Cloudflare dashboard. For more information on this, see the Workers Quick Start section "Publish to your Domain". Your wrangler.toml should include a zone_id and route, for instance:

zone_id = "abcdef123"
route = "mycustomwalletdomain.com/*"

Deploying

OMW is set up to allow automatic deployments using GitHub Actions. This means that whenever a new Git commit is pushed onto the master branch, GitHub Actions will automatically build the project and deploy it.

You can also deploy manually from your local machine:

yarn run gatsby:build
wrangler publish

Development

OMW uses Gatsby and Wrangler for local development. You can begin developing or exploring the application locally by running the following commands:

yarn
gatsby develop # Local UI development
wrangler dev   # Test serverless/edge functionality

Note that many of the edge/serverless operations, such as loading KV data locally, aren't supported inside of the gatsby develop workflow. This is something I'd like to fix in the future, and I've opened a ticket for tracking it: #7

License

OMW is licensed under the MIT license.

openmonetizationwallet's People

Contributors

kristianfreeman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

davidtsong donjo

openmonetizationwallet's Issues

Landing page

When a request comes in that isn't a web monetization request (Accept: application/spsp4+json header), the deploy could render a nice landing page:

  • Show that this is an OMW instance w/ logo
  • If it's configured, allow copying the URL from the page
  • Information for admins on how to get started, or access/change password if they've forgotten
  • Link to source code

Better documentation/process around initial setup/deployment

Initial setup of OMW is very developer-oriented: you need to run through the Workers quick start, be able to create KV namespaces locally, edit your wrangler.toml, etc – instead of needing to do all this, it would be neat to be able to do everything from the UI or with GitHub Actions + the CF dashboard and not need to do any sort of local terminal development

Local development is hard when using KV

Currently, gatsby develop is fairly limited, because all the data for the application comes from KV. Running wrangler dev works, but you need to run gatsby build repeatedly as you're changing code. I'd like to set up either a live-reloading process, or have gatsby develop be able to:

  1. recognize it's in a development mode
  2. route requests to localhost:8787 (locally running instance of the Workers application)

A temporary solution to this has been taking the JSON blob from my wallets key and copying it into the components manually, in order to play with the data as it exists on the edge. This isn't a great solution (and I've accidentally committed it a few times, oops)

Usage metrics

After the settings page (#9) is created, there should be a configurable option to report metrics back from OMW instances. This would be 100% anonymized usage metrics to help me know how many people are using OMW

Finish README

  • What is this project
  • Check out demo
  • Configuration/Deployment

Document API

The frontend app uses the /api routes to retrieve data from KV. These should be documented so they can be used by developers!

Multiple wallets

The primary wallet should become the default wallet, and then additional wallets can be defined and accessed at a provided/validated pathname. Each wallet can have its own set of users/wallet + revenue share.

Logs should show wallet information, instead of ID

Currently, the logs show a wallet ID/uuid. Instead, the Log component should take an optional wallet object, and use it to render the user/wallet name, instead of a UUID – especially when that UUID is never actually exposed in the UI!

Authenticate API routes

The API routes defined here should be better authenticated. Currently, all the data here is OK to be public-facing, but that should probably change.

The changes:

  • Require admin key as API key
  • Potentially allow configuring CORS in a settings page (#9)

Redesign logging page

Hero

Similar to the dash, showing some high level log information could be useful - "# of logs over the past week"/"past month"/etc., among others

Geo

With the availability of country information, a map could be a cool way to show off how your wallet is being accessed around the world

Pagination

For well-trafficked wallet instances, pagination will need to be introduced to allow users to look at all the logs for their application

Soft deletion of wallets

Wallets should be able to be deleted, but because the logs are tied to a wallet ("Who was paid for this request?"), the wallets should stick around so that the work implemented in #3 resolves correctly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.