diff --git a/package-lock.json b/package-lock.json index 76839135..f10b3e4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,11 +16,12 @@ "@types/react-dom": "18.0.11", "class-validator": "^0.14.0", "classnames": "^2.3.2", + "crypto-random-string": "^5.0.0", "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", "form-data": "^4.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.44", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.47", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", @@ -1535,6 +1536,20 @@ "node": ">= 8" } }, + "node_modules/crypto-random-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-5.0.0.tgz", + "integrity": "sha512-KWjTXWwxFd6a94m5CdRGW/t82Tr8DoBc9dNnPCAbFI1EBweN6v1tv8y4Y1m7ndkp/nkIBRxUxAzpaBnR2k3bcQ==", + "dependencies": { + "type-fest": "^2.12.2" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/csstype": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", @@ -2551,6 +2566,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globals/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globalthis": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", @@ -3202,7 +3228,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#30c8ee50b872a8bc6bec0f5d8c4626d8f4490177", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#467b34a484adbd6dfa3fd6082bb7677f6178da51", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -4474,11 +4500,11 @@ } }, "node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", "engines": { - "node": ">=10" + "node": ">=12.20" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" diff --git a/package.json b/package.json index 8f6f84e7..9ebaabbc 100644 --- a/package.json +++ b/package.json @@ -18,11 +18,12 @@ "@types/react-dom": "18.0.11", "class-validator": "^0.14.0", "classnames": "^2.3.2", + "crypto-random-string": "^5.0.0", "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", "form-data": "^4.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.44", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.47", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts index 219e507c..db4f0e7f 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts @@ -1,7 +1,6 @@ import { File } from "le-coffre-resources/dist/SuperAdmin"; import BaseSuperAdmin from "../BaseSuperAdmin"; -import CryptoService from "@Front/Services/CryptoService/CryptoService"; // TODO Type get query params -> Where + inclue + orderby @@ -20,7 +19,6 @@ export default class Files extends BaseSuperAdmin { private static instance: Files; private readonly baseURl = this.namespaceUrl.concat("/files"); - private cryptoService: CryptoService = CryptoService.getInstance(); private constructor() { super(); } @@ -35,9 +33,6 @@ export default class Files extends BaseSuperAdmin { if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); try { const files = await this.getRequest(url); - files.forEach(async (file) => { - file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv); - }); return files; } catch (err) { this.onError(err); @@ -58,13 +53,17 @@ export default class Files extends BaseSuperAdmin { } } + public getUploadLink(uid: string): string { + return this.baseURl.concat(`/upload/${uid}`); + } + + public async getByUid(uid: string, q?: any): Promise { const url = new URL(this.baseURl.concat(`/${uid}`)); const query = { q }; if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); try { const file = await this.getRequest(url); - file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv); return file; } catch (err) { this.onError(err); diff --git a/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx b/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx index f6dbe5a2..938ebea7 100644 --- a/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx @@ -1,9 +1,9 @@ - -import React, { ReactNode } from "react"; -import classes from "./classes.module.scss"; import Header from "@Front/Components/DesignSystem/Header"; import Version from "@Front/Components/DesignSystem/Version"; import classNames from "classnames"; +import React, { ReactNode } from "react"; + +import classes from "./classes.module.scss"; type IProps = { title: string; @@ -13,6 +13,7 @@ type IProps = { */ scrollTop: number | null; isPadding?: boolean; + hasHeaderLinks: boolean; }; type IState = {}; @@ -20,12 +21,13 @@ export default class DefaultTemplate extends React.Component { public static defaultProps = { scrollTop: 0, isPadding: true, + hasHeaderLinks: true, }; public override render(): JSX.Element { return ( <> -
+
{this.props.children}
diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 0b6fdea4..6c2a7e7e 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -1,3 +1,4 @@ +import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import DepositDocument from "@Front/Components/DesignSystem/DepositDocument"; import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField"; @@ -7,9 +8,8 @@ import Base from "@Front/Components/Layouts/Base"; import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; import React from "react"; import classes from "./classes.module.scss"; -import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; -import Customer, { Document } from "le-coffre-resources/dist/Customer"; import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; +import Customer, { Document } from "le-coffre-resources/dist/Customer"; import { document } from "./../../../Components/Layouts/DesignSystem/dummyData"; type IProps = {}; @@ -34,7 +34,7 @@ export default class ClientDashboard extends Base { public override render(): JSX.Element { return ( - +
{this.renderHeader()}
@@ -96,7 +96,9 @@ export default class ClientDashboard extends Base { l’aide du bouton ci-dessus.
- + + +
); } diff --git a/src/front/Components/Layouts/DesignSystem/dummyData.ts b/src/front/Components/Layouts/DesignSystem/dummyData.ts index 57157d5b..6007218c 100644 --- a/src/front/Components/Layouts/DesignSystem/dummyData.ts +++ b/src/front/Components/Layouts/DesignSystem/dummyData.ts @@ -146,7 +146,7 @@ export const fileMock: File = { file_name: "file_1", file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/Qmf_Yb_Eh_X9st_F_Srq_Ve_Bj_Yb_Aj56xv_AV_Nj6_Wjypo_B4r5ubce_U_ae3303e7ab.pdf", - iv: "1", + archived_at: null, }; export const fileMock2: File = { @@ -157,7 +157,7 @@ export const fileMock2: File = { file_name: "file_2", file_path: "https://minteed-prod-euwest3-s3.s3.eu-west-3.amazonaws.com/Qm_Wq_En1_DCA_8yt_RX_Qx_QFA_9_Fm_ZKZH_Qqb_VH_1_Q_Mnv_G_Jtt1_FS_Xp_2a35a36e19", - iv: "2", + archived_at: null, }; export const identityFile: File = { @@ -167,7 +167,7 @@ export const identityFile: File = { document: document, file_name: "file_3", file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/cni_fake_c7259d4923.png", - iv: "3", + archived_at: null, }; export const documentIdentity: Document = { diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index c8a51fb9..9db8c4fd 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -20,6 +20,7 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; import OcrResult from "./OcrResult"; +import Files from "@Front/Api/LeCoffreApi/SuperAdmin/Files/Files"; type IProps = {}; @@ -90,7 +91,7 @@ class ViewDocumentsClass extends BasePage { )}
- +
{this.state.document.files.length > 1 && (
{ private downloadFile() { const fileName = this.state.selectedFile?.file_path?.split("/").pop(); - fetch(this.state.selectedFile?.file_path as string) + fetch(Files.getInstance().getUploadLink(this.state.selectedFile?.uid as string)) .then((resp) => resp.blob()) .then((blob) => { const url = window.URL.createObjectURL(blob); diff --git a/src/front/Components/Layouts/LoginCallback/index.tsx b/src/front/Components/Layouts/LoginCallback/index.tsx index a794066e..67732034 100644 --- a/src/front/Components/Layouts/LoginCallback/index.tsx +++ b/src/front/Components/Layouts/LoginCallback/index.tsx @@ -10,7 +10,7 @@ import { useRouter } from "next/router"; //import React, { useEffect, useState } from "react"; import React from "react"; //import Loader from "@Front/Components/DesignSystem/Loader"; -import Auth from "@Front/Api/Auth/IdNot"; +//import Auth from "@Front/Api/Auth/IdNot"; import Folder from "../Folder"; import LoginClass from "../Login"; @@ -75,15 +75,15 @@ export default function LoginCallBack(props: IPropsClass) { const router = useRouter(); const { code } = router.query; if (code) { - const getIdNotJwt = async () => { - try { - const authService = Auth.getInstance(); - await authService.getIdnotJwt(code); - } catch (error) { - console.error(error); - } - }; - getIdNotJwt(); + // const getIdNotJwt = async () => { + // try { + // const authService = Auth.getInstance(); + // await authService.getIdnotJwt(code); + // } catch (error) { + // console.error(error); + // } + // }; + //getIdNotJwt(); return ; } return ; diff --git a/src/front/Components/Layouts/LoginCustomer/index.tsx b/src/front/Components/Layouts/LoginCustomer/index.tsx index ded0c9a6..fe5938c8 100644 --- a/src/front/Components/Layouts/LoginCustomer/index.tsx +++ b/src/front/Components/Layouts/LoginCustomer/index.tsx @@ -6,6 +6,8 @@ import Image from "next/image"; import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; import FranceConnectIcon from "./france-connect.svg"; import ExportIcon from "@Assets/Icons/export.svg"; +import { FrontendVariables } from "@Front/Config/VariablesFront"; +import cryptoRandomString from "crypto-random-string"; export default class LoginCustomer extends BasePage { public override render(): JSX.Element { @@ -35,12 +37,12 @@ export default class LoginCustomer extends BasePage { } private redirectUserOnConnection() { - // const variables = FrontendVariables.getInstance(); + const variables = FrontendVariables.getInstance(); // const baseFronturl = // variables.BACK_API_PROTOCOL + variables.FRONT_APP_HOST + (variables.FRONT_APP_PORT ? ":" + variables.FRONT_APP_PORT : ""); - // const authorizeEndPoint = variables.IDNOT_AUTHORIZE_ENDPOINT; - // const clientId = variables.IDNOT_CLIENT_ID; - // const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=${baseFronturl}/authorized-client&scope=openid,profile,offline_access&response_type=code`; - // window.location.assign(url); + const authorizeEndPoint = variables.FC_AUTHORIZE_ENDPOINT; + const clientId = variables.FC_CLIENT_ID; + const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=http://localhost:8080/login-callback&scope=openid&response_type=code&state=${cryptoRandomString({length: 64})}&nonce=${cryptoRandomString({length: 64})}&acr_values=eidas1`; + window.location.assign(url); } } diff --git a/src/front/Components/Layouts/MyAccount/index.tsx b/src/front/Components/Layouts/MyAccount/index.tsx index 03d5d198..4f892401 100644 --- a/src/front/Components/Layouts/MyAccount/index.tsx +++ b/src/front/Components/Layouts/MyAccount/index.tsx @@ -25,10 +25,10 @@ export default class MyAccount extends Base {
- - - - + + + +
@@ -42,11 +42,12 @@ export default class MyAccount extends Base { name="office_denomination" fakeplaceholder="Dénomination de l'office" type="text" + defaultValue="AP NOTAIRES" disabled /> - - - + + + diff --git a/src/front/Config/VariablesFront.ts b/src/front/Config/VariablesFront.ts index dd823f32..b2d11b4f 100644 --- a/src/front/Config/VariablesFront.ts +++ b/src/front/Config/VariablesFront.ts @@ -19,6 +19,10 @@ export class FrontendVariables { public KEY_DATA!: string; + public FC_AUTHORIZE_ENDPOINT!: string; + + public FC_CLIENT_ID!: string; + private constructor() {} public static getInstance(): FrontendVariables { diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 4e9c36fe..0e6998df 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -20,6 +20,8 @@ type AppPropsWithLayout = AppProps & { frontAppPort: string; idNotAuthorizeEndpoint: string; idNotClientId: string; + fcAuthorizeEndpoint: string; + fcClientId: string; }; const MyApp = (({ @@ -33,6 +35,8 @@ const MyApp = (({ frontAppPort, idNotAuthorizeEndpoint, idNotClientId, + fcAuthorizeEndpoint, + fcClientId }: AppPropsWithLayout) => { const getLayout = Component.getLayout ?? ((page) => ); @@ -45,6 +49,8 @@ const MyApp = (({ instance.FRONT_APP_PORT = frontAppPort; instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint; instance.IDNOT_CLIENT_ID = idNotClientId; + instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint; + instance.FC_CLIENT_ID = fcClientId return getLayout(); }) as AppType; @@ -59,6 +65,8 @@ MyApp.getInitialProps = async () => { frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"], idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"], idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"], + fcAuthorizeEndpoint: process.env["NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT"], + fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"] }; }; diff --git a/src/pages/login-callback.tsx b/src/pages/login-callback.tsx new file mode 100644 index 00000000..eb839556 --- /dev/null +++ b/src/pages/login-callback.tsx @@ -0,0 +1,5 @@ +import ClientDashboard from "@Front/Components/Layouts/ClientDashboard"; + +export default function Route() { + return ; +}