anastasis-core: salt rename, fix tagging
This commit is contained in:
parent
2c3aeabed1
commit
31b6496db5
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -274,13 +274,13 @@ export function ChallengeOverviewScreen(): VNode {
|
||||
Policy #{policy_index + 1}: {policyName}
|
||||
</h3>
|
||||
{policy.challenges.length === 0 && (
|
||||
<p>This policy doesn't have challenges.</p>
|
||||
<p>This policy doesn't have any challenges.</p>
|
||||
)}
|
||||
{policy.challenges.length === 1 && (
|
||||
<p>This policy just have one challenge.</p>
|
||||
<p>This policy has one challenge.</p>
|
||||
)}
|
||||
{policy.challenges.length > 1 && (
|
||||
<p>This policy have {policy.challenges.length} challenges.</p>
|
||||
<p>This policy has {policy.challenges.length} challenges.</p>
|
||||
)}
|
||||
{tableBody}
|
||||
</div>
|
||||
|
@ -44,10 +44,7 @@ export function AuthMethodEmailSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
) {
|
||||
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
<div>invalid state</div>
|
||||
|
@ -22,10 +22,7 @@ export function AuthMethodIbanSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
) {
|
||||
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
<div>invalid state</div>
|
||||
|
@ -43,10 +43,7 @@ export function AuthMethodPostSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
) {
|
||||
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
<div>invalid state</div>
|
||||
|
@ -22,10 +22,7 @@ export function AuthMethodQuestionSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
) {
|
||||
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
<div>invalid state</div>
|
||||
|
@ -44,10 +44,7 @@ export function AuthMethodSmsSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
) {
|
||||
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
<div>invalid state</div>
|
||||
|
@ -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 {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
) {
|
||||
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
<div>invalid state</div>
|
||||
@ -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<void> {
|
||||
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]}
|
||||
/>
|
||||
|
||||
<div
|
||||
@ -118,4 +117,3 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
</AnastasisClientFrame>
|
||||
);
|
||||
}
|
||||
// NKE8 VD857T X033X6RG WEGPYP6D70 Q7YE XN8D2 ZN79SCN 231B4QK0
|
||||
|
@ -23,8 +23,7 @@ export function AuthMethodVideoSolve({ id }: AuthMethodSolveProps): VNode {
|
||||
);
|
||||
}
|
||||
if (
|
||||
!reducer.currentReducerState ||
|
||||
reducer.currentReducerState.recovery_state === undefined
|
||||
reducer.currentReducerState?.reducer_type !== "recovery"
|
||||
) {
|
||||
return (
|
||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||
|
@ -14,55 +14,69 @@
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
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")
|
||||
}
|
||||
return Amounts.parseOrThrow("BTC:0.00000294");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user