summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/convertAAGUIDToString.ts
blob: 80dc63c82c0e11c7406aaf3f63659c2837462f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import uint8Array from './uint8Array';

/**
 * Convert the aaguid buffer in authData into a UUID string
 */
export function convertAAGUIDToString(aaguid: Uint8Array): string {
  // Raw Hex: adce000235bcc60a648b0b25f1f05503
  const hex = uint8Array.toHex(aaguid);

  const segments: string[] = [
    hex.slice(0, 8), // 8
    hex.slice(8, 12), // 4
    hex.slice(12, 16), // 4
    hex.slice(16, 20), // 4
    hex.slice(20, 32), // 8
  ];

  // Formatted: adce0002-35bc-c60a-648b-0b25f1f05503
  return segments.join('-');
}