A simple Web application that demonstrates how the end-to-end encryption works. The application uses firebase as a backend service for authentication and chat messaging, and Virgil E3Kit SDK for end-to-end encryption.
Clone or download
Latest commit 1448f6e Jan 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Updated content Dec 14, 2018
.babelrc update e3kit Nov 21, 2018
.gitignore remove vscode folder Aug 22, 2018
.prettierrc init Aug 13, 2018
README.md Added link to e3kit SDK [ci skip] Jan 8, 2019
package-lock.json fix vulnerability warnings Jan 17, 2019
package.json fix vulnerability warnings Jan 17, 2019
tsconfig.json move to webpack Oct 29, 2018
tslint.json handle register and login errors Dec 11, 2018
webpack.config.js move to webpack Oct 29, 2018

README.md

End-to-end encrypted, HIPAA-compliant JavaScript demo chat app for Firebase.

You can reuse this sample in any your projects to protect user data, documents, images using Virgil's end-to-end encryption HIPAA whitepaper.

This Demo is based on Virgil E3Kit JS SDK.

Prerequisites

Clone JavaScript project

git clone https://github.com/VirgilSecurity/demo-firebase-js
cd demo-firebase-js

Connect your Virgil and Firebase accounts

To connect your Virgil and Firebase accounts for implementing end-to-end encryption to deploy a Firebase function that gives out Virgil JWT tokens for your authenticated users.

To deploy the function, head over to our GitHub repo and follow the instructions in README:

Configure Authentication

  • Select the Authentication panel and then click the Sign In Method tab.
  • Choose your authentication method and turn on the Enable switch, then follow instructions and click Save.

Configure Cloud Firestore

  • Let's also set up a Firestore database for the sample apps: select the Database panel, select Cloud Firestore click Create database under Firestore, choose Start in test mode and click Enable.
  • Once the database is created, click on the Rules tab, click Edit rules and paste:
    service cloud.firestore {
      match /databases/{database}/documents {
        match /{document=**} {
          allow read, write: if request.auth.uid != null;
        }
      }
    }
    
  • Click PUBLISH.

You only need to do this once - if you did it already earlier or for your Android or iOS apps, don't need to do it again.

Add your Firebase function URL and Firebase project config to app

  • Copy your new Firebase function's URL: go to the Firebase console -> your project -> Functions tab and copy your new function's url
  • Paste it into FIREBASE_FUNCTION_URL variable in src/models/UserModel.ts:
    const FIREBASE_FUNCTION_URL = 'https://YOUR_FIREBASE_ENDPOINT.cloudfunctions.net/api';
    
  • Go back to your project's page in Firebase console, click the gear icon -> Project settings
  • Click Add app and choose "</> Add Firebase to your web app"
  • Copy only this part to the clipboard:
      var config = {
        apiKey: "...",
        authDomain: "...",
        databaseURL: "...",
        projectId: "...",
        storageBucket: "...",
        messagingSenderId: "..."
      };
    
  • Replace the copied block in your src/firebase.ts file.

Test it

  • Update dependencies, build & run

    npm install
    npm run start
    
  • Browse to http://localhost:1234

  • Start a second incognito window to have 2 chat apps running with 2 different users

Remember, the app deletes messages right after delivery (it's a HIPAA requirement to meet the conduit exception). If you want to see encrypted messages in your Firestore database, run only 1 browser instance, send a message to your chat partner and check Firestore DB's contents before opening the other user's app to receive the message. If you don't want to implement this behavior in your own app, you can remove it from this sample here.