{"id":19901912,"url":"https://github.com/hyperledger/firefly-dataexchange-https","last_synced_at":"2025-05-02T23:32:02.489Z","repository":{"id":41848524,"uuid":"370389868","full_name":"hyperledger/firefly-dataexchange-https","owner":"hyperledger","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-24T08:54:03.000Z","size":855,"stargazers_count":11,"open_issues_count":6,"forks_count":14,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-01T09:05:25.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperledger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-24T14:57:35.000Z","updated_at":"2025-03-11T17:20:29.000Z","dependencies_parsed_at":"2024-03-28T20:40:29.468Z","dependency_job_id":"a5861373-4ac4-4bbe-85ba-2aa78130f8d4","html_url":"https://github.com/hyperledger/firefly-dataexchange-https","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Ffirefly-dataexchange-https","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Ffirefly-dataexchange-https/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Ffirefly-dataexchange-https/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Ffirefly-dataexchange-https/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperledger","download_url":"https://codeload.github.com/hyperledger/firefly-dataexchange-https/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252122297,"owners_count":21698305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T20:16:35.492Z","updated_at":"2025-05-02T23:32:01.649Z","avatar_url":"https://github.com/hyperledger.png","language":"TypeScript","readme":"# Firefly MTLS Data Exchange\n\nThe following steps show how to setup Firefly MTLS Data Exchange for two organizations named `org-a` and `org-b` running on `localhost`.\n\n![Data exchange diagram](./diagram.png)\n\n`org-a` will use port `3000` for API and port `3001` for P2P. `org-b` will use port `4000` for API and port `4001` for P2P. Each organization will have its own private key and self-signed certificate.\n\n## Setup org-a\n\n#### Environment variables\n\nOpen a command line window and set the following environment variables, assigning an appropriate location to `DATA_DIRECTORY`. This is where configuration and certificate files will reside:\n```\nexport DATA_DIRECTORY=/data-a\nexport LOG_LEVEL=info\n```\n\n#### Configuration file\n\nCreate `config.json` in the data directory and set its content to:\n```\n{\n  \"$schema\": \"../../src/schemas/config.json\",\n  \"api\": {\n    \"hostname\": \"0.0.0.0\",\n    \"port\": 3000\n  },\n  \"p2p\": {\n    \"hostname\": \"0.0.0.0\",\n    \"port\": 3001\n  },\n  \"apiKey\": \"xxxxx\",\n  \"peers\": [\n    {\n      \"id\": \"org-b\",\n      \"endpoint\": \"https://localhost:4001\"\n    }\n  ]\n}\n```\n\nBased on this configuration:\n- API will be accessed via 0.0.0.0:3000\n- P2P communications will use 0.0.0.0:3001\n- The API key will be set to `xxxxx` (this is optional)\n- There is one peer named `org-b` whose P2P endpoint is `https://localhost:4001`\n\nNote: the property `p2p.endpoint` can optionally be used to specify a front facing endpoint.\nIf this property is not provided, the p2p endpoint will be calculated as `p2p.hostname`:`p2p.port`\n\n#### Generate certificate\n\nIn the data directory, run the following command:\n```\nopenssl req -new -x509 -nodes -days 365 -subj '/CN=localhost/O=org-a' -keyout key.pem -out cert.pem\n```\nThis will generate files `key.pem` and `cert.pem`. Notice that the common name is `localhost` while the organization name is `org-a`.\n\n## Setup org-b\n\n#### Environment variables\n\nOpen a second command line window and set the following environment variables, assigning an appropriate location to `DATA_DIRECTORY`. This is where configuration and certificate files will reside:\n```\nexport DATA_DIRECTORY=/data-b\nexport LOG_LEVEL=info\n```\n\n#### Configuration file\n\n```\n{\n  \"$schema\": \"../../src/schemas/config.json\",\n  \"api\": {\n    \"hostname\": \"0.0.0.0\",\n    \"port\": 4000\n  },\n  \"p2p\": {\n    \"hostname\": \"0.0.0.0\",\n    \"port\": 4001\n  },\n  \"apiKey\": \"xxxxx\",\n  \"peers\": [\n    {\n      \"id\": \"org-b\",\n      \"endpoint\": \"https://0.0.0.0:3001\"\n    }\n  ]\n}\n```\n\nBased on this configuration:\n- API will be accessed via 0.0.0.0:4000\n- P2P communications will use 0.0.0.0:4001\n- The API key will be set to `xxxxx` (this is optional)\n- There is one peer named `org-a` whose P2P endpoint is `https://localhost:3001`\n\nNote: the property `p2p.endpoint` can optionally be used to specify a front facing endpoint.\nIf this property is not provided, the p2p endpoint will be calculated as `p2p.hostname`:`p2p.port`\n\n#### Generate certificate\n\n```\nopenssl req -new -x509 -nodes -days 365 -subj '/CN=localhost/O=org-b' -keyout key.pem -out cert.pem\n```\n\nThis will generate files `key.pem` and `cert.pem`. Notice that the common name is `localhost` while the organization name is `org-b`.\n\n## Copy certificates\n\n- Copy `/org-a/cert.pem` to `/org-b/peer-certs/org-a.pem`.\n- Copy `/org-b/cert.pem` to `/org-a/peer-certs/org-b.pem`.\n\nThis will make it possible for the organizations to establish MTLS communications with each other.\n\n## Build and run the processes\n\n- Run `npm run build`.\n- In the command line window for `org-a` run `npm start`\n- In the command line window for `org-b` run `npm start`\n\n## Access the API Swagger\n\n- Open a new web browser window and navigate to `http://localhost:3000`\n- Open another web browser window and navigate to `http://localhost:4000`\n\n## WebSocket Events\n\n\n| Type            | Description                                                | Additional properties\n|-----------------|------------------------------------------------------------|-----------------------\n|blob-received    | Emitted to the recipient when a blob has been transferred  | sender, path, hash\n|blob-delivered   | Emitted to the sender when a blob has been delivered       | recipient, path, requestId (optional)\n|blob-failed      | Emitted to the sender when a blob could not be delivered   | recipient, path, requestId (optional)\n|message-received | Emitted to the recipient when a message has been sent      | sender, message\n|message-delivered| Emitted to the sender when a message has been delivered    | recipient, message, requestId (optional)\n|message-failed   | Emitted to the sender when a message could not be delivered| recipient, message, requestId (optional)\n\n- After receiving a websocket message, an ack must be sent (\"commit\" is a synonym for \"ack\"):\n  ```\n  { \"action\": \"ack\", \"id\": \"\u003cID_FROM_EVENT\u003e\" }\n  ```\n- Messages arrive in the same order they were sent\n- Up to 1,000 messages will be queued\n\n## Alternative setup using CA\n\nGenerate CA key and cert:\n```\nopenssl req -new -x509 -nodes -days 365 -subj '/CN=blob-exchange-ca' -keyout ca-key.pem -out ca.crt\n```\n\nGenerate `org-a` key:\n```\nopenssl genrsa -out org-a.key 2048\n```\nGenerate `org-a` CSR:\n```\nopenssl req -new -key org-a.key -subj '/CN=localhost,O=org-a' -out org-a.csr\n```\nCreate signed certificate using CSR, CA\n```\nopenssl x509 -req -in org-a.csr -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -days 365 -out org-a.crt\n```\nGenerate `org-b` key:\n```\nopenssl genrsa -out org-b.key 2048\n```\nGenerate `org-b` CSR:\n```\nopenssl req -new -key org-b.key -subj '/CN=localhost,O=org-b' -out org-b.csr\n```\nCreate signed certificate using CSR, CA\n```\nopenssl x509 -req -in org-b.csr -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -days 365 -out org-b.crt\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger%2Ffirefly-dataexchange-https","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperledger%2Ffirefly-dataexchange-https","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger%2Ffirefly-dataexchange-https/lists"}