0.39.0 • Published 2 years ago

@moneybutton/express-paymail v0.39.0

Weekly downloads
129
License
Open-BSV
Repository
github
Last release
2 years ago

@moneybutton/express-paymail

Description

This package intents to be a full implementation of BSV paymail specification easy to plug in any expressjs app.

Getting started

This is a minimal example of an express app using this package:

import { buildRouter } from '@moneybutton/express-paymail'
import express from 'express'

const BASE_URL = 'example.tls' // The library needs to know
                               // the actual url where the app is going to work

const paymailRouter = buildRouter(BASE_URL, {
  basePath: '/api/bsvalias',
  getIdentityKey: async (name, domain) => {
    // A paymail has the form `name@domain`. You can find the appropiate
    // key using paymail data.
    return '0335e5e7b86c12a4b5df082acb43ca7805382b58c805172bdef20ced310df845aa' // Some public key
  },
  getPaymentDestination: async (name, domain, body, helpers) => {
    // This method have to return a valid bitcoin outputs. The third parameter is the
    // body of the request and the fourth parameter is a js object containing handful
    // methods to create outputs.
    return helpers.p2pkhFromAddress('1FJJkRqyxTKAVX3dGFpddERt9XRbiSRZkL')
  },
  verifyPublicKeyOwner: async (name, domain, publicKeyToCheck) => {
    // Returns true if the public key belongs to the user owning `name@domain`, false in
    // any other case.
    return '0335e5e7b86c12a4b5df082acb43ca7805382b58c805172bdef20ced310df845aa' === publicKeyToCheck
  }
})

const app = express()
app.use(paymailRouter)

app.listen('3000', () => {
  logger.info(`Listening on port ${API_REST_PORT}.`)
})

This generates an app with the following endpoints:

endpointdescription
/.well-known/bsvaliasApi descriptor. Generated automatically.
/api/bsvalias/id/{alias}@{domain.tld}Returns public key for a given paymail.
/api/bsvalias/address/{alias}@{domain.tld}Returns an output to send money to a given paymail owner.
/verifypubkey/{alias}@{domain.tld}/{pubkey}Checks if a given pubkey belongs to given paymail.
0.39.0

2 years ago

0.38.8

3 years ago

0.38.7

3 years ago

0.38.6

3 years ago

0.38.5

4 years ago

0.38.4

4 years ago

0.38.3

4 years ago

0.38.2

4 years ago

0.38.1

4 years ago

0.37.0

4 years ago

0.36.0

4 years ago

0.35.0

4 years ago

0.34.0

4 years ago

0.33.0

4 years ago

0.32.0

4 years ago

0.31.3

4 years ago

0.31.2

4 years ago

0.31.1

4 years ago

0.31.0

4 years ago

0.30.1

4 years ago

0.30.0

5 years ago

0.28.1

5 years ago

0.28.0

5 years ago

0.27.0

5 years ago

0.26.0

5 years ago

0.25.0

5 years ago

0.24.4

5 years ago

0.24.3

5 years ago

0.24.2

5 years ago

0.24.0

5 years ago

0.23.1

5 years ago

0.23.0

5 years ago

0.22.2

5 years ago

0.22.1

5 years ago

0.21.11

5 years ago

0.21.10

5 years ago