Compare commits

...

7 Commits
main ... demo

Author SHA1 Message Date
Sosthene
d8759f854e Add demo workflow
All checks were successful
Demo - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 19s
Demo - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Demo - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 4s
2025-07-30 14:27:49 +02:00
Sosthene
bac90f003c Conditional hydration of folder_anchor
All checks were successful
Test - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 1m43s
Test - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Test - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 3s
2025-07-30 13:26:05 +02:00
Sosthene
64918e94f0 Add verbosity
All checks were successful
Test - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 2m19s
Test - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Test - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 3s
2025-07-30 13:04:59 +02:00
Sosthene
c33d4faacd Merge branch 'fix_download_certificate' into legacy_dev
All checks were successful
Test - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 16s
Test - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Test - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 3s
2025-07-30 12:29:29 +02:00
Sosthene
17c4347e98 Fix linter error on NotificationBuilder 2025-07-30 12:28:51 +02:00
Sosthene
b2dbfbeaa2 Add private getValidatedDocumentHashes and fix download bug 2025-07-30 12:26:50 +02:00
omaroughriss
008d21de8c Update legacy_dev to push on test env
All checks were successful
Test - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 15s
Test - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Test - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 2s
2025-07-30 11:51:03 +02:00
4 changed files with 64 additions and 58 deletions

View File

@ -2,7 +2,7 @@ name: Demo - Build & Deploy to Scaleway
on:
push:
branches: [legacy_dev]
branches: [demo]
env:
PROJECT_ID_LECOFFRE: 72d08499-37c2-412b-877e-f8af0471654a

View File

@ -1,15 +1,14 @@
name: Prod - Build & Deploy to Scaleway
name: Test - Build & Deploy to Scaleway
on:
push:
branches: [test]
branches: [legacy_dev]
env:
PROJECT_ID_LECOFFRE: 72d08499-37c2-412b-877e-f8af0471654a
NAMESPACE_ID_LECOFFRE: 3829c5cd-9fb0-4871-97a1-eb33e4bc1114
CONTAINER_REGISTRY_ENDPOINT_LECOFFRE: rg.fr-par.scw.cloud/funcscwlecoffretestouylprmj
IMAGE_NAME: back
CONTAINER_NAME: back
@ -18,16 +17,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
#- name: Setup SSH
# run: |
# mkdir -p ~/.ssh
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
# chmod 600 ~/.ssh/id_rsa
# ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
# env:
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
#- name: Copy SSH
# run: cp ~/.ssh/id_rsa id_rsa
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Copy SSH
run: cp ~/.ssh/id_rsa id_rsa
- name: Login to Scaleway Container Registry
uses: docker/login-action@v3
with:
@ -46,7 +45,7 @@ jobs:
deploy-back-lecoffre:
needs: build-and-push-images-lecoffre
runs-on: ubuntu-latest
environment: prod
environment: test
steps:
- name: Install CLI
uses: scaleway/action-scw@v0
@ -82,7 +81,7 @@ jobs:
deploy-cron-lecoffre:
needs: build-and-push-images-lecoffre
runs-on: ubuntu-latest
environment: prod
environment: test
steps:
- name: Install CLI
uses: scaleway/action-scw@v0
@ -110,9 +109,7 @@ jobs:
scw container container update ${{ env.CONTAINER_ID }} $env_string
env:
ENV_VARS: ${{ secrets.ENV }}
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY_LECOFFRE }}
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY_LECOFFRE }}
SCW_DEFAULT_PROJECT_ID: ${{ env.PROJECT_ID_LECOFFRE }}
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID_LECOFFRE }}
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID_LECOFFRE }}

View File

