MCPcopy Index your code
hub / github.com/Tatamo/atcoder-cli / getCSRFToken

Method getCSRFToken

src/atcoder.ts:105–115  ·  view source on GitHub ↗

* ログインページにアクセスしてCSRFトークンを取得

()

Source from the content-addressed store, hash-verified

103 * ログインページにアクセスしてCSRFトークンを取得
104 */
105 private async getCSRFToken(): Promise<{ csrf_token: string }> {
106 const {JSDOM} = await import("jsdom");
107 // cookieなしでログインページにアクセス
108 const response = await this.session.get(AtCoder.login_url, {headers: {Cookie: ""}});
109
110 const {document} = new JSDOM(response.data).window;
111 const input: HTMLInputElement = (document.getElementsByName("csrf_token")[0]) as HTMLInputElement;
112
113 await response.saveSession();
114 return {csrf_token: input.value};
115 }
116
117 async logout(): Promise<void> {
118 await this.session.removeSession();

Callers 1

loginMethod · 0.95

Calls 2

getMethod · 0.65
saveSessionMethod · 0.65

Tested by

no test coverage detected