diff options
Diffstat (limited to 'src/helpers/decodeClientDataJSON.ts')
-rw-r--r-- | src/helpers/decodeClientDataJSON.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/helpers/decodeClientDataJSON.ts b/src/helpers/decodeClientDataJSON.ts new file mode 100644 index 0000000..b957d60 --- /dev/null +++ b/src/helpers/decodeClientDataJSON.ts @@ -0,0 +1,12 @@ +import asciiToBinary from './asciiToBinary'; + +/** + * Decode an authenticator's base64-encoded clientDataJSON to JSON + * + * @param data + * @returns {Object} - the data as JSON + */ +export default function decodeClientDataJSON(data: string) { + const toString = asciiToBinary(data); + return JSON.parse(toString); +} |