fix: wrong base64 encode/decode. fix #4
parent
1c202e03fa
commit
4a02f6da8c
13
src/iksm.ts
13
src/iksm.ts
|
|
@ -318,7 +318,7 @@ async function getSessionToken({
|
|||
}): Promise<string | undefined> {
|
||||
const fetch = wrapFetch({ cookieJar });
|
||||
|
||||
const res = await fetch(
|
||||
const resp = await fetch(
|
||||
"https://accounts.nintendo.com/connect/1.0.0/api/session_token",
|
||||
{
|
||||
method: "POST",
|
||||
|
|
@ -338,8 +338,15 @@ async function getSessionToken({
|
|||
}),
|
||||
},
|
||||
);
|
||||
const resBody = await res.json();
|
||||
return resBody["session_token"];
|
||||
const json = await resp.json();
|
||||
if (json.error) {
|
||||
throw new APIError({
|
||||
response: resp,
|
||||
json,
|
||||
message: "Error getting session token",
|
||||
});
|
||||
}
|
||||
return json["session_token"];
|
||||
}
|
||||
|
||||
type IminkResponse = {
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ const stdinLines = io.readLines(Deno.stdin);
|
|||
|
||||
export function urlBase64Encode(data: ArrayBuffer) {
|
||||
return base64.encode(data)
|
||||
.replaceAll("+", "_")
|
||||
.replaceAll("/", "-")
|
||||
.replaceAll("+", "-")
|
||||
.replaceAll("/", "_")
|
||||
.replaceAll("=", "");
|
||||
}
|
||||
|
||||
export function urlBase64Decode(data: string) {
|
||||
return base64.decode(
|
||||
data
|
||||
.replaceAll("_", "+")
|
||||
.replaceAll("-", "/"),
|
||||
.replaceAll("_", "/")
|
||||
.replaceAll("-", "+"),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue