summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/decodeClientDataJSON.ts
blob: 1aeb9c94e502e7c9ddb7f6c68de360f14408335c (plain)
1
2
3
4
5
6
7
8
9
10
11
import { ClientDataJSON } from '@webauthntine/typescript-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);
}