Skip to content

Conversation

@gabriel-indik
Copy link
Contributor

No description provided.

Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
Signed-off-by: Gabriel Indik <gabriel.indik@kaleido.io>
@gabriel-indik
Copy link
Contributor Author

Changes included in this PR:
The PUT /api/v1/peers endpoint has been expanded to accept an optional segment that corresponds to a destination. For example: /api/v1/peers/org-a/destination1. This makes Data Exchange aware of the full identifier which includes the DX ID as well as the destination ID. With this information Data Exchange can validate the sender and recipient destinations whenever a message is sent or a blob is transferred. This happens at both the API and P2P levels. The reason the check is performed in both places is to cover the unexpected scenario where the Data Exchange instances get out of sync e.g. FireFly did not send the peer information.

Note that Data Exchange automatically associates destinations with peer information. This is for optimization purposes. More specifically, Data Exchange will not create multiple copies of the same certificate file. Instead each certificate will continue to be associated with a peer, and each peer can have 0-to-many destinations.

Similarly to how peers work, one can optionally pre-populate destinations in the Data Exchange configuration file for both sender and recipients (see changes in the configuration schema and sample config files). When invoking the PUT /api/v1/peers/id1/id2 endpoint, Data Exchange will persist on disk the destination (if it hadn't been already added) under destinations/data.json. Removing that file would be the equivalent of doing a "factory reset" where Data Exchange would fall back to the defaults set in the configuration file.

With these changes any call with an unknown destination on either the sender or the recipient will raise an error. The error messages are very detailed, showing what the valid destinations are (for sender and/or recipient) and which one was provided.

Finally, backward compatibility is preserved, making it possible to use Data Exchange seamlessly with and without destinations.

if (recipientURL === undefined) {
throw new RequestError(`Unknown recipient`, 400);
let recipientEndpoint: string;
recipientEndpoint = config.p2p.endpoint ?? `https://${config.p2p.hostname}:${config.p2p.port}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong... maybe this was supposed to be inside the if below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precisely

@gabriel-indik
Copy link
Contributor Author

Updated PR: #67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants