diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-17 23:20:00 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-17 23:20:00 -0700 |
commit | 23e320bf7133a90ae4dfcec7c65249c1dde7e321 (patch) | |
tree | 44d4823b72f4f5c1cd6603db520077405b62dc96 /src/helpers/decodeClientDataJSON.ts | |
parent | 3b26d1c8322f13178377467e438884621a75e284 (diff) |
Add some helpers
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); +} |