浏览代码

Use the union

Manav Rathi 1 年之前
父节点
当前提交
41c87efc5a
共有 1 个文件被更改,包括 4 次插入10 次删除
  1. 4 10
      web/apps/auth/src/services/code.ts

+ 4 - 10
web/apps/auth/src/services/code.ts

@@ -2,13 +2,7 @@ import { URI } from "vscode-uri";
 
 
 type Type = "totp" | "TOTP" | "hotp" | "HOTP";
 type Type = "totp" | "TOTP" | "hotp" | "HOTP";
 
 
-type AlgorithmType =
-    | "sha1"
-    | "SHA1"
-    | "sha256"
-    | "SHA256"
-    | "sha512"
-    | "SHA512";
+type Algorithm = "sha1" | "sha256" | "sha512";
 
 
 export class Code {
 export class Code {
     // id for the corresponding auth entity
     // id for the corresponding auth entity
@@ -18,7 +12,7 @@ export class Code {
     digits: number;
     digits: number;
     period: number;
     period: number;
     secret: string;
     secret: string;
-    algorithm: AlgorithmType;
+    algorithm: Algorithm;
     type: Type;
     type: Type;
     rawData?: string;
     rawData?: string;
 
 
@@ -28,7 +22,7 @@ export class Code {
         digits: number | undefined,
         digits: number | undefined,
         period: number,
         period: number,
         secret: string,
         secret: string,
-        algorithm: AlgorithmType,
+        algorithm: Algorithm,
         type: Type,
         type: Type,
         rawData?: string,
         rawData?: string,
         id?: string,
         id?: string,
@@ -133,7 +127,7 @@ const parseDigits = (uriParams): number =>
 const parsePeriod = (uriParams): number =>
 const parsePeriod = (uriParams): number =>
     parseInt(uriParams["period"] ?? "", 10) || 30;
     parseInt(uriParams["period"] ?? "", 10) || 30;
 
 
-const parseAlgorithm = (uriParams): AlgorithmType => {
+const parseAlgorithm = (uriParams): Algorithm => {
     switch (uriParams["algorithm"]?.toLowerCase()) {
     switch (uriParams["algorithm"]?.toLowerCase()) {
         case "sha256":
         case "sha256":
             return "sha256";
             return "sha256";