Compare commits

...

3 Commits

Author SHA1 Message Date
Christian Landgren 0ff5fad4d9 fix: try to get callback auth to work 2023-09-15 14:59:58 +02:00
Christian Landgren 23f81cf113 aider: Updated React Native version to 0.67.3 in package.json.
# Aider chat conversation:

USER: help me upgrade react native to a version compatible with the rest of the dependencies

ASSISTANT: Sure, I can guide you through the process of upgrading React Native to a version compatible with the rest of your dependencies. However, I need to know the current version of React Native you're using and the versions of the other dependencies in your project.

Please share your `package.json` file. This file contains the list of dependencies and their versions.

Once you've shared the `package.json` file, I can provide you with the steps to upgrade React Native.

USER: I added these *read-write* files: package.json

ASSISTANT: Thank you for providing the `package.json` file.

From the provided `package.json` file, I can see that the current version of React Native in your project is `0.66.4`.

To upgrade React Native, you can use the `react-native upgrade` command which will automatically upgrade your project to the latest version. However, this command might not always work as expected, especially for major version upgrades.

Alternatively, you can manually update the version of React Native in your `package.json` file and then run `yarn install` or `npm install` to install the new version.

Here's how you can manually upgrade React Native to version `0.67.3` (the latest stable version at the time of writing):

```json
package.json
<<<<<<< HEAD
    "react-native": "0.66.4",
=======
    "react-native": "0.67.3",
>>>>>>> updated
```

After updating the `package.json` file, run `yarn install` or `npm install` to install the new version of React Native.

