From 41c87efc5ad51ddb432d8554a6fb6a63fd91f0d7 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 23 May 2024 13:07:33 +0530 Subject: [PATCH] Use the union --- web/apps/auth/src/services/code.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/web/apps/auth/src/services/code.ts b/web/apps/auth/src/services/code.ts index 8e30a7f16..4fe134835 100644 --- a/web/apps/auth/src/services/code.ts +++ b/web/apps/auth/src/services/code.ts @@ -2,13 +2,7 @@ import { URI } from "vscode-uri"; type Type = "totp" | "TOTP" | "hotp" | "HOTP"; -type AlgorithmType = - | "sha1" - | "SHA1" - | "sha256" - | "SHA256" - | "sha512" - | "SHA512"; +type Algorithm = "sha1" | "sha256" | "sha512"; export class Code { // id for the corresponding auth entity @@ -18,7 +12,7 @@ export class Code { digits: number; period: number; secret: string; - algorithm: AlgorithmType; + algorithm: Algorithm; type: Type; rawData?: string; @@ -28,7 +22,7 @@ export class Code { digits: number | undefined, period: number, secret: string, - algorithm: AlgorithmType, + algorithm: Algorithm, type: Type, rawData?: string, id?: string, @@ -133,7 +127,7 @@ const parseDigits = (uriParams): number => const parsePeriod = (uriParams): number => parseInt(uriParams["period"] ?? "", 10) || 30; -const parseAlgorithm = (uriParams): AlgorithmType => { +const parseAlgorithm = (uriParams): Algorithm => { switch (uriParams["algorithm"]?.toLowerCase()) { case "sha256": return "sha256";