@ -3,7 +3,7 @@ import { Controller, Get, Post } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController";
import { Service } from "typedi";
import { Document, OfficeFolder, File } from "le-coffre-resources/dist/Notary";
import { getFolderHashes, getFolderFilesUid } from "@Common/optics/notary";
import { getFolderFilesUid } from "@Common/optics/notary";
import OfficeFoldersService from "@Services/notary/OfficeFoldersService/OfficeFoldersService";
import OfficeFolderAnchorsRepository from "@Repositories/OfficeFolderAnchorsRepository";
import FilesService from "@Services/common/FilesService/FilesService";
@ -49,6 +49,27 @@ export default class OfficeFoldersController extends ApiController {
super();
}
private getValidatedDocumentHashes(officeFolder: OfficeFolder): string[] {
const documents = officeFolder.documents ?? [];
if (documents.length === 0) {
return [];
}
const folderHashes: string[] = [];
documents.forEach((document: any) => {
const documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
if (documentHydrated.document_status === "VALIDATED") {
documentHydrated.files?.forEach((file: any) => {
const fileHydrated = File.hydrate<File>(file, { strategy: "excludeAll" });
folderHashes.push(fileHydrated.hash);
});
}
});
return folderHashes.sort();
}
/**
* @description Download a folder anchoring proof document along with all accessible files
*/
@ -79,15 +100,14 @@ export default class OfficeFoldersController extends ApiController {
}
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
const folderHashes = getFolderHashes(officeFolder);
const sortedHashes = this.getValidatedDocumentHashes(officeFolder);
const folderFilesUid = getFolderFilesUid(officeFolder);
if (folderHashes.length === 0) {
if (sortedHashes.length === 0) {
this.httpNotFoundRequest(response, "No file hash to anchor");
return;
}
const sortedHashes = [...folderHashes].sort();
const anchoringProof = await this.secureService.download(sortedHashes, officeFolder.office!.name);
@ -143,21 +163,25 @@ export default class OfficeFoldersController extends ApiController {
const officeFolderFound: any = await this.officeFoldersService.getByUid(uid, query);
console.log(officeFolderFound);
if (!officeFolderFound) {
this.httpNotFoundRequest(response, "Office folder not found");
return;
}
const officeFolderAnchorFound = OfficeFolderAnchor.hydrate<OfficeFolderAnchor>(officeFolderFound.folder_anchor, {
strategy: "excludeAll",
});
if (officeFolderAnchorFound) {
this.httpBadRequest(response, {
error: "Office folder already anchored",
folder_anchor: officeFolderAnchorFound,
if (officeFolderFound.folder_anchor) {
const officeFolderAnchorFound = OfficeFolderAnchor.hydrate<OfficeFolderAnchor>(officeFolderFound.folder_anchor, {
strategy: "excludeAll",
});
return;
if (officeFolderAnchorFound) {
this.httpBadRequest(response, {
error: "Office folder already anchored",
folder_anchor: officeFolderAnchorFound,
});
return;
}
}
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
@ -180,18 +204,13 @@ export default class OfficeFoldersController extends ApiController {
return;
}
const folderHashes: string[] = [];
documents.forEach((document: any) => {
const documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
if (documentHydrated.document_status === "VALIDATED") {
documentHydrated.files?.forEach((file: any) => {
const fileHydrated = File.hydrate<File>(file, { strategy: "excludeAll" });
folderHashes.push(fileHydrated.hash);
});
}
});
const sortedHashes = this.getValidatedDocumentHashes(officeFolder);
if (sortedHashes.length === 0) {
this.httpBadRequest(response, "No file hash to anchor");
return;
}
const sortedHashes = [...folderHashes].sort();
const data = await this.secureService.anchor(sortedHashes);
const officeFolderAnchor = hydrateOfficeFolderAnchor(data);
@ -248,23 +267,13 @@ export default class OfficeFoldersController extends ApiController {
return;
}
const folderHashes: string[] = [];
documents.forEach((document: any) => {
const documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
if (documentHydrated.document_status === "VALIDATED") {
documentHydrated.files?.forEach((file: any) => {
const fileHydrated = File.hydrate<File>(file, { strategy: "excludeAll" });
folderHashes.push(fileHydrated.hash);
});
}
});
const sortedHashes = this.getValidatedDocumentHashes(officeFolder);
if (folderHashes.length === 0) {
if (sortedHashes.length === 0) {
this.httpNotFoundRequest(response, "No file hash to anchor");
return;
}
const sortedHashes = [...folderHashes].sort();
const officeFolderAnchorFound = OfficeFolderAnchor.hydrate<OfficeFolderAnchor>(officeFolderFound.folder_anchor, {
strategy: "excludeAll",
});

View File

@ -95,7 +95,7 @@ export default class NotificationBuilder {
redirection_url: "",
created_at: new Date(),
updated_at: new Date(),
user: [user] || [],
user: user ? [user] : [],
});
}
@ -105,7 +105,7 @@ export default class NotificationBuilder {
redirection_url: "",
created_at: new Date(),
updated_at: new Date(),
user: [user] || [],
user: user ? [user] : [],
});
}