From 23e320bf7133a90ae4dfcec7c65249c1dde7e321 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 17 May 2020 23:20:00 -0700 Subject: Add some helpers --- src/helpers/decodeClientDataJSON.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/helpers/decodeClientDataJSON.ts (limited to 'src/helpers/decodeClientDataJSON.ts') 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); +} -- cgit v1.2.3