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,
|
escrow_type: authMethod.type as any,
|
||||||
instructions: authMethod.instructions,
|
instructions: authMethod.instructions,
|
||||||
provider_salt: provider.provider_salt,
|
provider_salt: provider.provider_salt,
|
||||||
truth_salt: tm.master_salt,
|
question_salt: tm.master_salt,
|
||||||
truth_key: tm.truth_key,
|
truth_key: tm.truth_key,
|
||||||
url: meth.provider,
|
url: meth.provider,
|
||||||
uuid: tm.uuid,
|
uuid: tm.uuid,
|
||||||
@ -902,7 +902,7 @@ async function getResponseHash(
|
|||||||
respHash = await secureAnswerHash(
|
respHash = await secureAnswerHash(
|
||||||
solveRequest.answer,
|
solveRequest.answer,
|
||||||
truth.uuid,
|
truth.uuid,
|
||||||
truth.truth_salt,
|
truth.question_salt,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw Error("unsupported answer request");
|
throw Error("unsupported answer request");
|
||||||
@ -1074,7 +1074,9 @@ async function selectChallenge(
|
|||||||
|
|
||||||
const url = new URL(`/truth/${truth.uuid}/challenge`, truth.url);
|
const url = new URL(`/truth/${truth.uuid}/challenge`, truth.url);
|
||||||
|
|
||||||
if (truth.escrow_type === ChallengeType.Question) {
|
switch (truth.escrow_type) {
|
||||||
|
case ChallengeType.Question:
|
||||||
|
case ChallengeType.Totp: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
recovery_state: RecoveryStates.ChallengeSolving,
|
recovery_state: RecoveryStates.ChallengeSolving,
|
||||||
@ -1087,6 +1089,7 @@ async function selectChallenge(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const resp = await fetch(url.href, {
|
const resp = await fetch(url.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -1732,7 +1735,7 @@ export async function reduceAction(
|
|||||||
return {
|
return {
|
||||||
reducer_type: "error",
|
reducer_type: "error",
|
||||||
...e.errorJson,
|
...e.errorJson,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ export interface EscrowMethod {
|
|||||||
/**
|
/**
|
||||||
* Salt to hash the security question answer if applicable.
|
* Salt to hash the security question answer if applicable.
|
||||||
*/
|
*/
|
||||||
truth_salt: TruthSalt;
|
question_salt: TruthSalt;
|
||||||
|
|
||||||
// Salt from the provider to derive the user ID
|
// Salt from the provider to derive the user ID
|
||||||
// at this provider.
|
// at this provider.
|
||||||
|
@ -274,13 +274,13 @@ export function ChallengeOverviewScreen(): VNode {
|
|||||||
Policy #{policy_index + 1}: {policyName}
|
Policy #{policy_index + 1}: {policyName}
|
||||||
</h3>
|
</h3>
|
||||||
{policy.challenges.length === 0 && (
|
{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 && (
|
{policy.challenges.length === 1 && (
|
||||||
<p>This policy just have one challenge.</p>
|
<p>This policy has one challenge.</p>
|
||||||
)}
|
)}
|
||||||
{policy.challenges.length > 1 && (
|
{policy.challenges.length > 1 && (
|
||||||
<p>This policy have {policy.challenges.length} challenges.</p>
|
<p>This policy has {policy.challenges.length} challenges.</p>
|
||||||
)}
|
)}
|
||||||
{tableBody}
|
{tableBody}
|
||||||
</div>
|
</div>
|
||||||
|
@ -44,10 +44,7 @@ export function AuthMethodEmailSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||||
!reducer.currentReducerState ||
|
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
<div>invalid state</div>
|
<div>invalid state</div>
|
||||||
|
@ -22,10 +22,7 @@ export function AuthMethodIbanSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||||
!reducer.currentReducerState ||
|
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
<div>invalid state</div>
|
<div>invalid state</div>
|
||||||
|
@ -43,10 +43,7 @@ export function AuthMethodPostSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||||
!reducer.currentReducerState ||
|
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
<div>invalid state</div>
|
<div>invalid state</div>
|
||||||
|
@ -22,10 +22,7 @@ export function AuthMethodQuestionSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||||
!reducer.currentReducerState ||
|
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
<div>invalid state</div>
|
<div>invalid state</div>
|
||||||
|
@ -44,10 +44,7 @@ export function AuthMethodSmsSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||||
!reducer.currentReducerState ||
|
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
<div>invalid state</div>
|
<div>invalid state</div>
|
||||||
|
@ -12,7 +12,7 @@ import { SolveOverviewFeedbackDisplay } from "../SolveScreen";
|
|||||||
import { AuthMethodSolveProps } from "./index";
|
import { AuthMethodSolveProps } from "./index";
|
||||||
|
|
||||||
export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
||||||
const [answer, setAnswer] = useState("");
|
const [answerCode, setAnswerCode] = useState("");
|
||||||
|
|
||||||
const reducer = useAnastasisContext();
|
const reducer = useAnastasisContext();
|
||||||
if (!reducer) {
|
if (!reducer) {
|
||||||
@ -22,10 +22,7 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (reducer.currentReducerState?.reducer_type !== "recovery") {
|
||||||
!reducer.currentReducerState ||
|
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
<div>invalid state</div>
|
<div>invalid state</div>
|
||||||
@ -72,11 +69,13 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
for (const ch of chArr) {
|
for (const ch of chArr) {
|
||||||
challenges[ch.uuid] = ch;
|
challenges[ch.uuid] = ch;
|
||||||
}
|
}
|
||||||
const selectedChallenge = challenges[selectedUuid];
|
|
||||||
const feedback = challengeFeedback[selectedUuid];
|
const feedback = challengeFeedback[selectedUuid];
|
||||||
|
|
||||||
async function onNext(): Promise<void> {
|
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 {
|
function onCancel(): void {
|
||||||
reducer?.back();
|
reducer?.back();
|
||||||
@ -96,7 +95,7 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
label="Answer"
|
label="Answer"
|
||||||
onConfirm={onNext}
|
onConfirm={onNext}
|
||||||
grabFocus
|
grabFocus
|
||||||
bind={[answer, setAnswer]}
|
bind={[answerCode, setAnswerCode]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@ -118,4 +117,3 @@ export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
</AnastasisClientFrame>
|
</AnastasisClientFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// NKE8 VD857T X033X6RG WEGPYP6D70 Q7YE XN8D2 ZN79SCN 231B4QK0
|
|
||||||
|
@ -23,8 +23,7 @@ export function AuthMethodVideoSolve({ id }: AuthMethodSolveProps): VNode {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!reducer.currentReducerState ||
|
reducer.currentReducerState?.reducer_type !== "recovery"
|
||||||
reducer.currentReducerState.recovery_state === undefined
|
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<AnastasisClientFrame hideNav title="Recovery problem">
|
<AnastasisClientFrame hideNav title="Recovery problem">
|
||||||
|
@ -14,55 +14,69 @@
|
|||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
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
|
* @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 {
|
export interface SegwitAddrs {
|
||||||
addr1: string,
|
addr1: string;
|
||||||
addr2: string,
|
addr2: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buf2hex(buffer: Uint8Array) { // buffer is an ArrayBuffer
|
function buf2hex(buffer: Uint8Array) {
|
||||||
|
// buffer is an ArrayBuffer
|
||||||
return [...new Uint8Array(buffer)]
|
return [...new Uint8Array(buffer)]
|
||||||
.map(x => x.toString(16).padStart(2, '0'))
|
.map((x) => x.toString(16).padStart(2, "0"))
|
||||||
.join('');
|
.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateFakeSegwitAddress(reservePub: string, addr: string): SegwitAddrs {
|
export function generateFakeSegwitAddress(
|
||||||
const pub = decodeCrock(reservePub)
|
reservePub: string,
|
||||||
|
addr: string,
|
||||||
|
): SegwitAddrs {
|
||||||
|
const pub = decodeCrock(reservePub);
|
||||||
|
|
||||||
const first_rnd = getRandomBytes(4)
|
const first_rnd = getRandomBytes(4);
|
||||||
const second_rnd = new Uint8Array(first_rnd.length)
|
const second_rnd = new Uint8Array(first_rnd.length);
|
||||||
second_rnd.set(first_rnd)
|
second_rnd.set(first_rnd);
|
||||||
|
|
||||||
first_rnd[0] = first_rnd[0] & 0b0111_1111
|
first_rnd[0] = first_rnd[0] & 0b0111_1111;
|
||||||
second_rnd[0] = second_rnd[0] | 0b1000_0000
|
second_rnd[0] = second_rnd[0] | 0b1000_0000;
|
||||||
|
|
||||||
const first_part = new Uint8Array(first_rnd.length + pub.length / 2)
|
const first_part = new Uint8Array(first_rnd.length + pub.length / 2);
|
||||||
first_part.set(first_rnd, 0)
|
first_part.set(first_rnd, 0);
|
||||||
first_part.set(pub.subarray(0, 16), 4)
|
first_part.set(pub.subarray(0, 16), 4);
|
||||||
const second_part = new Uint8Array(first_rnd.length + pub.length / 2)
|
const second_part = new Uint8Array(first_rnd.length + pub.length / 2);
|
||||||
second_part.set(first_rnd, 0)
|
second_part.set(first_rnd, 0);
|
||||||
second_part.set(pub.subarray(16), 4)
|
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
|
const prefix =
|
||||||
if (prefix === undefined) throw new Error('unknown bitcoin net')
|
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 {
|
return {
|
||||||
addr1: segwit.default.encode(prefix, 0, first_part),
|
addr1: segwit.default.encode(prefix, 0, first_part),
|
||||||
addr2: segwit.default.encode(prefix, 0, second_part),
|
addr2: segwit.default.encode(prefix, 0, second_part),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp
|
// https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp
|
||||||
export function segwitMinAmount(): AmountJson {
|
export function segwitMinAmount(): AmountJson {
|
||||||
return Amounts.parseOrThrow("BTC:0.00000294")
|
return Amounts.parseOrThrow("BTC:0.00000294");
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user