Skip to content

Commit

Permalink
Merge pull request #38 from DIG-Network/release/v0.0.1-alpha.41
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.41
  • Loading branch information
MichaelTaylor3D authored Sep 22, 2024
2 parents fba9d4b + a2e5185 commit 6cb8044
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.1-alpha.41](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.40...v0.0.1-alpha.41) (2024-09-22)


### Features

* upload dat file as part up upload session ([4b97d08](https://github.com/DIG-Network/dig-propagation-server/commit/4b97d08296c39d337221b8f73d50149b618ffa2f))

### [0.0.1-alpha.40](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.39...v0.0.1-alpha.40) (2024-09-22)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig-propagation-server",
"version": "0.0.1-alpha.40",
"version": "0.0.1-alpha.41",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
22 changes: 8 additions & 14 deletions src/controllers/merkleTreeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,17 @@ export const startUploadSession = async (
session.resetTtl(); // Reset TTL on each chunk of data
});

// Extract the file and its metadata from the FormData body
const contentDisposition = req.headers["content-disposition"] || "";
const matches = contentDisposition.match(/filename="(.+?)"/);
if (!matches) {
throw new HttpError(400, "Missing filename in the upload request.");
}

const filename = matches[1];
if (!/^[a-fA-F0-9]{64}\.dat$/.test(filename)) {
throw new HttpError(400, "Invalid rootHash format in the filename.");
const rootHash = req.query.roothash as string;
if (!rootHash || !/^[a-fA-F0-9]{64}$/.test(rootHash)) {
throw new HttpError(400, "Invalid or missing rootHash.");
}

const rootHash = filename.split(".")[0]; // Extract rootHash from the file name
const tmpDatFilePath = path.join(session.tmpDir, filename);
// Create the file path for saving the uploaded .dat file
const tmpDatFilePath = path.join(session.tmpDir, `${rootHash}.dat`);
const fileStream = fs.createWriteStream(tmpDatFilePath);

// Stream the file from the request body into the temp file
const fileWriteStream = fs.createWriteStream(tmpDatFilePath);
await streamPipeline(req.pipe(passThrough), fileWriteStream);
await streamPipeline(req.pipe(passThrough), fileStream);

// Now validate the file once it's saved
await validateDataFile(tmpDatFilePath, storeId);
Expand Down Expand Up @@ -317,6 +310,7 @@ export const uploadFile = async (
}

// Validate the key ownership signature using the nonce

const isSignatureValid = await Wallet.verifyKeyOwnershipSignature(
nonce,
keyOwnershipSig,
Expand Down

0 comments on commit 6cb8044

Please sign in to comment.