{"id":19198499,"url":"https://github.com/virgilsecurity/demo-nexmo-chat-server","last_synced_at":"2026-06-23T19:30:17.783Z","repository":{"id":44177287,"uuid":"116400915","full_name":"VirgilSecurity/demo-nexmo-chat-server","owner":"VirgilSecurity","description":"Application API server for the Virgil Nexmo Demo Messaging app. ","archived":false,"fork":false,"pushed_at":"2022-12-08T10:35:50.000Z","size":198,"stargazers_count":1,"open_issues_count":12,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-04T11:12:46.843Z","etag":null,"topics":["api","chat","cryptography","demo","encryption","messenger","nexmo","server"],"latest_commit_sha":null,"homepage":"https://github.com/VirgilSecurity/demo-nexmo-chat-android","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/VirgilSecurity.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}},"created_at":"2018-01-05T15:47:55.000Z","updated_at":"2021-05-30T08:09:14.000Z","dependencies_parsed_at":"2023-01-25T03:00:16.271Z","dependency_job_id":null,"html_url":"https://github.com/VirgilSecurity/demo-nexmo-chat-server","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirgilSecurity%2Fdemo-nexmo-chat-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirgilSecurity%2Fdemo-nexmo-chat-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirgilSecurity%2Fdemo-nexmo-chat-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirgilSecurity%2Fdemo-nexmo-chat-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VirgilSecurity","download_url":"https://codeload.github.com/VirgilSecurity/demo-nexmo-chat-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271539,"owners_count":19774859,"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":["api","chat","cryptography","demo","encryption","messenger","nexmo","server"],"created_at":"2024-11-09T12:22:29.584Z","updated_at":"2026-06-23T19:30:17.739Z","avatar_url":"https://github.com/VirgilSecurity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Virgil Nexmo Demo Chat API v2 Sample Backend\n\nApplication API server for the [Virgil Nexmo In-app Messaging Demo app](https://github.com/VirgilSecurity/demo-nexmo-chat-android). Its primary purpose is to register users' Virgil Cards on  Virgil's Cards service and generate JWTs for users to access Nexmo and Virgil APIs. This server \nis intended for demonstration purposes only, it does not implement request authentication strategy. Feel free to implement your own auth tech and/or copy the code into your own backend.\n\n ## Contents\n * [Deployment](#deployment)\n    * [Pre-requisites](#pre-requisites)\n    * [Setup instructions](#setup-instructions)\n * [Endpoints](#endpoints)\n    * [POST /users](#post-users)\n    * [GET /users](#get-users)\n    * [POST /conversations](#post-conversations)\n    * [PUT /conversations](#put-conversations)\n    * [GET /nexmo-jwt](#get-nexmo-jwt)\n    * [GET /virgil-jwt](#get-virgil-jwt)\n * [Errors](#errors)\n\n## Deployment\n\n### Pre-requisites\n\n* Ensure you have [Node.js](https://nodejs.org/en/) \u003e= 8 installed\n* Create a free [Virgil Security](https://dashboard.virgilsecurity.com/) account\n* Create a free [Nexmo](https://dashboard.nexmo.com/) account\n* Install the Nexmo CLI (note the `@beta` tag):\n\t```sh\n\tnpm install -g nexmo-cli@beta\n\t```\n\tSetup the CLI to use your Nexmo API Key and API Secret. You can get these from the \n\t[settings](https://dashboard.nexmo.com/settings) page in the Nexmo Dashboard.\n\t```sh\n\tnexmo setup api_key api_secret\n\t```\n\n### Setup instructions\n\n* Clone this Node sample server repo to your disk and step into the project's folder\n\t```sh\n\tgit clone https://github.com/VirgilSecurity/demo-nexmo-chat-server.git\n\tcd demo-nexmo-chat-server\n\t```\n\t\n* Create a Nexmo Application\n\t```sh\n\tnexmo app:create \"My Stitch App\" https://example.com/answer https://example.com/event --type=rtc --keyfile=private.key\n\t```\n\t\n* Install the Virgil Node sample server package and run setup. The set setup will ask you a few questions...\n\t```sh\n\tnpm install\n\tnpm run setup\n\t```\n\t\n* To provide the first input, create an **END-TO-END ENCRYPTION** Application in the Virgil Security [Dashboard](https://dashboard.virgilsecurity.com/apps/new) and copy the APP ID here:\n\t```sh\n\t? Enter your Virgil Security Application ID [paste Virgil APP ID here]\n\t```\n\t\n* Go back to the Virgil Dashboard [API Keys page and create one](https://dashboard.virgilsecurity.com/api-keys), it will be copied to your clipboard.\n\t```sh\n\t? Enter your Virgil Security API Key private key [paste it here]\n\t```\n\n* Now, on the Virgil API keys page, find your new API key in the list and copy its API KEY ID.  \n\t```sh\n\t? Enter your Virgil Security API Key ID [paste it here]\n\t```\n\t\n* Get your [Nexmo API keys](https://dashboard.nexmo.com/getting-started-guide) and complete the rest of the questions:\n\t```sh\n\t? Enter the path to your Nexmo app conifg file (.nexmo-app) [simply hit enter]\n\t? Enter your Nexmo API Key [paste your Nexmo API key]\n\t? Enter your Nexmo API Secret [paste your Nexmo API secret]\n\t```\n\t\n* Now the Virgil node backend server is ready to start:\n\t```sh\n\tnpm start\n\t```\n\t\n* You can test it at http://localhost:3000\n\nLeave the server running and continue your mobile app setup: [Android](https://github.com/VirgilSecurity/demo-nexmo-chat-android)  iOS \u0026 JS coming soon\n\n\n ## Endpoints\n Use this part of the readme to understand what this backend sample does and how it fits in with your own backend.\n \n ### POST /users\n \n An endpoint to register new user. Expects a _Raw Card_ in base64 string form as its only parameter.\n The raw card must have unique identity, attempt to register a card with duplicate identity will result in\n `400 BadRequest` error.\n \n **Request**\n ```json\n{\n\t\"raw_card_string\": \"eyJjb250ZW50X3NuYXBzaG90IjoiZXlKcFpHVnVkR2...k9In19fQ==\"\n}\n```\n\n**Response**\n\nIf request is successful, an object representing a [Nexmo user](https://developer.nexmo.com/stitch/in-app-messaging/guides/simple-conversation)\nis returned along with the base64 string representation of the user's Virgil Card and two JWTs for Nexmo and Virgil\nAPIs:\n\n\u003e Request must include `Content-Type: \"application/json\"` header \n \n```json\n{\n\t\"user\": {\n\t\t\"id\": \"USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\t\"href\": \"http://conversation.local/v1/users/USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\t\"virgil_card\": \"eyJjb250ZW50X3NuYXBzaG90IjoiZXlKcFpHVnVkR2...k9In19fQ==\"\n\t},\n\t\"nexmo_jwt\": \"xxxxx.yyyyy.zzzzz\",\n\t\"virgil_jwt\": \"qqqqq.bbbbb.ddddd\"\n}\n```\nYou can then use the `CardManager` from virgil sdk to `import` a Virgil Card from this string. The `nexmo_jwt` and\n `virgil_jwt` can be used to initialize the appropriate API client.\n\n### GET /users\n\nAn endpoint to retrieve a list of users.\n\n**Response**\n\n```json\n[\n\t{\n\t\t\"name\": \"Dillon\",\n\t\t\"id\": \"USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\t\"href\": \"http://conversation.local/v1/users/USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\"\n\t}\n]\n```\n\n### POST /conversations\n\nAn endpoint to create a new [Nexmo Conversation](https://developer.nexmo.com/stitch/in-app-messaging/guides/simple-conversation)\n\n**Request**\n\n```json\n{\n\t\"display_name\": \"My new conversation\" \n}\n```\n\n**Response**\n\n```json\n{\n\t\"id\": \"CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\"href\": \"http://conversation.local/v1/conversations/CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\"\n}\n```\n   \n### PUT /conversations\n\nAn endpoint to add a user to a conversation.\n\n**Request**\n\n```json\n{\n\t\"conversation_id\": \"CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\"user_id\": \"USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\"action\": \"join\"\n}\n```\n\nParameter action must be \"join\" to add the user to the conversation. Other types of actions - TBD.\n\n**Response**\n\n```json\n{ \n\t\"id\": \"MEM-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\"user_id\": \"USR-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\",\n\t\"state\": \"JOINED\",\n\t\"timestamp\": { \"joined\": \"2018-01-15T15:17:59.248Z\" },\n\t\"channel\": { \"type\": \"app\" },\n\t\"href\": \"http://conversation.local/v1/conversations/CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab/members/MEM-aaaaaaaa-bbbb-cccc-dddd-0123456789ab\"\n}\n```\n\n### GET /nexmo-jwt?identity=[YOUR_USER_IDENTITY]\n\nAn endpoint to obtain an access token for the Nexmo API. The URL must include a query parameter named `identity` that is the identity of the user to issue the token for.\n\n**Response**\n```json\n{\n\t\"jwt\": \"xxxxx.yyyyy.zzzzz\"\n}\n```\n\n### GET /virgil-jwt\n\nAn endpoint to obtain an access token for the Virgil Security API. The URL must include a query parameter named `identity` that is the identity of the user to issue the token for.\n\n**Response**\n```json\n{\n\t\"jwt\": \"qqqqq.bbbbb.ddddd\"\n}\n```\n\n## Errors\n\nApplication uses standard HTTP response codes:\n\n```\n200 - Success\n400 - Request error\n500 - Server error\n```\n\nAdditional information about the error is returned in response body as JSON object:\n```json\n{\n\t\"status\": 500,\n\t\"error_code\": 50000,\n\t\"message\": \"Message containing error details\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgilsecurity%2Fdemo-nexmo-chat-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirgilsecurity%2Fdemo-nexmo-chat-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgilsecurity%2Fdemo-nexmo-chat-server/lists"}