{"id":15065356,"url":"https://github.com/radovantrtil/matrix-communication-helper","last_synced_at":"2025-07-12T08:31:44.625Z","repository":{"id":148294979,"uuid":"605265514","full_name":"radovantrtil/matrix-communication-helper","owner":"radovantrtil","description":"Npm package to provide e2ee communication","archived":false,"fork":false,"pushed_at":"2023-06-18T20:23:12.000Z","size":178,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"io","last_synced_at":"2025-07-01T19:08:21.618Z","etag":null,"topics":["communication-protocol","e2ee","end-to-end-encryption","helper","matrix-js-sdk","matrix-org","nodejs","npm","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/matrix-communication-helper","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/radovantrtil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-22T19:54:20.000Z","updated_at":"2023-05-28T21:20:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"198071d0-96bd-4dd0-af8d-ceccdd814787","html_url":"https://github.com/radovantrtil/matrix-communication-helper","commit_stats":null,"previous_names":["radovantrtil/bp_xtrtil"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/radovantrtil/matrix-communication-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radovantrtil%2Fmatrix-communication-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radovantrtil%2Fmatrix-communication-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radovantrtil%2Fmatrix-communication-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radovantrtil%2Fmatrix-communication-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/radovantrtil","download_url":"https://codeload.github.com/radovantrtil/matrix-communication-helper/tar.gz/refs/heads/io","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radovantrtil%2Fmatrix-communication-helper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264962276,"owners_count":23689773,"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":["communication-protocol","e2ee","end-to-end-encryption","helper","matrix-js-sdk","matrix-org","nodejs","npm","npm-package"],"created_at":"2024-09-25T00:37:17.785Z","updated_at":"2025-07-12T08:31:44.348Z","avatar_url":"https://github.com/radovantrtil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Matrix communication helper\n\nMatrix communication helper is an [NPM](https://www.npmjs.com/package/matrix-communication-helper) package that provides end-to-end encrypted (e2ee) \nsecure communication between web services, built on top of the Matrix protocol.\nThis package makes it easy to send and receive encrypted messages, \ncreate and manage rooms, and invite users to rooms.\n\n## Requirements\n\n- Node.js version 18 or higher.\n- A valid account on the desired homeserver, \nwhere are NOT back up keys set up.\n\n## Installation\n\nTo install the package, run the following command:\n\n```\nnpm install matrix-communication-helper\n```\n\n## Web app - specific prerequisites\nIn WebApp, after install package, you need to move `olm.wasm file`\nfrom `node_modules/@matrix-org/olm` and put it in `public folder`\nand in web app you need to `declare variable global` before using this package.\n\n``` html\n\u003cscript\u003e var global = window; \u003c/script\u003e\n``` \n\n\n## Exported methods\n\n- `runClient(credentials)` Initializes and starts the Matrix client with the given credentials.\n- `createRoom(roomName)` Creates a new private, end-to-end encrypted room.\n- `inviteUser(roomId, userId)` Invites a user to a room. \n- `sendEncryptedMessage(roomId, message)` Sends an encrypted message to a room. \n- `sendMessage(roomId, message)` Sends a plain text message to a room.\n- `onMessage(roomId, onMessageCallback)` Sets up a message listener for plain text messages in a room.\n- `onEncryptedMessage(roomId, onMessageCallback)` Sets up a message listener for encrypted messages in a room.\n- `getJoinedRoomsID()` Retrieves an array of room IDs that the client has joined.\n- `getAllMemberUserIds(roomId)` Retrieves an array of room member's user ids.\n- `getMyPowerLevel(roomId)` Retrieves the power level of the client in a room. \n- `isCurrentClientJoinedInRoom(roomId)` Checks if the client is a member of a room.\n\n\n## Usage\n\n1. Import the package:\n\n```javascript\nimport m_helper from \"matrix-communication-helper\";\n```\n\n\n2. Provide the user's login credentials (homeserver URL, username and password as object):\n\n```javascript\nconst credentials = {\n    homeserverUrl: \"https://matrix.org\",\n    username: \"your-username\",\n    password: \"your-password\",\n};\n```\n   or in Node app use json file like this conf.json and add relative path to this file as parameter, e.g. \"./config.json\"  \n``` json\n{\n    \"homeserverUrl\": \"https://matrix.org\",\n    \"username\": \"yourUsername\",\n    \"password\": \"yourPassword\"\n}\n```\n3. Start the client with the provided credentials using object or file path to file with creds:\n\n```javascript\nm_helper.runClient(credentials)\n.then(() =\u003e {\n    // Your code here\n})\n.catch((error) =\u003e {\n    console.error(\"Error while running client:\", error);\n});\n```\n\n4. Use the available functions to perform various tasks, such as sending encrypted messages, listening for encrypted messages, inviting users to a room, and more. See the following examples:\n\n```javascript\nconst roomsID = await m_helper.getJoinedRoomsID();\nconst roomId = roomsID[0];\n\nconst mess = {\n    albumId: 1,\n    id: 2,\n    title: \"reprehenderit est deserunt velit ipsam\",\n    url: \"https://via.placeholder.com/600/771796\",\n    thumbnailUrl: \"https://via.placeholder.com/150/771796\",\n};\n\n// Send an encrypted message\nm_helper.sendEncryptedMessage(roomId, mess)\n.then((response) =\u003e {\n    console.log(response);\n})\n.catch((error) =\u003e {\n    console.error(\"Error while sending encrypted message:\", error);\n});\n\n// Listen for encrypted messages\nm_helper.onEncryptedMessage( roomId, (message) =\u003e {\n        console.log(\"Received message:\", message);\n    }\n);\n```\n\n## Contributing\n\nContributions to the package are welcome. Feel free to open an issue or submit a pull request on the repository.\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradovantrtil%2Fmatrix-communication-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradovantrtil%2Fmatrix-communication-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradovantrtil%2Fmatrix-communication-helper/lists"}