From 65b4b4dfea2796bb0aa080898ee60edaf8981ecc Mon Sep 17 00:00:00 2001 From: Thomas Queste Date: Tue, 3 Oct 2023 09:00:21 +0200 Subject: [PATCH] feat: authenticate --- bun.lockb | Bin 108214 -> 111620 bytes package.json | 3 +++ src/loans.ts | 51 ++++++++++++++++++++++++++++++++++++++++----------- src/test.ts | 15 +++++++++++++++ 4 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 src/test.ts diff --git a/bun.lockb b/bun.lockb index e4c6d7df775f115fbdcd53678b2f2e6055800321..782352ab8080dad22138cf812eb26f57650d507b 100755 GIT binary patch delta 27610 zcmeHwd3;Rg`}Uk^hKvY7kPwpCgMwNF=c&mKj?WwLUm#t*xT= zy$P`tEp2Jl*B5QI)fGk2s--ROb)AJ&>94={eYOAed|bKDbwAsE-_LTMnVdX!9xFEK zLb2H)K@;{>Z8o**&ZCP=_rIge#K%k zc|f0@Iy5yiDLeZXI1R|v<%VLKf#%|xA(^`VWpFR#n+Zunr?_k7o`qyPVW@<%Hn@|X z9fYDHe;$0*+jgpo1o=?BATP&ZV@dfVx8WJ;Gl3PD=0)M{Z`8BPS=-k#!S!SV3-5x*Fq4$V{G@Iv^*@;V^vx zPD8&!Ym8L?tfXWI!u>4zf%@f;H0%Z>)6-I&**RHZCR5hH0m-P_G`*~rv3fa88j5N2Vd98tQsE>{ehh&4PkW4=fL&+V^QI6y! zG<>dt$%L}5M=Lx5Jqs9-IIQzMkgQ-6BpX--Ne_?f6(^@8r42#7DZ{ge0E^yD$GcwXVW2BF$Z0GYIe@x?2MsJkjDu<4as(-k8os}OgAfQ4f|Hr zx?mG(<7oE?)VeUtU(*lD$Q*#;rmvBYh6X{;`csm!sdk#Ys%Z%WGqQpmNy#a_^n&*> z7nyMZ3c@+p@&K)3zZxbJqU+iK$@FP@g-gIW$Xjss9^Z`$QILxdw5Q2 zTDEBda;uhO#IeGm;2fNtA-OcSf~29dOj=|d*=eambI=WuT7{)_`3@u_mgX2S6j@D$ zx_+@PU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jv>w(j`WejEV-H^sKQ6#ULv3FXWfL2<+i)S$9S); zKEB}H;wSo+h1qejZ-+f^kM*~Hpk<8rHtC9eXHF}K`?#y2yWdc07rNrE@ism#Kkj0+ zo+K`wcPSTt(^XB69N^rMdyfh398@~<@oF2+R@1#O)=Rcx2y~410_*)J+ijk*<^9tb zn<{&Lk~U|6)nBHj;Y*b8FyrdW{<1aMk4h&^h{FZB4yS z@5s6Ihi=b*SidX6%G|2&`X67EeaZj; diff --git a/package.json b/package.json index b3ad55e..31db37c 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "module": "src/main.ts", "devDependencies": { "@tsconfig/node18": "^18.2.2", + "@types/tough-cookie": "^4.0.3", "@typescript-eslint/eslint-plugin": "^6.7.2", "@typescript-eslint/parser": "^6.7.2", "bun-types": "^1.0.2", @@ -44,6 +45,8 @@ }, "dependencies": { "fp-ts": "^2.16.1", + "http-cookie-agent": "^5.0.4", + "tough-cookie": "^4.1.3", "undici": "^5.25.3" } } diff --git a/src/loans.ts b/src/loans.ts index 3adab57..aab27e3 100644 --- a/src/loans.ts +++ b/src/loans.ts @@ -1,6 +1,8 @@ import { pipe } from "fp-ts/function"; import * as TE from "fp-ts/TaskEither"; -import { Dispatcher, request } from "undici"; +import { CookieAgent } from "http-cookie-agent/undici"; +import { CookieJar } from "tough-cookie"; +import { Dispatcher, FormData, request } from "undici"; // type Loans = { // username: string; @@ -10,15 +12,42 @@ import { Dispatcher, request } from "undici"; // } export const listLoans = (): TE.TaskEither => { - const post = (url: string) => - TE.tryCatch( - () => request(url), - (reason) => new Error(`Unable to fetch loans: ${String(reason)}`), - ); - const parseJson = TE.tryCatchK( - (resp) => resp.body.text(), - (reason) => new Error(`Unable to : ${String(reason)}`), + return pipe( + authenticate( + "http://www.mediathequederoubaix.fr", + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + process.env.USERNAME!, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + process.env.PASSWORD!, + ), + TE.chain(getText), ); - - return pipe(post("http://www.mediathequederoubaix.fr"), TE.chain(parseJson)); }; + +const authenticate = (url: string, user: string, pass: string) => + TE.tryCatch( + () => { + const cookieJar = new CookieJar(); + const agent = new CookieAgent({ cookies: { jar: cookieJar } }); + + const data = new FormData(); + data.set("name", user); + data.set("pass", pass); + data.set("form_id", "user_login"); + + return request(url, { + method: "POST", + body: data, + dispatcher: agent, + }); + }, + (reason) => new Error(`Unable to authenticate: ${String(reason)}`), + ); +const getText = TE.tryCatchK( + async (resp) => { + const text = await resp.body.text(); + console.log("text", text); + return text; + }, + (reason) => new Error(`Unable to : ${String(reason)}`), +); diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000..9988220 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,15 @@ +import { FormData, request } from "undici"; + +const data = new FormData(); +data.set("name", "X0002412030"); +data.set("pass", "03/11/1980"); +data.set("form_id", "user_login"); + +const resp = await request("http://www.mediathequederoubaix.fr", { + method: "POST", + body: data, +}); + +const text = await resp.body.text(); + +console.log("text", text);