Please note that upgrading React Native might require you to make additional changes to your native iOS and Android projects. You can refer to the [React Native Upgrade Guide](https://react-native-community.github.io/upgrade-helper/) for detailed instructions on how to upgrade your project.

Also, remember to test your application thoroughly after the upgrade to ensure that everything still works as expected.
2023-09-15 09:12:54 +02:00
Christian Landgren 3b7942ac1a Added .aider* to .gitignore. 2023-09-15 09:11:29 +02:00
7 changed files with 49 additions and 42 deletions

1
.gitignore vendored
View File

@ -110,3 +110,4 @@ xcshareddata
xcuserdata
/.vs
*.hprof
.aider*

View File

@ -36,18 +36,9 @@ async function run() {
api.on('login', async () => {
console.log('Logged in')
if (bankIdUsed) {
const sessionCookie = getSessionCookieFromCookieJar()
ensureDirectoryExistence(recordFolder)
await writeFile(
`${recordFolder}/latestSessionCookie.txt`,
JSON.stringify(sessionCookie)
)
console.log(
`Session cookie saved to file ${recordFolder}/latesSessionCookie.txt`
)
}
console.log('user') //-
const cookies = cookieJar.toJSON()
console.log('cookies', cookies)
const user = await api.getUser()
console.log(user)

View File

@ -33,6 +33,7 @@ import {
bankIdInitUrl,
bankIdCheckUrl,
bankIdSessionUrl,
bankIdCallbackUrl,
apiUrls,
} from './routes'
import parse from '@skolplattformen/curriculum'
@ -127,20 +128,26 @@ export class ApiAdmentum extends EventEmitter implements Api {
}
async setSessionCookie(sessionCookie: string): Promise<void> {
// this.cookieManager.setCookieString(sessionCookie, admentumUrl)
if (!sessionCookie) throw Error('cookie required')
this.cookieManager.setCookieString(
`sessionid=${sessionCookie}; Path=/;`,
'skola.admentum.se'
)
const user = await this.getUser()
if (!user.isAuthenticated) {
throw new Error('Session cookie is expired')
}
this.isLoggedIn = true
this.emit('login')
}
async getUser(): Promise<User> {
console.log('fetching user')
const currentUserResponse = await this.fetch('current-user', apiUrls.users) // + /id?
const userId = '437302'
const currentUserResponse = await this.fetch(
'current-user',
apiUrls.user(userId)
) // + /id?
console.log('current-user', currentUserResponse)
if (currentUserResponse.status !== 200) {
return { isAuthenticated: false }
}
@ -312,10 +319,9 @@ export class ApiAdmentum extends EventEmitter implements Api {
const statusChecker = checkStatus(this.fetch, bankIdCheckUrl(sessionId))
statusChecker.on('OK', async () => {
// setting these similar to how the sthlm api does it
// not sure if it is needed or if the cookies are enough for fetching all info...
this.isLoggedIn = true
this.personalNumber = personalNumber
this.setSessionCookie(sessionId)
this.emit('login')
})
statusChecker.on('ERROR', () => {

View File

@ -40,7 +40,8 @@ export const apiUrls = {
subjects: baseUrl + 'subjects',
teachers: baseUrl + 'teachers',
upper_secondary_subjects: baseUrl + 'upper_secondary_subjects',
users: baseUrl + 'users',
users: baseUrl + 'users?format=json',
user: (userId: string) => baseUrl + `users/${userId}/?format=json`,
}
export const bankIdCheckUrl = (sessionId: string) =>
@ -51,3 +52,6 @@ export const bankIdSessionUrl = (returnUrl: string) =>
export const bankIdInitUrl = (sessionId: string) =>
`https://login.grandid.com/?sessionid=${sessionId}&eleg=1&bankid=1&bChoice=other`
export const bankIdCallbackUrl = (grandSessionId: string) =>
`https://auth.admentum.se/larande/callback?grandidsession=${grandSessionId}`

View File

@ -88,8 +88,6 @@ export interface Classmate {
guardians: Guardian[]
}
export interface Fetch {
(url: string, init?: RequestInit): Promise<Response>
}
@ -146,9 +144,9 @@ export interface RequestInit {
/**
* Set to `manual` to extract redirect headers, `error` to reject redirect */
redirect?: string
follow?: number // how many redirects should we allow to follow?
}
/**
* @export
* @interface ScheduleItem
@ -215,7 +213,7 @@ export interface TimetableEntry extends Subject {
dateEnd: string
}
export interface Teacher {
export interface Teacher {
id: number
sisId: string
firstname: string

View File

@ -53,7 +53,7 @@
"personnummer": "^3.1.4",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.66.4",
"react-native": "0.67.3",
"react-native-animatable": "^1.3.3",
"react-native-async-storage": "^0.0.1",
"react-native-calendar-events": "2.2.0",

View File

@ -2236,10 +2236,10 @@
resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e"
integrity sha512-KrwSpS1tKI70wuKl68DwJZYEvXktDHdZMG0k2AXD/rJVSlB23/X2CB2cutVR0HwNMJIal9HOUOBB2rVfa6UGtQ==
"@react-native/normalize-color@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@react-native/normalize-color/-/normalize-color-1.0.0.tgz#c52a99d4fe01049102d47dc45d40cbde4f720ab6"
integrity sha512-xUNRvNmCl3UGCPbbHvfyFMnpvLPoOjDCcp5bT9m2k+TF/ZBklEQwhPZlkrxRx2NhgFh1X3a5uL7mJ7ZR+8G7Qg==
"@react-native/normalize-color@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@react-native/normalize-color/-/normalize-color-2.0.0.tgz#da955909432474a9a0fe1cbffc66576a0447f567"
integrity sha512-Wip/xsc5lw8vsBlmY2MO/gFLp3MvuZ2baBZjDeTjjndMgM0h5sxz7AZR62RDPGgstp8Np7JzjvVqVT7tpFZqsw==
"@react-native/polyfills@2.0.0":
version "2.0.0"
@ -10924,7 +10924,15 @@ raw-loader@^4.0.2:
loader-utils "^2.0.0"
schema-utils "^3.0.0"
react-devtools-core@^4.13.0, react-devtools-core@^4.19.1:
react-devtools-core@4.19.1:
version "4.19.1"
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.19.1.tgz#bc37c2ef2f48f28c6af4c7292be9dca1b63deace"
integrity sha512-2wJiGffPWK0KggBjVwnTaAk+Z3MSxKInHmdzPTrBh1mAarexsa93Kw+WMX88+XjN+TtYgAiLe9xeTqcO5FfJTw==
dependencies:
shell-quote "^1.6.1"
ws "^7"
react-devtools-core@^4.19.1:
version "4.21.0"
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.21.0.tgz#a54c9a0fd7261491e616d6c87d1869e011d8521d"
integrity sha512-clGWwJHV5MHwTwYyKc+7FZHwzdbzrD2/AoZSkicUcr6YLc3Za9a9FaLhccWDHfjQ+ron9yzNhDT6Tv+FiPkD3g==
@ -10990,10 +10998,10 @@ react-native-clean-project@^3.6.7:
resolved "https://registry.yarnpkg.com/react-native-clean-project/-/react-native-clean-project-3.6.7.tgz#6d22ad22fe3a1e6efdb040eb66f9bdfb2273ac2e"
integrity sha512-GSJG1oNRJKtINPMzfHgRmu7HJs7phwgtwQ6GvyGARiySqQlU/bAc5zsI9rOeNPGlpgYongQtjOGdmqSpsWMJTw==
react-native-codegen@^0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/react-native-codegen/-/react-native-codegen-0.0.7.tgz#86651c5c5fec67a8077ef7f4e36f7ed459043e14"
integrity sha512-dwNgR8zJ3ALr480QnAmpTiqvFo+rDtq6V5oCggKhYFlRjzOmVSFn3YD41u8ltvKS5G2nQ8gCs2vReFFnRGLYng==
react-native-codegen@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/react-native-codegen/-/react-native-codegen-0.0.8.tgz#b7796a54074139d956fff2862cf1285db43c891b"
integrity sha512-k/944+0XD+8l7zDaiKfYabyEKmAmyZgS1mj+4LcSRPyHnrjgCHKrh/Y6jM6kucQ6xU1+1uyMmF/dSkikxK8i+Q==
dependencies:
flow-parser "^0.121.0"
jscodeshift "^0.11.0"
@ -11126,17 +11134,17 @@ react-native-webview@^11.15.0:
escape-string-regexp "2.0.0"
invariant "2.2.4"
react-native@0.66.4:
version "0.66.4"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.66.4.tgz#bf89a5fb18bd23046d889fb4de4ea2822a4d7805"
integrity sha512-9vx5dlSfQlKbbDtr8+xMon6qsmSu7jvjdXWZpEKh3XVKpUidbbODv7048gwVKX8YAel1egeR7hN8vzSeI6ssTw==
react-native@0.67.3:
version "0.67.3"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.67.3.tgz#ee8bafb644afbe511a4a2c8e9c144a9720d06dd8"
integrity sha512-epMVRMRH7dLCis97+YwiV4dmTVZO6qKmQgwcTNcxVt/kEMxAa+OYK7h81+99/n7XCeMFk/U2zYOBuQqc7c5Amg==
dependencies:
"@jest/create-cache-key-function" "^27.0.1"
"@react-native-community/cli" "^6.0.0"
"@react-native-community/cli-platform-android" "^6.0.0"
"@react-native-community/cli-platform-ios" "^6.0.0"
"@react-native/assets" "1.0.0"
"@react-native/normalize-color" "1.0.0"
"@react-native/normalize-color" "2.0.0"
"@react-native/polyfills" "2.0.0"
abort-controller "^3.0.0"
anser "^1.4.9"
@ -11145,7 +11153,6 @@ react-native@0.66.4:
hermes-engine "~0.9.0"
invariant "^2.2.4"
jsc-android "^250230.2.1"
metro-babel-register "0.66.2"
metro-react-native-babel-transformer "0.66.2"
metro-runtime "0.66.2"
metro-source-map "0.66.2"
@ -11153,8 +11160,8 @@ react-native@0.66.4:
pretty-format "^26.5.2"
promise "^8.0.3"
prop-types "^15.7.2"
react-devtools-core "^4.13.0"
react-native-codegen "^0.0.7"
react-devtools-core "4.19.1"
react-native-codegen "^0.0.8"
react-refresh "^0.4.0"
regenerator-runtime "^0.13.2"
scheduler "^0.20.2"