summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/convertAAGUIDToString.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-06-20 12:24:50 -0700
committerMatthew Miller <matthew@millerti.me>2020-06-20 12:24:50 -0700
commitc46154bd28805c4c597c7aa49e975c220a43a02a (patch)
treea5f281a4f39a595e2c5c2386613cc5b99bb01e66 /packages/server/src/helpers/convertAAGUIDToString.ts
parent3b913114f69e0a7bbe28cbabbec420500a9f3732 (diff)
Add helper for converting aaguid to UUID string
Diffstat (limited to 'packages/server/src/helpers/convertAAGUIDToString.ts')
-rw-r--r--packages/server/src/helpers/convertAAGUIDToString.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/server/src/helpers/convertAAGUIDToString.ts b/packages/server/src/helpers/convertAAGUIDToString.ts
new file mode 100644
index 0000000..36e251b
--- /dev/null
+++ b/packages/server/src/helpers/convertAAGUIDToString.ts
@@ -0,0 +1,18 @@
+/**
+ * Convert the aaguid buffer in authData into a UUID string
+ */
+export default function convertAAGUIDToString(aaguid: Buffer): string {
+ // Raw Hex: adce000235bcc60a648b0b25f1f05503
+ const hex = aaguid.toString('hex');
+
+ 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('-');
+}