Skip to content

Commit

Permalink
fix(double-auth): use encode/decode
Browse files Browse the repository at this point in the history
read UTF-8 string instead of binary string
  • Loading branch information
Vexcited committed Aug 7, 2024
1 parent 3ae3bbb commit b5dddf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/double-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { decodeDoubleAuthChallenge } from "~/decoders/double-auth-challenge";
import { decodeDoubleAuth } from "~/decoders/double-auth";
import { Request } from "~/core/request";

import { btoa } from "js-base64";
import { encode } from "js-base64";

export async function initDoubleAuth (session: Session): Promise<DoubleAuthChallenge> {
if (!session.token)
Expand Down Expand Up @@ -31,7 +31,7 @@ export async function checkDoubleAuth (session: Session, answer: string): Promis
.addVersionURL()
.setToken(session.token)
.setFormData({
choix: btoa(answer)
choix: encode(answer)
});

const response = await request.send(session.fetcher);
Expand Down
6 changes: 3 additions & 3 deletions src/decoders/double-auth-challenge.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { DoubleAuthChallenge } from "~/models";
import { atob } from "js-base64";
import { decode } from "js-base64";

export function decodeDoubleAuthChallenge (challenge: any): DoubleAuthChallenge {
return {
question: atob(challenge.question),
answers: challenge.propositions.map(atob)
question: decode(challenge.question),
answers: challenge.propositions.map(decode)
};
}

0 comments on commit b5dddf0

Please sign in to comment.