diff --git a/.vscode/launch.json b/.vscode/launch.json index 073e087..5dde25e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,7 +14,9 @@ ], "env": { "DATA_DIRECTORY": "${workspaceFolder}/data/member-a", - "LOG_LEVEL": "info" + "LOG_LEVEL": "info", + "REJECT_UNAUTHORIZED": "false", + "NODE_TLS_REJECT_UNAUTHORIZED": "0" }, "args": [ "|", @@ -35,6 +37,8 @@ "env": { "DATA_DIRECTORY": "${workspaceFolder}/data/member-b", "LOG_LEVEL": "info", + "REJECT_UNAUTHORIZED": "false", + "NODE_TLS_REJECT_UNAUTHORIZED": "0" }, "args": [ "|", diff --git a/data/member-a/cert.pem b/data/member-a/cert.pem index f984b1b..954bf54 100644 --- a/data/member-a/cert.pem +++ b/data/member-a/cert.pem @@ -1,17 +1,17 @@ -----BEGIN CERTIFICATE----- -MIICxDCCAawCCQCwQ58VBeUg+TANBgkqhkiG9w0BAQsFADAkMRIwEAYDVQQDDAls -b2NhbGhvc3QxDjAMBgNVBAoMBW9yZy1hMB4XDTIxMDUyMDAyMjUzN1oXDTIyMDUy -MDAyMjUzN1owJDESMBAGA1UEAwwJbG9jYWxob3N0MQ4wDAYDVQQKDAVvcmctYTCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK/bZPBvaA+V6HoXNP+oOQaK -DPuLgFO3R7TTIBTCJttELv1lbfuw95Up+/5b4dPnnIF3wwE2GZsiMWJV7RgfDAUi -x7saJJIIa2E8gLrmoaG99w+PYQW41OBz0p54tw4abN5RNsgineu1N5pIJOMJ6cMs -D8IYfWSHDjZZvu3F2YCItSVYZlfmGBCcFCf4HASF6m4lUTZCDRBurjOQrwW9mXJv -hkIa1HEa4l7Nq09d8Bokvieq1vHJUB78kYTR027z+sm4H2o4pXjzBOaV/z2yB7+t -yqWbMjm8aq2m/gmpZTjDBPgX9XLMYHWBZWCpk1iHo/eqw+UeZ6kRZ0RR78Co+IsC -AwEAATANBgkqhkiG9w0BAQsF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CB1V1RWY1 +AkSYl7XTfD4KvGJja0Vk+PoQeMTp5P7vhSI9YQzVB9XgY12wl1PpUe3Lm4p2NEIZ +dcYndhugqTp7JCUVMNWbIqODEHvdKINOlyMY2AwNYno+/Y11m3PENr4E8OKa1X0k +xf1BNlj1w99hNhABstjHu1Q0F8V6/7GBjV69Ypukg0kmv1kYEJlqF9S5EZhIf0Rf +AEVC/fR3lf2zpfL2JGLy97B5dpReC+1crZmlfAnBXz6c48RCe6YaHQ== -----END CERTIFICATE----- diff --git a/data/member-a/config.json b/data/member-a/config.json index 6ca5d72..ffc129e 100644 --- a/data/member-a/config.json +++ b/data/member-a/config.json @@ -12,7 +12,7 @@ "peers": [ { "id": "org-b", - "endpoint": "https://localhost:4001" + "endpoint": "https://0.0.0.0:4001" } ] } \ No newline at end of file diff --git a/data/member-a/key.pem b/data/member-a/key.pem index edb1501..ab3a817 100644 --- a/data/member-a/key.pem +++ b/data/member-a/key.pem @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCv22Twb2gPleh6 -FzT/qDkGigz7i4BTt0e00yAUwibbRC79ZW37sPeVKfv+W+HT55yBd8MBNhmbIjFi -Ve0YHwwFIse7GiSSCGthPIC65qGhvfcPj2EFuNTgc9KeeLcOGmzeUTbIIp3rtTea -SCTjCenDLA/CGH1khw42Wb7txdmAiLUlWGZX5hgQnBQn+BwEhepuJVE2Qg0Qbq4z -kK8FvZlyb4ZCGtRxGuJezatPXfAaJL4nqtbxyVAe/JGE0dNu8/rJuB9qOKV48wTm -lf89sge/rcqlmzI5vGqtpv4JqWU4wwT4F/VyzGB1gWVgqZNYh6P3qsPlHmepEWdE -Ue/AqPiLAgMBAAECggEAfeVtQAwhzXaetjlDAfwmxx2x6auXNVezCCtVfkb4lmUb -1uD0egnZVXp3I0QYSiI4Ex/wBT/72OoDvMiTMn+XlV2u663tnHZWmYg9CJDwCeD7 -rLIS3Y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+5ydCXez7Lj783MKMsc0bfq8DgAt +CZMNdANcASI2b1hM6vSTwhk7GQcHSGqk5qJEDeomkfcZ9YSU1QAlnXLxcicYziB8 +HfxtMpr7bE8CgYBJrc4HywlIqbv1MqASMQ5a+HzvyBZVQRRPTBWaeR7cDJPJe8l4 +hdgB+MnhOslmmGzy6JZdSsqHLhnsxQyFaWU8HLhgyEQmT+NqL8wTS4jIxsXwVvZW +CO9+vN+7pkLoNl0oMKie2ECoMeXGlo74ZXO5DIpM/9WcpBu1Jxqu8nd6QQKBgQCz +HkxIN/cNJWlQb2iH6+/uWExc7FwQeSIxAx82ZRbBz/hiSknAxu5WW/5oTOUjFUwV +Hlkl+ohmHW5KQLCQr7LlDM8/jv71+BbFdpWK5lzcqMY0LrszG6CBxFw+YfpUw08H +CCsL4Q6+XdQZiarQMWkprzaa36CJpg29aWWwsvl0JwKBgQD4wxlRT/tNPitblI9c +UxTFobgndQoehA67vW0JWxzytbySUSclp6HXPbgDZwkNX/Y+sGEaQh7convAyqnJ +HmZMFCPuIf3kxHeyfqKf9M5ocU/EFCRIhC7N+G2psrHdPdC2NDHF9fR33W3lVBIK +K0PUgIAhw6zvUnEAl3+TKrYInw== -----END PRIVATE KEY----- diff --git a/data/member-b/cert.pem b/data/member-b/cert.pem index 37988eb..3a50883 100644 --- a/data/member-b/cert.pem +++ b/data/member-b/cert.pem @@ -1,17 +1,17 @@ -----BEGIN CERTIFICATE----- -MIICxDCCAawCCQCoKGH3VybuuDANBgkqhkiG9w0BAQsFADAkMRIwEAYDVQQDDAls -b2NhbGhvc3QxDjAMBgNVBAoMBW9yZy1iMB4XDTIxMDUyMDAyMjYxNFoXDTIyMDUy -MDAyMjYxNFowJDESMBAGA1UEAwwJbG9jYWxob3N0MQ4wDAYDVQQKDAVvcmctYjCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN21/OyZAHIM+6B/HdR7pQLX -cEh60nUYHEJbCa5dlV7WyqpbKF6jSnbxz3/ZC59q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c7OKpBEE9yWRNX47NGzSJPOtjn8rJ4EYFu0CYYrMcNpGg8wtc +Osi6kEEmHWecE8CGkj48E3iWFo/AZEAacsg2mwtsDZGkAD3qxXKlhEwu18G6iYuT +V1yze/wo1puTf3/srIu+ZUkcjndNkyunJLtvO8jvZZVUB8gsDNepuHaAF3hAtBUC +AwEAATANBgkqhkiG9w0BAQsFAAOCAQEAg975lC4A8iGCA67nD5vbGzWGFgxH/Kyj +6jTZ3PIcd0gz9Mwm34HqD48hylbPpRIwMggAD6/9PnRmuZIqMhXRKMi9GtKpS+v6 +jRx7LP73aivgDUDu1IfDKnka3izy4NFo5pGQs5kk2njswoYOj63Qa/8COA7H8rLp +qw9u0RF6j/OruvAthTltwnv0c+CkYwzz7VshVqWBrQuRAAku+nu8nYznDyYTdgaF +IXvCbOS/vDQJWFRmrXsQx6+kDDkon6Vt4lR8TJJMwQ9s1KIFsV1Hcu92qQHhAh3V +EtmsbnwuFOXJ5dr11HqcFKKjs1xIcsvWC04pBMk/SGS25jDB20fNdA== -----END CERTIFICATE----- diff --git a/data/member-b/config.json b/data/member-b/config.json index 72d7d75..0754795 100644 --- a/data/member-b/config.json +++ b/data/member-b/config.json @@ -12,7 +12,7 @@ "peers": [ { "id": "org-a", - "endpoint": "https://localhost:3001" + "endpoint": "https://0.0.0.0:3001" } ] } \ No newline at end of file diff --git a/data/member-b/key.pem b/data/member-b/key.pem index 36435ef..8db6d18 100644 --- a/data/member-b/key.pem +++ b/data/member-b/key.pem @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDdtfzsmQByDPug -fx3Ue6UC13BIetJ1GBxCWwmuXZVe1sqqWyheo0p28c9/2Qufah0CkoEOgpZvgCux -mjKbjdppjWS9MnEeflJWsfqwyfNu89o/sglM99YC/Kd/5Bk3uuinmFb7htwJ7Qgw -vqwq0oZBN7PBM0dupNbyzGr2aL2VU+sXzjRTz2xRB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CU3x3iQsL1x6ymW9kCgYEA4XXDiS11JjLuyPFI +yCgbbPWb7YcDFzSZ/YSCUZuXNtubGLsa5ymSPE8NAum1UFCiw5v1NtINUt7qNZgW +sDueAjTF4eBchX7BP5XpHbVD8n5iTLa+k3/l6eHr2brCX7Mza2N6XkqnDeSUz1O5 +fu+aNQ9JkrFeOaXvO47u0MOuN0MCgYEA27fL490BCcs6372RAQvgY1xnCc5MnzUA +mMiQDt0S0JD82z681kkbBD2Nu854zZKNafd3Vgf1bYQuod40EoFTmN0f3AORsKoM +E5aNiqRKk7oQuHrIjNz7y6aXRcwYIfh1HGlPnLpRtVV3Ui8AwoOcFcpw4WOX41XB +ArLbf+yz1ccCgYBtiSlWnB8uT9BzD8asd8/bP/hhjhaST5wA7z/hJhZxMIBJo52O +cUP6yO0pXSIZwxNQtZSM7cBLYsGnCBz9wfkiWUFKXBaXRN3eZpa7ODWqunxHiQFN +5/Vri7dqMLH+jLGOmuX4qYw/0634jFSytvXUkXjNLB77IwL3jJm6E1ewwQKBgHR9 +90khtNo3eUiFHmtam6ayqCLH0VIb7OwUcmSfC8mvBZFMqxxF+GAALrRjXSNJT1be +kNP5NkPRcFP8Fsm07di/bJPfBJCRKAP+r57RSoUWgqT83HXq+ElaUxv7gNQKAjWF +FGO5WXb2EGRvbUy0ML5Q7hZiEnbC0amXoM8rdZGjAoGASPGmRVIJCKlXm0Q4F39i +T9E1c0frkGl5cpllDL5FBehCucHMRBvlw42P4eTUKLy1pUpkyX+wcM2DNGapnrlB +UqlBxnIrwymADyQxr6v18WiOI5d2NCALB1U+IkZJRBOL6mycWsMu46j9MWoZbF0I +i3Fk/uW6OEw/fX2rPco4gHE= -----END PRIVATE KEY----- diff --git a/src/handlers/blobs.ts b/src/handlers/blobs.ts index 5f146da..e9a11d4 100644 --- a/src/handlers/blobs.ts +++ b/src/handlers/blobs.ts @@ -21,7 +21,7 @@ import https from 'https'; import path from 'path'; import stream from 'stream'; import { v4 as uuidV4 } from 'uuid'; -import { ca, cert, key } from '../lib/cert'; +import { ca, cert, key, peerID } from '../lib/cert'; import { BlobTask, IBlobDeliveredEvent, IBlobFailedEvent, IFile, IMetadata } from "../lib/interfaces"; import { Logger } from '../lib/logger'; import RequestError from '../lib/request-error'; @@ -67,12 +67,13 @@ export const storeBlob = async (file: IFile, filePath: string) => { return await upsertMetadata(filePath, blobHash, blobSize); }; -export const sendBlob = async (blobPath: string, recipient: string, recipientURL: string, requestId: string | undefined) => { +export const sendBlob = async (blobPath: string, recipientID: string, recipientURL: string, requestId: string | undefined, + senderDestination: string | undefined, recipientDestination: string | undefined) => { if (sending) { - blobQueue.push({ blobPath, recipient, recipientURL, requestId }); + blobQueue.push({ blobPath, recipientID, recipientURL, requestId, senderDestination, recipientDestination }); } else { sending = true; - blobQueue.push({ blobPath, recipient, recipientURL, requestId }); + blobQueue.push({ blobPath, recipientID, recipientURL, requestId, senderDestination, recipientDestination }); while (blobQueue.length > 0) { await deliverBlob(blobQueue.shift()!); } @@ -80,13 +81,23 @@ export const sendBlob = async (blobPath: string, recipient: string, recipientURL } }; -export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestId }: BlobTask) => { +export const deliverBlob = async ({ blobPath, recipientID, recipientURL, requestId, senderDestination, recipientDestination }: BlobTask) => { const resolvedFilePath = path.join(utils.constants.DATA_DIRECTORY, utils.constants.BLOBS_SUBDIRECTORY, blobPath); if (!(await utils.fileExists(resolvedFilePath))) { throw new RequestError('Blob not found', 404); } const stream = createReadStream(resolvedFilePath); const formData = new FormData(); + let sender = peerID; + if(senderDestination !== undefined) { + formData.append('senderDestination', senderDestination); + sender += utils.constants.ID_SEGMENT_SEPARATOR + senderDestination + } + let recipient = recipientID; + if(recipientDestination !== undefined) { + formData.append('recipientDestination', recipientDestination); + recipient += utils.constants.ID_SEGMENT_SEPARATOR + recipientDestination; + } formData.append('blob', stream); const httpsAgent = new https.Agent({ cert, key, ca }); log.trace(`Delivering blob ${blobPath} to ${recipient} at ${recipientURL}`); @@ -103,6 +114,7 @@ export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestId id: uuidV4(), type: 'blob-delivered', path: blobPath, + sender, recipient, requestId } as IBlobDeliveredEvent); @@ -112,6 +124,7 @@ export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestId id: uuidV4(), type: 'blob-failed', path: blobPath, + sender, recipient, requestId, error: err.message, diff --git a/src/handlers/messages.ts b/src/handlers/messages.ts index 1c14f2e..613e6ec 100644 --- a/src/handlers/messages.ts +++ b/src/handlers/messages.ts @@ -17,23 +17,24 @@ import FormData from 'form-data'; import https from 'https'; import { v4 as uuidV4 } from 'uuid'; -import { ca, cert, key } from '../lib/cert'; +import { ca, cert, key, peerID } from '../lib/cert'; import { IMessageDeliveredEvent, IMessageFailedEvent, MessageTask } from '../lib/interfaces'; import { Logger } from '../lib/logger'; import * as utils from '../lib/utils'; import { queueEvent } from './events'; -const log = new Logger('handlers/messages.ts') +const log = new Logger('handlers/messages.ts'); let messageQueue: MessageTask[] = []; let sending = false; -export const sendMessage = async (message: string, recipient: string, recipientURL: string, requestId: string | undefined) => { +export const sendMessage = async (message: string, recipientID: string, recipientURL: string, requestId: string | undefined, + senderDestination: string | undefined, recipientDestination: string | undefined) => { if (sending) { - messageQueue.push({ message, recipient, recipientURL, requestId }); + messageQueue.push({ message, recipientID, recipientURL, requestId, senderDestination, recipientDestination }); } else { sending = true; - messageQueue.push({ message, recipient, recipientURL, requestId }); + messageQueue.push({ message, recipientID, recipientURL, requestId, senderDestination, recipientDestination }); while (messageQueue.length > 0) { await deliverMessage(messageQueue.shift()!); } @@ -41,9 +42,19 @@ export const sendMessage = async (message: string, recipient: string, recipientU } }; -export const deliverMessage = async ({ message, recipient, recipientURL, requestId }: MessageTask) => { +export const deliverMessage = async ({ message, recipientID, recipientURL, requestId, senderDestination, recipientDestination }: MessageTask) => { const httpsAgent = new https.Agent({ cert, key, ca }); const formData = new FormData(); + let sender = peerID; + if(senderDestination !== undefined) { + formData.append('senderDestination', senderDestination); + sender += utils.constants.ID_SEGMENT_SEPARATOR + senderDestination + } + let recipient = recipientID; + if(recipientDestination !== undefined) { + formData.append('recipientDestination', recipientDestination); + recipient += utils.constants.ID_SEGMENT_SEPARATOR + recipientDestination; + } formData.append('message', message); log.trace(`Delivering message to ${recipient} at ${recipientURL}`); try { @@ -58,6 +69,7 @@ export const deliverMessage = async ({ message, recipient, recipientURL, request id: uuidV4(), type: 'message-delivered', message, + sender, recipient, requestId } as IMessageDeliveredEvent); @@ -67,6 +79,7 @@ export const deliverMessage = async ({ message, recipient, recipientURL, request id: uuidV4(), type: 'message-failed', message, + sender, recipient, requestId, error: err.message, diff --git a/src/lib/cert.ts b/src/lib/cert.ts index b7cee09..3c20075 100644 --- a/src/lib/cert.ts +++ b/src/lib/cert.ts @@ -76,7 +76,7 @@ export const genTLSContext = () => { key, cert, ca, - rejectUnauthorized: true, + rejectUnauthorized: Boolean(process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0'? false: true), requestCert: true, } } diff --git a/src/lib/interfaces.ts b/src/lib/interfaces.ts index 3c6cb58..8a8281d 100644 --- a/src/lib/interfaces.ts +++ b/src/lib/interfaces.ts @@ -53,6 +53,7 @@ export type OutboundEvent = export interface IMessageReceivedEvent { id: string type: 'message-received' + recipient: string sender: string message: string } @@ -60,6 +61,7 @@ export interface IMessageReceivedEvent { export interface IMessageDeliveredEvent { id: string type: 'message-delivered' + sender: string recipient: string message: string } @@ -67,6 +69,7 @@ export interface IMessageDeliveredEvent { export interface IMessageFailedEvent { id: string type: 'message-failed' + sender: string recipient: string message: string requestId?: string @@ -76,6 +79,7 @@ export interface IBlobReceivedEvent { id: string type: 'blob-received' sender: string + recipient: string path: string hash: string size: number @@ -84,6 +88,7 @@ export interface IBlobReceivedEvent { export interface IBlobDeliveredEvent { id: string type: 'blob-delivered' + sender: string recipient: string path: string } @@ -91,6 +96,7 @@ export interface IBlobDeliveredEvent { export interface IBlobFailedEvent { id: string type: 'blob-failed' + sender: string recipient: string path: string } @@ -113,15 +119,19 @@ export interface IAckEvent { export type MessageTask = { requestId?: string message: string - recipient: string + recipientID: string recipientURL: string + senderDestination?: string + recipientDestination?: string } export type BlobTask = { requestId?: string blobPath: string - recipient: string + recipientID: string recipientURL: string + senderDestination?: string + recipientDestination?: string } export interface IStatus { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d9fa98f..18c93ac 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -46,7 +46,8 @@ export const constants = { SIZE_HEADER_NAME: 'dx-size', LAST_UPDATE_HEADER_NAME: 'dx-last-update', DEFAULT_JSON_PARSER_LIMIT: '1mb', - DEFAULT_MAX_INFLIGHT: 100 + DEFAULT_MAX_INFLIGHT: 100, + ID_SEGMENT_SEPARATOR: '/' }; const log = new Logger('utils.ts'); axios.defaults.timeout = constants.REST_API_CALL_REQUEST_TIMEOUT; @@ -67,19 +68,33 @@ export const fileExists = async (filePath: string): Promise => { throw err; } } - return true; } -export const extractFileFromMultipartForm = (req: Request): Promise => { +export const extractFileFromMultipartForm = (req: Request): Promise<{ + file: IFile, senderDestination: string | undefined, + recipientDestination: string | undefined +}> => { return new Promise(async (resolve, reject) => { let fileFound = false; + let senderDestination: string | undefined = undefined; + let recipientDestination: string | undefined = undefined; req.pipe(newBusboy({ headers: req.headers }) + .on('field', (fieldname, value) => { + switch (fieldname) { + case 'senderDestination': senderDestination = value; break; + case 'recipientDestination': recipientDestination = value; break; + } + }) .on('file', (fieldname, readableStream, file) => { fileFound = true; resolve({ - key: fieldname, - name: file.filename, - readableStream + senderDestination, + recipientDestination, + file: { + key: fieldname, + name: file.filename, + readableStream + } }); })).on('finish', () => { if (!fileFound) { @@ -89,18 +104,26 @@ export const extractFileFromMultipartForm = (req: Request): Promise => { }); }; -export const extractMessageFromMultipartForm = (req: Request): Promise => { +export const extractMessageFromMultipartForm = (req: Request): Promise<{ + senderDestination: string | undefined, + recipientDestination: string | undefined, message: string +}> => { return new Promise(async (resolve, reject) => { - let fieldFound = false; + let message: string | undefined = undefined; + let senderDestination: string | undefined = undefined; + let recipientDestination: string | undefined = undefined; req.pipe(newBusboy({ headers: req.headers }) .on('field', (fieldname, value) => { - if(fieldname === 'message') { - fieldFound = true; - resolve(value); + switch (fieldname) { + case 'senderDestination': senderDestination = value; break; + case 'recipientDestination': recipientDestination = value; break; + case 'message': message = value; break; } })).on('finish', () => { - if (!fieldFound) { + if (message === undefined) { reject(new RequestError('Missing message', 400)); + } else { + resolve({ message, senderDestination, recipientDestination }); } }); }); @@ -129,13 +152,13 @@ export const axiosWithRetry = async (config: AxiosRequestConfig) => { }; export const getPeerID = (organization: string | undefined, organizationUnit: string | undefined) => { - if(organization !== undefined) { - if(organizationUnit !== undefined) { + if (organization !== undefined) { + if (organizationUnit !== undefined) { return `${organization}-${organizationUnit}`; } else { return organization; } - } else if(organizationUnit !== undefined) { + } else if (organizationUnit !== undefined) { return organizationUnit; } else { throw new Error('Invalid peer'); @@ -148,11 +171,11 @@ export const getCertData = (cert: string): ICertData => { const subject = x509.getSubjectString(); const o = subject.match('O=([^\/.]+)'); let certData: ICertData = {}; - if(o !== null) { + if (o !== null) { certData.organization = o[1]; } const ou = subject.match('OU=([^\/.]+)'); - if(ou !== null) { + if (ou !== null) { certData.organizationUnit = ou[1]; } return certData; diff --git a/src/routers/api.ts b/src/routers/api.ts index e43bd86..5c5f708 100644 --- a/src/routers/api.ts +++ b/src/routers/api.ts @@ -131,18 +131,42 @@ router.post('/messages', async (req, res, next) => { if (req.body.message === undefined) { throw new RequestError('Missing message', 400); } - if (req.body.recipient === undefined) { + let senderDestination: string | undefined = undefined; + if (typeof req.body.sender === 'string') { + if (!req.body.sender.startsWith(peerID)) { + throw new RequestError('Invalid sender'); + } else { + const destination = req.body.sender.substring(peerID.length + 1); + if(destination.length > 0) { + senderDestination = destination; + } + } + } + let recipientID: string; + let recipientDestination: string | undefined = undefined; + if (typeof req.body.recipient === 'string') { + const index = req.body.recipient.indexOf(utils.constants.ID_SEGMENT_SEPARATOR); + if (index !== -1) { + recipientID = req.body.recipient.substring(0, index); + const destination = req.body.recipient.substring(index + 1); + if(destination.length > 0) { + recipientDestination = destination; + } + } else { + recipientID = req.body.recipient; + } + } else { throw new RequestError('Missing recipient', 400); } - let recipientURL = config.peers.find(peer => peer.id === req.body.recipient)?.endpoint; + let recipientURL = config.peers.find(peer => peer.id === recipientID)?.endpoint; if (recipientURL === undefined) { throw new RequestError(`Unknown recipient`, 400); } let requestId = uuidV4(); - if(typeof req.body.requestId === 'string') { + if (typeof req.body.requestId === 'string') { requestId = req.body.requestId; } - messagesHandler.sendMessage(req.body.message, req.body.recipient, recipientURL, requestId); + messagesHandler.sendMessage(req.body.message, recipientID, recipientURL, requestId, senderDestination, recipientDestination); res.send({ requestId }); } catch (err) { next(err); @@ -188,7 +212,7 @@ router.put('/blobs/*', async (req: Request, res, next) => { if (!utils.regexp.FILE_KEY.test(blobPath) || utils.regexp.CONSECUTIVE_DOTS.test(blobPath)) { throw new RequestError('Invalid path', 400); } - const file = await utils.extractFileFromMultipartForm(req); + const { file } = await utils.extractFileFromMultipartForm(req); const metadata = await blobsHandler.storeBlob(file, blobPath); res.send(metadata); } catch (err) { @@ -204,18 +228,43 @@ router.post('/transfers', async (req, res, next) => { if (!utils.regexp.FILE_KEY.test(req.body.path) || utils.regexp.CONSECUTIVE_DOTS.test(req.body.path)) { throw new RequestError('Invalid path', 400); } - if (req.body.recipient === undefined) { + await blobsHandler.retreiveMetadata(path.join(utils.constants.DATA_DIRECTORY, utils.constants.BLOBS_SUBDIRECTORY, req.body.path)); + let senderDestination: string | undefined = undefined; + if (typeof req.body.sender === 'string') { + if (!req.body.sender.startsWith(peerID)) { + throw new RequestError('Invalid sender'); + } else { + const destination = req.body.sender.substring(peerID.length + 1); + if(destination.length > 0) { + senderDestination = destination; + } + } + } + let recipientID: string; + let recipientDestination: string | undefined = undefined; + if (typeof req.body.recipient === 'string') { + const index = req.body.recipient.indexOf(utils.constants.ID_SEGMENT_SEPARATOR); + if (index !== -1) { + recipientID = req.body.recipient.substring(0, index); + const destination = req.body.recipient.substring(index + 1); + if(destination.length > 0) { + recipientDestination = destination; + } + } else { + recipientID = req.body.recipient; + } + } else { throw new RequestError('Missing recipient', 400); } - let recipientURL = config.peers.find(peer => peer.id === req.body.recipient)?.endpoint; + let recipientURL = config.peers.find(peer => peer.id === recipientID)?.endpoint; if (recipientURL === undefined) { throw new RequestError(`Unknown recipient`, 400); } let requestId = uuidV4(); - if(typeof req.body.requestId === 'string') { + if (typeof req.body.requestId === 'string') { requestId = req.body.requestId; } - blobsHandler.sendBlob(req.body.path, req.body.recipient, recipientURL, requestId); + blobsHandler.sendBlob(req.body.path, recipientID, recipientURL, requestId, senderDestination, recipientDestination); res.send({ requestId }); } catch (err) { next(err); diff --git a/src/routers/p2p.ts b/src/routers/p2p.ts index aea688d..83f5497 100644 --- a/src/routers/p2p.ts +++ b/src/routers/p2p.ts @@ -21,6 +21,7 @@ import path from 'path'; import { IBlobReceivedEvent, IMessageReceivedEvent } from '../lib/interfaces'; import { v4 as uuidV4 } from 'uuid'; import { queueEvent } from '../handlers/events'; +import { peerID } from '../lib/cert'; export const router = Router(); @@ -30,12 +31,20 @@ router.head('/ping', (_req, res) => { router.post('/messages', async (req: Request, res, next) => { try { - const sender = utils.extractPeerSenderFromRequest(req); - const message = await utils.extractMessageFromMultipartForm(req); + let sender = utils.extractPeerSenderFromRequest(req); + const { senderDestination, recipientDestination, message } = await utils.extractMessageFromMultipartForm(req); + if (senderDestination !== undefined) { + sender += utils.constants.ID_SEGMENT_SEPARATOR + senderDestination; + } + let recipient = peerID; + if (recipientDestination !== undefined) { + recipient += utils.constants.ID_SEGMENT_SEPARATOR + recipientDestination; + } await queueEvent({ id: uuidV4(), type: 'message-received', sender, + recipient, message } as IMessageReceivedEvent); res.sendStatus(204); @@ -46,8 +55,15 @@ router.post('/messages', async (req: Request, res, next) => { router.put('/blobs/*', async (req: Request, res, next) => { try { - const sender = utils.extractPeerSenderFromRequest(req); - const file = await utils.extractFileFromMultipartForm(req); + let sender = utils.extractPeerSenderFromRequest(req); + const { file, senderDestination, recipientDestination } = await utils.extractFileFromMultipartForm(req); + if (senderDestination !== undefined) { + sender += utils.constants.ID_SEGMENT_SEPARATOR + senderDestination; + } + let recipient = peerID; + if (recipientDestination !== undefined) { + recipient += utils.constants.ID_SEGMENT_SEPARATOR + recipientDestination; + } const blobPath = path.join(utils.constants.RECEIVED_BLOBS_SUBDIRECTORY, sender, req.params[0]); const metadata = await blobsHandler.storeBlob(file, blobPath); res.sendStatus(204); @@ -55,6 +71,7 @@ router.put('/blobs/*', async (req: Request, res, next) => { id: uuidV4(), type: 'blob-received', sender, + recipient, path: blobPath, hash: metadata.hash, size: metadata.size, diff --git a/test/handlers/events.test.ts b/test/handlers/events.test.ts index c4c95df..169772a 100644 --- a/test/handlers/events.test.ts +++ b/test/handlers/events.test.ts @@ -59,7 +59,8 @@ describe('events', () => { id: `${i}`, type: 'message-received', message: `message_${i}`, - sender: 'peer1' + sender: 'peer1', + recipient: 'peer2' }); } await firstTenDispatched; @@ -111,7 +112,8 @@ describe('events', () => { id: `${i}`, type: 'message-received', message: `message_${i}`, - sender: 'peer1' + sender: 'peer1', + recipient: 'peer2' }); queued++; } @@ -148,7 +150,8 @@ describe('events', () => { id: `right`, type: 'message-received', message: `message`, - sender: 'peer1' + sender: 'peer1', + recipient: 'peer2' }); events.handleAck({ id: `wrong`, type: 'ack' }); @@ -164,7 +167,8 @@ describe('events', () => { id: `right`, type: 'message-received', message: `message`, - sender: 'peer1' + sender: 'peer1', + recipient: 'peer2' }); events.handleAck({ type: 'ack' }); @@ -195,13 +199,15 @@ describe('events', () => { id: `1`, type: 'message-received', message: `message`, - sender: 'peer1' + sender: 'peer1', + recipient: 'peer2' }); await events.queueEvent({ id: `2`, type: 'message-received', message: `message`, - sender: 'peer1' + sender: 'peer1', + recipient: 'peer2' }); events.reDispatchInFlight();