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.
Masking data with Reactors
{
"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
}
]
}
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)
}
}
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));
});
@nloding
Copy link
Author

nloding commented May 17, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment