From 31b6496db502b302e5a33597723ed847a83fe63e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 13 Apr 2022 13:16:35 +0200 Subject: anastasis-core: salt rename, fix tagging --- packages/anastasis-core/src/index.ts | 31 ++++++++++++---------- .../anastasis-core/src/recovery-document-types.ts | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'packages/anastasis-core') diff --git a/packages/anastasis-core/src/index.ts b/packages/anastasis-core/src/index.ts index 52cb33f5a..68ecc5173 100644 --- a/packages/anastasis-core/src/index.ts +++ b/packages/anastasis-core/src/index.ts @@ -458,7 +458,7 @@ async function prepareRecoveryData( escrow_type: authMethod.type as any, instructions: authMethod.instructions, provider_salt: provider.provider_salt, - truth_salt: tm.master_salt, + question_salt: tm.master_salt, truth_key: tm.truth_key, url: meth.provider, uuid: tm.uuid, @@ -902,7 +902,7 @@ async function getResponseHash( respHash = await secureAnswerHash( solveRequest.answer, truth.uuid, - truth.truth_salt, + truth.question_salt, ); } else { throw Error("unsupported answer request"); @@ -1074,18 +1074,21 @@ async function selectChallenge( const url = new URL(`/truth/${truth.uuid}/challenge`, truth.url); - if (truth.escrow_type === ChallengeType.Question) { - return { - ...state, - recovery_state: RecoveryStates.ChallengeSolving, - selected_challenge_uuid: truth.uuid, - challenge_feedback: { - ...state.challenge_feedback, - [truth.uuid]: { - state: ChallengeFeedbackStatus.Pending, + switch (truth.escrow_type) { + case ChallengeType.Question: + case ChallengeType.Totp: { + return { + ...state, + recovery_state: RecoveryStates.ChallengeSolving, + selected_challenge_uuid: truth.uuid, + challenge_feedback: { + ...state.challenge_feedback, + [truth.uuid]: { + state: ChallengeFeedbackStatus.Pending, + }, }, - }, - }; + }; + } } const resp = await fetch(url.href, { @@ -1732,7 +1735,7 @@ export async function reduceAction( return { reducer_type: "error", ...e.errorJson, - } + }; } throw e; } diff --git a/packages/anastasis-core/src/recovery-document-types.ts b/packages/anastasis-core/src/recovery-document-types.ts index 3dc4481ff..f94aa1916 100644 --- a/packages/anastasis-core/src/recovery-document-types.ts +++ b/packages/anastasis-core/src/recovery-document-types.ts @@ -82,7 +82,7 @@ export interface EscrowMethod { /** * Salt to hash the security question answer if applicable. */ - truth_salt: TruthSalt; + question_salt: TruthSalt; // Salt from the provider to derive the user ID // at this provider. -- cgit v1.2.3