express-sendwyre
v0.0.1-alpha.0
Published
💰 Express middleware for hosting Wyre verification. https://www.sendwyre.com/
Downloads
4
Readme
express-sendwyre
express middleware for hosting Wyre verification.
🚀 Installing
Using yarn:
yarn add express-sendwyre
✍️ Usage
Once installed, insert the middleware into your existing express
app at an appropriate path:
import express from "express";
import { verify } from "express-sendwyre";
express()
.use("/wyre/verify", verify({ env: "test" })) // sandbox mode
.listen(3000, () => null);
In this example, your clients may then make HTTP GET
requests to http://localhost:3000/wyre/verify
.
🦮 Retrieving the Access Token
The verification process served by Wyre returns an access token which is used to enumerate your authenticated user, which can be returned back to the frontend by specifying a base-64 encoded redirect
URL query parameter:
const addressToReturnTokenTo = "myapp://";
const requestUri = `http://localhost:3000/wyre/verify?redirect=${btoa(addressToReturnTokenTo)}`;
Upon successful verification, the browser will be redirected to the supplied redirect
URI with the base-64 encoded wyreToken
:
const successRedirectUrl = `myapp://?wyreToken=${btoa(wyreAccessToken)}`;
On error, the browser will redirect to the specified URI and provide the base-64 encoded wyreError
message as a URL parameter:
const errorRedirectUrl = `myapp://?wyreError=${btoa(errorMessage)}`;