This commit is contained in:
Vincent Alamelle 2023-05-11 12:39:35 +02:00
parent 4fdb6ef210
commit fa1da23eb2
4 changed files with 36 additions and 16 deletions

38
package-lock.json generated
View File

@ -16,11 +16,12 @@
"@types/react-dom": "18.0.11", "@types/react-dom": "18.0.11",
"class-validator": "^0.14.0", "class-validator": "^0.14.0",
"classnames": "^2.3.2", "classnames": "^2.3.2",
"crypto-random-string": "^5.0.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"eslint": "8.36.0", "eslint": "8.36.0",
"eslint-config-next": "13.2.4", "eslint-config-next": "13.2.4",
"form-data": "^4.0.0", "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", "next": "13.2.4",
"prettier": "^2.8.7", "prettier": "^2.8.7",
"react": "18.2.0", "react": "18.2.0",
@ -1535,6 +1536,20 @@
"node": ">= 8" "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": { "node_modules/csstype": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz",
@ -2551,6 +2566,17 @@
"url": "https://github.com/sponsors/sindresorhus" "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": { "node_modules/globalthis": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz",
@ -3202,7 +3228,7 @@
} }
}, },
"node_modules/le-coffre-resources": { "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", "license": "MIT",
"dependencies": { "dependencies": {
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
@ -4474,11 +4500,11 @@
} }
}, },
"node_modules/type-fest": { "node_modules/type-fest": {
"version": "0.20.2", "version": "2.19.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz",
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==",
"engines": { "engines": {
"node": ">=10" "node": ">=12.20"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"

View File

@ -23,7 +23,7 @@
"eslint": "8.36.0", "eslint": "8.36.0",
"eslint-config-next": "13.2.4", "eslint-config-next": "13.2.4",
"form-data": "^4.0.0", "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", "next": "13.2.4",
"prettier": "^2.8.7", "prettier": "^2.8.7",
"react": "18.2.0", "react": "18.2.0",

View File

@ -1,7 +1,6 @@
import { File } from "le-coffre-resources/dist/SuperAdmin"; import { File } from "le-coffre-resources/dist/SuperAdmin";
import BaseSuperAdmin from "../BaseSuperAdmin"; import BaseSuperAdmin from "../BaseSuperAdmin";
import CryptoService from "@Front/Services/CryptoService/CryptoService";
// TODO Type get query params -> Where + inclue + orderby // TODO Type get query params -> Where + inclue + orderby
@ -20,7 +19,6 @@ export default class Files extends BaseSuperAdmin {
private static instance: Files; private static instance: Files;
private readonly baseURl = this.namespaceUrl.concat("/files"); private readonly baseURl = this.namespaceUrl.concat("/files");
private cryptoService: CryptoService = CryptoService.getInstance();
private constructor() { private constructor() {
super(); 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))); if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
try { try {
const files = await this.getRequest<File[]>(url); const files = await this.getRequest<File[]>(url);
files.forEach(async (file) => {
file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv);
});
return files; return files;
} catch (err) { } catch (err) {
this.onError(err); this.onError(err);
@ -69,7 +64,6 @@ export default class Files extends BaseSuperAdmin {
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
try { try {
const file = await this.getRequest<File>(url); const file = await this.getRequest<File>(url);
file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv);
return file; return file;
} catch (err) { } catch (err) {
this.onError(err); this.onError(err);

View File

@ -146,7 +146,7 @@ export const fileMock: File = {
file_name: "file_1", file_name: "file_1",
file_path: 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", "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 = { export const fileMock2: File = {
@ -157,7 +157,7 @@ export const fileMock2: File = {
file_name: "file_2", file_name: "file_2",
file_path: 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", "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 = { export const identityFile: File = {
@ -167,7 +167,7 @@ export const identityFile: File = {
document: document, document: document,
file_name: "file_3", file_name: "file_3",
file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/cni_fake_c7259d4923.png", 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 = { export const documentIdentity: Document = {