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.
diff --git a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx
index 11001194a..c4047f0b3 100644
--- a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx
@@ -274,13 +274,13 @@ export function ChallengeOverviewScreen(): VNode {
Policy #{policy_index + 1}: {policyName}
{policy.challenges.length === 0 && (
-
This policy doesn't have challenges.
+ This policy doesn't have any challenges.
)}
{policy.challenges.length === 1 && (
- This policy just have one challenge.
+ This policy has one challenge.
)}
{policy.challenges.length > 1 && (
- This policy have {policy.challenges.length} challenges.
+ This policy has {policy.challenges.length} challenges.
)}
{tableBody}
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx
index 9ee52d8ed..4f7f21324 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx
@@ -44,10 +44,7 @@ export function AuthMethodEmailSolve({ id }: AuthMethodSolveProps): VNode {
);
}
- if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
- ) {
+ if (reducer.currentReducerState?.reducer_type !== "recovery") {
return (
invalid state
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx
index 3eea9c15f..b58952feb 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx
@@ -22,10 +22,7 @@ export function AuthMethodIbanSolve({ id }: AuthMethodSolveProps): VNode {
);
}
- if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
- ) {
+ if (reducer.currentReducerState?.reducer_type !== "recovery") {
return (
invalid state
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx
index 5f03437af..fcff0b498 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx
@@ -43,10 +43,7 @@ export function AuthMethodPostSolve({ id }: AuthMethodSolveProps): VNode {
);
}
- if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
- ) {
+ if (reducer.currentReducerState?.reducer_type !== "recovery") {
return (
invalid state
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
index f54f91d92..058efe009 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
@@ -22,10 +22,7 @@ export function AuthMethodQuestionSolve({ id }: AuthMethodSolveProps): VNode {
);
}
- if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
- ) {
+ if (reducer.currentReducerState?.reducer_type !== "recovery") {
return (
invalid state
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx
index 1fd4343ab..3b00f6f2a 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx
@@ -44,10 +44,7 @@ export function AuthMethodSmsSolve({ id }: AuthMethodSolveProps): VNode {
);
}
- if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
- ) {
+ if (reducer.currentReducerState?.reducer_type !== "recovery") {
return (
invalid state
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx
index bd31fd5bf..ce7b2e545 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx
@@ -12,7 +12,7 @@ import { SolveOverviewFeedbackDisplay } from "../SolveScreen";
import { AuthMethodSolveProps } from "./index";
export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
- const [answer, setAnswer] = useState("");
+ const [answerCode, setAnswerCode] = useState("");
const reducer = useAnastasisContext();
if (!reducer) {
@@ -22,10 +22,7 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
);
}
- if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
- ) {
+ if (reducer.currentReducerState?.reducer_type !== "recovery") {
return (
invalid state
@@ -72,11 +69,13 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
for (const ch of chArr) {
challenges[ch.uuid] = ch;
}
- const selectedChallenge = challenges[selectedUuid];
const feedback = challengeFeedback[selectedUuid];
async function onNext(): Promise {
- return reducer?.transition("solve_challenge", { answer });
+ console.log(`sending TOTP code '${answerCode}'`);
+ return reducer?.transition("solve_challenge", {
+ pin: Number.parseInt(answerCode),
+ });
}
function onCancel(): void {
reducer?.back();
@@ -96,7 +95,7 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
label="Answer"
onConfirm={onNext}
grabFocus
- bind={[answer, setAnswer]}
+ bind={[answerCode, setAnswerCode]}
/>
);
}
-// NKE8 VD857T X033X6RG WEGPYP6D70 Q7YE XN8D2 ZN79SCN 231B4QK0
diff --git a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx
index 021589198..e0ebdce76 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx
@@ -23,8 +23,7 @@ export function AuthMethodVideoSolve({ id }: AuthMethodSolveProps): VNode {
);
}
if (
- !reducer.currentReducerState ||
- reducer.currentReducerState.recovery_state === undefined
+ reducer.currentReducerState?.reducer_type !== "recovery"
) {
return (
diff --git a/packages/taler-util/src/bitcoin.ts b/packages/taler-util/src/bitcoin.ts
index 85a176dc6..cf9d52c40 100644
--- a/packages/taler-util/src/bitcoin.ts
+++ b/packages/taler-util/src/bitcoin.ts
@@ -14,55 +14,69 @@
GNU Taler; see the file COPYING. If not, see
*/
-import { AmountJson } from "."
-import { Amounts, } from "./amounts"
-import { getRandomBytes, decodeCrock, encodeCrock } from "./talerCrypto"
-import * as segwit from "./segwit_addr"
/**
*
* @author sebasjm
*/
+/**
+ * Imports.
+ */
+import { AmountJson, Amounts } from "./amounts.js";
+import { getRandomBytes, decodeCrock } from "./talerCrypto.js";
+import * as segwit from "./segwit_addr.js";
+
export interface SegwitAddrs {
- addr1: string,
- addr2: string,
+ addr1: string;
+ addr2: string;
}
-function buf2hex(buffer: Uint8Array) { // buffer is an ArrayBuffer
+function buf2hex(buffer: Uint8Array) {
+ // buffer is an ArrayBuffer
return [...new Uint8Array(buffer)]
- .map(x => x.toString(16).padStart(2, '0'))
- .join('');
+ .map((x) => x.toString(16).padStart(2, "0"))
+ .join("");
}
-export function generateFakeSegwitAddress(reservePub: string, addr: string): SegwitAddrs {
- const pub = decodeCrock(reservePub)
+export function generateFakeSegwitAddress(
+ reservePub: string,
+ addr: string,
+): SegwitAddrs {
+ const pub = decodeCrock(reservePub);
- const first_rnd = getRandomBytes(4)
- const second_rnd = new Uint8Array(first_rnd.length)
- second_rnd.set(first_rnd)
+ const first_rnd = getRandomBytes(4);
+ const second_rnd = new Uint8Array(first_rnd.length);
+ second_rnd.set(first_rnd);
- first_rnd[0] = first_rnd[0] & 0b0111_1111
- second_rnd[0] = second_rnd[0] | 0b1000_0000
+ first_rnd[0] = first_rnd[0] & 0b0111_1111;
+ second_rnd[0] = second_rnd[0] | 0b1000_0000;
- const first_part = new Uint8Array(first_rnd.length + pub.length / 2)
- first_part.set(first_rnd, 0)
- first_part.set(pub.subarray(0, 16), 4)
- const second_part = new Uint8Array(first_rnd.length + pub.length / 2)
- second_part.set(first_rnd, 0)
- second_part.set(pub.subarray(16), 4)
+ const first_part = new Uint8Array(first_rnd.length + pub.length / 2);
+ first_part.set(first_rnd, 0);
+ first_part.set(pub.subarray(0, 16), 4);
+ const second_part = new Uint8Array(first_rnd.length + pub.length / 2);
+ second_part.set(first_rnd, 0);
+ second_part.set(pub.subarray(16), 4);
- console.log(first_part.length, second_part.length)
+ console.log(first_part.length, second_part.length);
- const prefix = (addr[0] === 't' && addr[1] == 'b') ? "tb" : (addr[0] === 'b' && addr[1] == 'c' && addr[2] === 'r' && addr[3] == 't') ? 'bcrt' : (addr[0] === 'b' && addr[1] == 'c') ? 'bc' : undefined
- if (prefix === undefined) throw new Error('unknown bitcoin net')
+ const prefix =
+ addr[0] === "t" && addr[1] == "b"
+ ? "tb"
+ : addr[0] === "b" && addr[1] == "c" && addr[2] === "r" && addr[3] == "t"
+ ? "bcrt"
+ : addr[0] === "b" && addr[1] == "c"
+ ? "bc"
+ : undefined;
+ if (prefix === undefined) throw new Error("unknown bitcoin net");
return {
addr1: segwit.default.encode(prefix, 0, first_part),
addr2: segwit.default.encode(prefix, 0, second_part),
- }
+ };
}
// https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp
export function segwitMinAmount(): AmountJson {
- return Amounts.parseOrThrow("BTC:0.00000294")
-}
\ No newline at end of file
+ return Amounts.parseOrThrow("BTC:0.00000294");
+}