diff --git a/src/iksm.ts b/src/iksm.ts index 87c6560..21a50b8 100644 --- a/src/iksm.ts +++ b/src/iksm.ts @@ -318,7 +318,7 @@ async function getSessionToken({ }): Promise { 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 = { diff --git a/src/utils.ts b/src/utils.ts index 0bbd6ed..d35e438 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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("-", "+"), ); }