express middleware for hosting Wyre verification using Plaid.
- Migrating to
>=0.1.0
has deprecated the{ verify }
export fromexpress-wyre
in favour of a dedicated{ wyre }
export, which nests all dependent middleware.- This means you'll need to replace existing implementations of
.use("wyre/verify", verify())
with.use("/wyre", wyre({ env: "test" }))
, which in turn generates thewyre/verify
route. - In addition, callers are required to define their environment configuration upon invocation, whereas in the past it implicitly defaulted to
{ env: "test" }
.
- This means you'll need to replace existing implementations of
Using yarn:
yarn add express-wyre
Once installed, insert the middleware into your existing express
app at an appropriate path:
import express from "express";
import { verify } from "express-wyre";
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
.
In sandbox mode, you can login to Plaid using the following credentials:
user_good
pass_good
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)}`;