Skip to content

Instantly share code, notes, and snippets.

@nloding
Created May 17, 2022 15:33
Show Gist options
  • Save nloding/26d51a0fc2e15ff454e19080a819c464 to your computer and use it in GitHub Desktop.
Save nloding/26d51a0fc2e15ff454e19080a819c464 to your computer and use it in GitHub Desktop.

Revisions

  1. nloding created this gist May 17, 2022.
    16 changes: 16 additions & 0 deletions formula-config.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    {
    "name": "Mask Data - Example",
    "description": "Mask custom data with a Reactor",
    "type": "private",
    "code": "module.exports = async function (req) {\n const mask = (str, mask, n = 1) => \n ('' + str).slice(0, -n)\n .replace(/./g, mask)\n + ('' + str).slice(-n)\n\n const { data } = req.args\n\n return {\n raw: mask(data)\n }\n}",
    "configuration": [
    ],
    "request_parameters": [
    {
    "name": "data",
    "description": "All fields in this object will be masked",
    "type": "string",
    "optional": false
    }
    ]
    }
    12 changes: 12 additions & 0 deletions formula.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    const formula = async function (req) {
    const mask = (str, mask, n = 1) =>
    ('' + str).slice(0, -n)
    .replace(/./g, mask)
    + ('' + str).slice(-n)

    const { data } = req.args

    return {
    raw: mask(data)
    }
    }
    18 changes: 18 additions & 0 deletions usage.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    return axios
    .post(
    `https://api.basistheory.com/${reactorId}/react`,
    {
    data: "{{token-id | $.bankAccountOne}}"
    },
    {
    headers: {
    "BT-API-KEY": process.env.BASIS_THEORY_SERVER_APPLICATION
    },
    }
    )
    .then(async ({ data }) => {
    res.status(200).json({ data });
    })
    .catch((err) => {
    console.log(JSON.stringify(err));
    });