summaryrefslogtreecommitdiffhomepage
path: root/src/helpers/decodeClientDataJSON.ts
blob: b957d60b3f532ec3480241582ac58c3773efd6db (plain)
1
2
3
4
5
6
7
8
9
10
11
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);
}