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

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);
}