Created
May 17, 2022 15:33
-
-
Save nloding/26d51a0fc2e15ff454e19080a819c464 to your computer and use it in GitHub Desktop.
Masking data with Reactors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.basistheory.com/detokenization/#transformations-json-path