diff --git a/package-lock.json b/package-lock.json index 0de1045b..313aadb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,7 +85,7 @@ "scolengo-api": "^3.0.5", "text-encoding": "^0.7.0", "turbawself": "^1.1.1", - "uphf-api": "^2.1.3", + "uphf-api": "^2.2.0", "zustand": "^4.5.2" }, "devDependencies": { @@ -10572,6 +10572,16 @@ "node": "*" } }, + "node_modules/fetch-cookie": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-3.0.1.tgz", + "integrity": "sha512-ZGXe8Y5Z/1FWqQ9q/CrJhkUD73DyBU9VF0hBQmEO/wPHe4A9PKTjplFDLeFX8aOsYypZUcX5Ji/eByn3VCVO3Q==", + "license": "Unlicense", + "dependencies": { + "set-cookie-parser": "^2.4.8", + "tough-cookie": "^4.0.0" + } + }, "node_modules/fetch-retry": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/fetch-retry/-/fetch-retry-4.1.1.tgz", @@ -15127,6 +15137,12 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "license": "MIT" }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", + "license": "MIT" + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -15349,6 +15365,12 @@ "node": ">=0.4.x" } }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "license": "MIT" + }, "node_modules/queue": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz", @@ -16097,6 +16119,12 @@ "path-parse": "^1.0.5" } }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "license": "MIT" + }, "node_modules/resolve": { "version": "2.0.0-next.5", "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.5.tgz", @@ -17397,6 +17425,30 @@ "node": ">=0.6" } }, + "node_modules/tough-cookie": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", + "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", + "license": "BSD-3-Clause", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tough-cookie/node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -17760,10 +17812,13 @@ } }, "node_modules/uphf-api": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/uphf-api/-/uphf-api-2.1.3.tgz", - "integrity": "sha512-/zSB3Gflu/p/FX/ydaDm46kncW4gnxzo/7zTwNArTNfRNPyl91LB0Coqcj2Vpv7eQJGV4MPdpmiblif+HuhCoA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/uphf-api/-/uphf-api-2.2.0.tgz", + "integrity": "sha512-A/eTbmD5HHF2lREbdsnssYHNnUybMi+kozVpYxP6zYphlIQ7JC5mKWegzKHOD8G62f6+MokUZcckW4OstsWV0A==", "license": "GPL-3.0-only", + "dependencies": { + "fetch-cookie": "^3.0.1" + }, "engines": { "node": ">=18" } @@ -17805,6 +17860,16 @@ "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz", "integrity": "sha512-EGXjXJZhIHiQMK2pQukuFcL303nskqIRzWvPvV5O8miOfwoUb9G+a/Cld60kUyeaybEI94wvVClT10DtfeAExA==" }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "license": "MIT", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "node_modules/use-latest-callback": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/use-latest-callback/-/use-latest-callback-0.2.1.tgz", diff --git a/package.json b/package.json index f64e4f73..48371056 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "scolengo-api": "^3.0.5", "text-encoding": "^0.7.0", "turbawself": "^1.1.1", - "uphf-api": "^2.1.3", + "uphf-api": "^2.2.0", "zustand": "^4.5.2" }, "devDependencies": { diff --git a/src/services/uphf/default-personalization.ts b/src/services/uphf/default-personalization.ts index 91cf3d7c..cbe71c71 100644 --- a/src/services/uphf/default-personalization.ts +++ b/src/services/uphf/default-personalization.ts @@ -1,4 +1,4 @@ -import type { Personalization } from "@/stores/account/types"; +import type { Personalization, UphfAccount } from "@/stores/account/types"; import { defaultTabs } from "@/consts/DefaultTabs"; import type pronote from "pawnote"; @@ -10,10 +10,14 @@ const defaultUphfTabs = [ "News", ] as typeof defaultTabs[number]["tab"][]; -const defaultPersonalization = async (): Promise> => { +const defaultPersonalization = async (instance: UphfAccount["instance"]): Promise> => { + const profilePictureAsBase64 = await instance?.getProfilePictureAsBase64(); return { color: colors[0], magicEnabled: true, + profilePictureB64: (profilePictureAsBase64 !== null && profilePictureAsBase64 != "") + ? await profilePictureAsBase64 + : void 0, tabs: defaultTabs.filter(current => defaultUphfTabs.includes(current.tab)).map((tab, index) => ({ name: tab.tab, enabled: index <= 4 diff --git a/src/views/login/IdentityProvider/IdentityProviderSelector.tsx b/src/views/login/IdentityProvider/IdentityProviderSelector.tsx index 862225af..1fc04bc2 100644 --- a/src/views/login/IdentityProvider/IdentityProviderSelector.tsx +++ b/src/views/login/IdentityProvider/IdentityProviderSelector.tsx @@ -7,6 +7,16 @@ import { NativeItem, NativeList, NativeListHeader, NativeText } from "@/componen import { Info } from "lucide-react-native"; const IdentityProviderSelector: Screen<"IdentityProviderSelector"> = ({ navigation }) => { + const universityProviders = [ + { + name: "univ_uphf", + title: "Université Polytechnique Hauts-de-France", + description: "Utilisez votre compte UPHF pour vous connecter", + image: require("@/../assets/images/service_uphf.png"), + navigate: () => navigation.navigate("UnivUphf_Login"), + }, + ]; + const identityProviders = [ { name: "univ_rennes1", @@ -43,6 +53,23 @@ const IdentityProviderSelector: Screen<"IdentityProviderSelector"> = ({ navigati style={{ flex: 1 }} contentContainerStyle={{ padding: 16, paddingTop: 0 }} > + + + + {universityProviders.map((identityProvider) => ( + identityProvider.navigate()} + leading={} + > + {identityProvider.title} + + {identityProvider.description} + + + ))} + + diff --git a/src/views/login/IdentityProvider/providers/UnivUphf.tsx b/src/views/login/IdentityProvider/providers/UnivUphf.tsx index a7733a92..f38d8846 100644 --- a/src/views/login/IdentityProvider/providers/UnivUphf.tsx +++ b/src/views/login/IdentityProvider/providers/UnivUphf.tsx @@ -43,7 +43,7 @@ const UnivUphf_Login: Screen<"UnivUphf_Login"> = ({ navigation }) => { authentication: { refreshAuthToken: account.userData.refreshAuthToken, }, - personalization: await defaultPersonalization() + personalization: await defaultPersonalization(account), }; createStoredAccount(local_account);