From 2fc9d17bf1f0d1e5f333c4fd5cdec96c9f858f37 Mon Sep 17 00:00:00 2001 From: Kajetan Kazimierczak Date: Sat, 27 Feb 2021 00:01:03 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20f=C3=B6r=20Stockholms=20nedst=C3=A4ngning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api.ts | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/api.ts b/lib/api.ts index c95ac63a3..b2b201114 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -114,8 +114,43 @@ export class Api extends EventEmitter { async getChildren(): Promise { if (this.isFake) return fakeResponse(fake.children()) + //-------- + const cdnUrl = 'https://etjanst.stockholm.se/vardnadshavare/base/cdn' + const authUrl = 'https://etjanst.stockholm.se/vardnadshavare/base/auth' + const cdnResponse = await this.fetch('cdn_', cdnUrl, this.session) + const cdn = await cdnResponse.text() + + const authResponse = await this.fetch('auth_', authUrl, this.session) + const auth = await authResponse.text() + + const rawResponse = await this.fetch('cdn2_', cdn, { + method: 'POST', + + headers: { + 'Accept': 'text/plain', + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'text/plain', + 'Cookie': this.getSessionCookie() + }, + body: auth + }) + const authData = await rawResponse.json(); + + const apiKey = 'QgBGAEYANgA1AEYAMABGAC0ARgA1AEIAQQAtADQANQA0ADEALQA5ADcAMQA3AC0ARQBBADMANQA0AEIAOQBCADgAMgA2AEQA' + const url = routes.children - const response = await this.fetch('children', url, this.session) + const response = await this.fetch('children', url, { + method: 'GET', + headers:{ + 'Accept': 'application/json;odata=verbose', + 'Auth': authData.token, + 'API-Key': apiKey, + 'Cookie': this.getSessionCookie(), + 'Host': 'etjanst.stockholm.se', + 'Referer': 'https://etjanst.stockholm.se/Vardnadshavare/inloggad2/hem' + } + }) + const data = await response.json() return parse.children(data) }