fix: wrong cookie in fetcher
parent
597960df32
commit
1afdbd0bc6
1
deps.ts
1
deps.ts
|
|
@ -3,6 +3,7 @@ export {
|
||||||
CookieJar,
|
CookieJar,
|
||||||
wrapFetch,
|
wrapFetch,
|
||||||
} from "https://deno.land/x/another_cookiejar@v4.1.4/mod.ts";
|
} from "https://deno.land/x/another_cookiejar@v4.1.4/mod.ts";
|
||||||
|
export type { CookieOptions } from "https://deno.land/x/another_cookiejar@v4.1.4/mod.ts";
|
||||||
export * as base64 from "https://deno.land/std@0.160.0/encoding/base64.ts";
|
export * as base64 from "https://deno.land/std@0.160.0/encoding/base64.ts";
|
||||||
export * as flags from "https://deno.land/std@0.160.0/flags/mod.ts";
|
export * as flags from "https://deno.land/std@0.160.0/flags/mod.ts";
|
||||||
export * as io from "https://deno.land/std@0.160.0/io/mod.ts";
|
export * as io from "https://deno.land/std@0.160.0/io/mod.ts";
|
||||||
|
|
|
||||||
10
src/env.ts
10
src/env.ts
|
|
@ -1,4 +1,4 @@
|
||||||
import { CookieJar, wrapFetch } from "../deps.ts";
|
import { CookieJar, CookieOptions, wrapFetch } from "../deps.ts";
|
||||||
import { io } from "../deps.ts";
|
import { io } from "../deps.ts";
|
||||||
|
|
||||||
const stdinLines = io.readLines(Deno.stdin);
|
const stdinLines = io.readLines(Deno.stdin);
|
||||||
|
|
@ -30,7 +30,7 @@ export type Logger = {
|
||||||
export type Env = {
|
export type Env = {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
readline: () => Promise<string>;
|
readline: () => Promise<string>;
|
||||||
newFetcher: () => Fetcher;
|
newFetcher: (opts?: { cookies?: CookieOptions[] }) => Fetcher;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_ENV: Env = {
|
export const DEFAULT_ENV: Env = {
|
||||||
|
|
@ -41,8 +41,8 @@ export const DEFAULT_ENV: Env = {
|
||||||
error: console.error,
|
error: console.error,
|
||||||
},
|
},
|
||||||
readline,
|
readline,
|
||||||
newFetcher: () => {
|
newFetcher: ({ cookies } = {}) => {
|
||||||
const cookieJar = new CookieJar();
|
const cookieJar = new CookieJar(cookies);
|
||||||
const fetch = wrapFetch({ cookieJar });
|
const fetch = wrapFetch({ cookieJar });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -62,3 +62,5 @@ export const DEFAULT_ENV: Env = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type { CookieOptions };
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,13 @@ export async function getBulletToken(
|
||||||
env: Env;
|
env: Env;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const { post } = env.newFetcher();
|
const { post } = env.newFetcher({
|
||||||
|
cookies: [{
|
||||||
|
name: "_gtoken",
|
||||||
|
value: webServiceToken,
|
||||||
|
domain: "api.lp1.av5ja.srv.nintendo.net",
|
||||||
|
}],
|
||||||
|
});
|
||||||
const resp = await post({
|
const resp = await post({
|
||||||
url: "https://api.lp1.av5ja.srv.nintendo.net/api/bullet_tokens",
|
url: "https://api.lp1.av5ja.srv.nintendo.net/api/bullet_tokens",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -255,7 +261,6 @@ export async function getBulletToken(
|
||||||
"Accept": "*/*",
|
"Accept": "*/*",
|
||||||
"Origin": "https://api.lp1.av5ja.srv.nintendo.net",
|
"Origin": "https://api.lp1.av5ja.srv.nintendo.net",
|
||||||
"X-Requested-With": "com.nintendo.znca",
|
"X-Requested-With": "com.nintendo.znca",
|
||||||
"Cookie": `_gtoken=${webServiceToken}`,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue