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

import asciiToBinary from './asciiToBinary';

/**
 * Decode an authenticator's base64-encoded clientDataJSON to JSON
 */
export default function decodeClientDataJSON(data: string): ClientDataJSON {
  const toString = asciiToBinary(data);
  return JSON.parse(toString);
}