summaryrefslogtreecommitdiffhomepage
path: root/src/helpers/decodeClientDataJSON.ts
blob: 2b5bbbd3e03b30f63b05568a699d828052f8ec4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { ClientDataJSON } from '@types';

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): ClientDataJSON {
  const toString = asciiToBinary(data);
  return JSON.parse(toString);
}