GithubHelp home page GithubHelp logo

virgilsecurity / virgil-e3kit-firebase-func Goto Github PK

View Code? Open in Web Editor NEW
21.0 11.0 5.0 2.1 MB

Backend's function that connects your Virgil and Firebase accounts for implementing end-to-end encryption

Home Page: https://developer.virgilsecurity.com/docs/use-cases/v5/encrypted-communication-for-firebase

License: BSD 3-Clause "New" or "Revised" License

TypeScript 37.51% JavaScript 62.49%
firebase end-to-end-encryption hipaa e3kit authentication

virgil-e3kit-firebase-func's Introduction

Configure your Firebase function to generate Virgil JWT

Greenkeeper badge

This repository contains a backend's function that connects your Virgil and Firebase accounts for implementing end-to-end encryption.

Prerequisites

  • Node version from 10 to 13

You can use one of node version managers to switch the version: n or nvm

Configure Your Firebase Project

We assume that you already have a Firebase Project. If you don't, please create one now at your Firebase Console.

Configure User Authentication

If you haven't already, set up Sign-in method in your Firebase Project by enabling any of the Sign-in providers. For the purposes of this tutorial it doesn't matter which sign-in provider you choose.

To set up your Sign-in method, go to your Firebase Console and navigate to Authentication, under Develop. Go to the Sign-in method tab and set up your preferred sing-in method(s).

Deploy the Firebase function

This Firebase function will connect Firebase's and Virgil's authentication via JWT tokens.

  • Clone this repository
    git clone https://github.com/VirgilSecurity/virgil-e3kit-firebase-func.git
    cd virgil-e3kit-firebase-func

Set up Firebase project

  • Install Firebase CLI if you haven't already:

    npm install -g firebase-tools
  • Start up the Firebase CLI:

    firebase login
  • Navigate to this repository and connect it to your Firebase project:

    firebase use --add
  • Select your Firebase project from the list and press ENTER.

  • Type an alias for your project and press ENTER again.

Connect repository to your Firebase project

Set up Virgil Application

  1. Navigate to the Virgil Dashboard -> Your Application -> E3Kit Section.

Virgil Application

  1. Generate .env in the .env file section.

Virgil Application .env generation

  1. Download the generated file, paste it into the project root folder and rename it to .env.

Virgil Application .env credentials

Install dependencies

  • To install dependencies and configure Virgil Credentials, in cmd navigate to the repository folder and run:

    cd functions
    npm install
    npm run configure

    In case you receive a message like warning found n vulnerabilities printed in the console after running the npm install, there is a potential security vulnerability in one of the demo's dependencies. Don't worry, this is a normal occurrence and in the majority of cases, is fixed by updating the packages. To install any updates, run the command npm audit fix. If some of the vulnerabilities persist after the update, check the results of the npm audit to see a detailed report. The report includes instructions on how to act on this information.

  • If npm install fails, make sure you have a compatible node version. See in Prerequisites.

  • Windows users only: In firebase.json rename $RESOURCE_DIR to %RESOURCE_DIR%

  • Optional: change the field used for identity to email, phone_number or any unique value in functions/src/index.ts . Default is uid (Firebase unique id)

Deploy function

⚠️ Since August 17, 2020, Firebase has changed their billing plans. In order to deploy the function and run this demo, you will need to change your project billing plan to "Blaze" in project settings "Usage and Billing".

  • Deploy the Firebase function:
    npm run deploy

Now, in your at your Firebase Console in "Develop" -> "Functions" you'll be able to see the function deployed:

Firebase function deployed

Troubleshooting

Error: Error parsing triggers: Cannot find module '../virgil_crypto_node.node'

Make sure you've followed the instructions in the README. If you did so, try running this command:

node node_modules/virgil-crypto/scripts/download-node-addon.js

TypeError: Cannot destructure property app_id of 'undefined' or 'null'.

You most likely forgot to generate the .env file or named it incorrectly. Make sure the file is named exactly .env (no '.txt' at the end and no other extensions) and contains your keys in a similar format:

APP_ID=40afa3ea[...]520c1be
APP_KEY_ID=0e6f[...]fd3476c3cf
APP_KEY=MC4CAQt[...]7DprlzC7gG1

License

This library is released under the 3-clause BSD License.

Support

Our developer support team is here to help you. Find out more information on our Help Center.

You can find us on Twitter or send us email [email protected].

Also, get extra help from our support team on Slack.

virgil-e3kit-firebase-func's People

Contributors

cardoso avatar dependabot[bot] avatar dkosolap avatar greenkeeper[bot] avatar mariiamalitska avatar unlim-it avatar vadimavdeev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virgil-e3kit-firebase-func's Issues

Error deploying to firebase

I followed the steps listed in this project and the deployment failed. Is this no longer maintained? If anyone has a working version, please share the working dependencies. Thank you!!

.env file not found error during configure

I followed the steps of generating the env file, paste it in the root folder, and then the following:

cd functions
npm install
npm run configure

At run configure, the following error was encountered:
Error: .env not found
at Object. (/Users/gerardheng1/virgil-e3kit-firebase-func/functions/utils/configure.js:6:22)

Syntax error caused by the 3 dots(...), please help ...


C:\Users\Cheaito\Desktop\Androd git\virgil-e3kit-firebase-func\functions\node_modules\chokidar\index.js:904
  const options = {type: EV_ALL, alwaysStat: true, lstat: true, ...opts};
                                                                ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\Cheaito\Desktop\Androd git\virgil-e3kit-firebase-func\functions\node_modules\firebase-tools\lib\emulator\functionsEmulator.js:21:18)

    at ChildProcess.exithandler (child_process.js:252:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:887:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'firebase functions:config:set virgil.app_key="APP_KEY" virgil.app_id="APP_ID" virgil.app_key_id="APP_KEY_ID"' }

Node version 8
Windows 10
npm 6.11.3

@xlwknx

Error while deploying Cloud Functions

i am getting the error Error: Illegal arguments for function privateKeyToDER when i run the command firebase deploy --only functions
Node version: 10.16.0
here is the log

Desktop/e2e_test/virgil-e3kit-firebase-func/functions/node_modules/virgil-crypto/dist/virgil-crypto.cjs.js:223:32)
    at Object.privateKeyToDer (Desktop/e2e_test/virgil-e3kit-firebase-func/functions/node_modules/virgil-crypto/dist/virgil-crypto.cjs.js:408:41)
    at VirgilCrypto.importPrivateKey (/Desktop/e2e_test/virgil-e3kit-firebase-func/functions/node_modules/virgil-crypto/dist/virgil-crypto.cjs.js:1364:43)
    at Object.<anonymous> (Desktop/e2e_test/virgil-e3kit-firebase-func/functions/lib/generate-virgil-jwt.js:18:20)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)

any thoughts about this?

Failing to install firebase function when running 'npm run configure': Error: Cannot find module 'exegesis/lib/errors'

I reported this issue in Virgil Slack a few days ago. But I guess it will be lost there soon. That´s why I post it here again for other developers to see my problem, in case it happens to them. I´ll update this issue once it is solved.

At the moment I´m trying to setup the virgil-js-demo. Running "npm run configure" gives me these errors. I´m following this video tutorial: https://youtu.be/YJ7pD_w_nUo?t=135
Any idea what´s wrong? Thanks

https://imgur.com/a/9ZQQ9HP
https://imgur.com/a/stoMO74

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.