summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/decodeClientDataJSON.test.ts
blob: 9f22bcb486d7954e78f16d143131e6ee95ff4452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { assertEquals } from 'https://deno.land/std@0.198.0/assert/mod.ts';

import { decodeClientDataJSON } from './decodeClientDataJSON.ts';

Deno.test('should convert base64url-encoded attestation clientDataJSON to JSON', () => {
  assertEquals(
    decodeClientDataJSON(
      'eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiWko0YW12QnpOUGVMb3lLVE04bDlqamFmMDhXc0V0TG5OSENGZnhacGEybjlfU21NUnR5VjZlYlNPSUFfUGNsOHBaUjl5Y1ZhaW5SdV9rUDhRaTZiemciLCJvcmlnaW4iOiJodHRwczovL3dlYmF1dGhuLmlvIn0',
    ),
    {
      type: 'webauthn.create',
      challenge:
        'ZJ4amvBzNPeLoyKTM8l9jjaf08WsEtLnNHCFfxZpa2n9_SmMRtyV6ebSOIA_Pcl8pZR9ycVainRu_kP8Qi6bzg',
      origin: 'https://webauthn.io',
    },
  );
});