π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move into the function
Manav Rathi99f47dc1ae3c
diff --git a/web/apps/auth/src/pages/auth.tsx b/web/apps/auth/src/pages/auth.tsxindex 02d32edc72..86015247e6 100644--- a/web/apps/auth/src/pages/auth.tsx+++ b/web/apps/auth/src/pages/auth.tsx@@ -179,7 +179,7 @@ const CodeDisplay: React.FC<CodeDisplay> = ({ codeInfo }) => {console.log({ codeInfo });const totp = new TOTP({secret: codeInfo.secret,- algorithm: codeInfo.algorithm ?? Code.defaultAlgo,+ algorithm: codeInfo.algorithm,period: codeInfo.period,digits: codeInfo.digits,});diff --git a/web/apps/auth/src/services/code.ts b/web/apps/auth/src/services/code.tsindex 226d8b7a72..b80c4b398f 100644--- a/web/apps/auth/src/services/code.ts+++ b/web/apps/auth/src/services/code.ts@@ -11,8 +11,6 @@ type AlgorithmType =| "SHA512";export class Code {- static readonly defaultAlgo = "sha1";-// id for the corresponding auth entityid?: String;account: string;@@ -81,8 +79,8 @@ export const codeFromRawData = (id: string, rawData: string): Code => {return new Code(_getAccount(uriPath),_getIssuer(uriPath, uriParams),- _getDigits(uriParams) || 6,- _getPeriod(uriParams) || 30,+ _getDigits(uriParams),+ _getPeriod(uriParams),getSanitizedSecret(uriParams),_getAlgorithm(uriParams),_getType(uriPath),@@ -129,23 +127,23 @@ const _getIssuer = (uriPath: string, uriParams: { get?: any }): string => {}};-const _getDigits = (uriParams): number | undefined => {+const _getDigits = (uriParams): number => {try {- return parseInt(uriParams["digits"], 10);- } catch (e) {- return undefined;+ return parseInt(uriParams["digits"], 10) || 6;+ } catch {+ return 6;}};-const _getPeriod = (uriParams): number | undefined => {+const _getPeriod = (uriParams): number => {try {- return parseInt(uriParams["period"], 10);- } catch (e) {- return undefined;+ return parseInt(uriParams["period"], 10) || 30;+ } catch {+ return 30;}};-const _getAlgorithm = (uriParams): AlgorithmType => {+const _getAlgorithm = (uriParams): AlgorithmType | undefined => {try {const algorithm = uriParams["algorithm"].toLowerCase();if (algorithm === "sha256") {