Make temporary change to highlight cookie issue
This commit is contained in:
parent
1aaaeb64e3
commit
826b7453c4
|
@ -21,7 +21,7 @@ import { darkTheme, lightTheme } from './design/themes'
|
|||
import useSettingsStorage from './hooks/useSettingsStorage'
|
||||
import { translations } from './utils/translation'
|
||||
|
||||
const apiSkolplattformen = initSkolplattformen(fetch, CookieManager)
|
||||
//const apiSkolplattformen = initSkolplattformen(fetch, CookieManager)
|
||||
const apiHjarntorget = initHjarntorget(fetch, CookieManager)
|
||||
|
||||
const reporter = __DEV__
|
||||
|
@ -70,7 +70,7 @@ export default () => {
|
|||
return (
|
||||
<SchoolPlatformProvider>
|
||||
<ApiProvider
|
||||
api={apiSkolplattformen}
|
||||
api={apiHjarntorget}
|
||||
storage={AsyncStorage}
|
||||
reporter={reporter}
|
||||
>
|
||||
|
|
|
@ -18,7 +18,7 @@ import { toMarkdown, Api, URLSearchParams, LoginStatusChecker, CalendarItem,
|
|||
Fetcher,
|
||||
FetcherOptions,
|
||||
wrap
|
||||
} from '@skolplattformen/api'
|
||||
} from '../../api/lib'
|
||||
import { checkStatus } from './loginStatus'
|
||||
import { extractMvghostRequestBody, parseCalendarItem } from './parse/parsers'
|
||||
import {
|
||||
|
@ -89,6 +89,7 @@ export class ApiHjarntorget extends EventEmitter implements Api {
|
|||
options?: FetcherOptions
|
||||
) {
|
||||
super()
|
||||
|
||||
this.fetch = wrap(fetch, options);
|
||||
this.realFetcher = this.fetch;
|
||||
this.cookieManager = cookieManager
|
||||
|
@ -427,7 +428,7 @@ export class ApiHjarntorget extends EventEmitter implements Api {
|
|||
}
|
||||
})
|
||||
|
||||
console.log("start polling")
|
||||
console.log("start polling", (beginBankIdResponse as any).url)
|
||||
|
||||
const statusChecker = checkStatus(this.fetch, verifyUrlBase((beginBankIdResponse as any).url))
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { ApiHjarntorget } from './apiHjarntorget'
|
||||
import { Api, FetcherOptions, Fetch, RNCookieManager,
|
||||
import { FetcherOptions } from '../../api/lib/fetcher'
|
||||
import { Fetch } from '../../api/lib/types'
|
||||
import { Api } from '../../api/lib/api'
|
||||
import { RNCookieManager,
|
||||
ToughCookieJar,
|
||||
wrapReactNativeCookieManager,
|
||||
wrapToughCookie } from '@skolplattformen/api'
|
||||
wrapToughCookie } from '../../api/lib/cookies'
|
||||
|
||||
const init = (
|
||||
fetchImpl: Fetch,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { EventEmitter } from 'events'
|
||||
import { LoginStatusChecker, Fetcher} from '@skolplattformen/api'
|
||||
import { LoginStatusChecker, Fetcher} from '../../api/lib'
|
||||
import {
|
||||
extractAuthGbgLoginRequestBody,
|
||||
extractHjarntorgetSAMLLogin
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as html from 'node-html-parser'
|
||||
import { decode } from 'he'
|
||||
import { CalendarItem } from '..'
|
||||
|
||||
// TODO: Move this into the parse folder and convert it to follow the pattern of other parsers (include tests).
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ function requestLogger(httpModule) {
|
|||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const { inspect } = require('util')
|
||||
const init = require('./dist/api-hjarntorget/lib').default
|
||||
const init = require('./dist/libs/api-hjarntorget/lib').default
|
||||
|
||||
const [, , personalNumber] = process.argv
|
||||
|
||||
|
@ -78,13 +78,13 @@ function requestLogger(httpModule) {
|
|||
|
||||
async function run() {
|
||||
const cookieJar = new CookieJar()
|
||||
const fetch = fetchCookie(nodeFetch, cookieJar)
|
||||
const fetch = nodeFetch //fetchCookie(nodeFetch, cookieJar)
|
||||
|
||||
try {
|
||||
const api = init(fetch, cookieJar, { record })
|
||||
console.log("inited...")
|
||||
|
||||
api.on('login', async () => {
|
||||
|
||||
console.log("Loged in!")
|
||||
await api.getUser()
|
||||
const children = await api.getChildren()
|
||||
|
|
|
@ -98,21 +98,28 @@ export interface RNCookieManager {
|
|||
export const wrapReactNativeCookieManager = (
|
||||
rnc: RNCookieManager
|
||||
): CookieManager => ({
|
||||
clearAll: () => rnc.clearAll().then(),
|
||||
clearAll: () => {
|
||||
console.log("clearAll")
|
||||
return rnc.clearAll().then()
|
||||
},
|
||||
getCookieString: async (url) => {
|
||||
const cookies = await rnc.get(url)
|
||||
console.log("getCookieString", url, cookies)
|
||||
return Object.values(cookies)
|
||||
.map((c) => `${c.name}=${c.value}`)
|
||||
.join('; ')
|
||||
},
|
||||
getCookies: async (url) => {
|
||||
const cookies = await rnc.get(url)
|
||||
console.log("getCookies", url, cookies)
|
||||
return Object.values(cookies)
|
||||
},
|
||||
setCookie: async (cookie, url) => {
|
||||
console.log("setting cookie", url, cookie)
|
||||
await rnc.setFromResponse(url, serialize(cookie))
|
||||
},
|
||||
setCookieString: async (cookieString, url) => {
|
||||
console.log("setting cookieString", url, cookieString)
|
||||
await rnc.setFromResponse(url, cookieString)
|
||||
},
|
||||
})
|
||||
|
|
|
@ -66,7 +66,6 @@ export default function wrap(
|
|||
},
|
||||
}
|
||||
const response = await fetch(url, config)
|
||||
|
||||
const wrapMethod = (res: Response, methodName: string): void => {
|
||||
// @ts-ignore
|
||||
const original = res[methodName].bind(res)
|
||||
|
|
Loading…
Reference in New Issue