-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from Adamant-im/dev
v2.0.0
- Loading branch information
Showing
43 changed files
with
18,697 additions
and
11,718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
env: { | ||
commonjs: true, | ||
es2021: true, | ||
browser: true, | ||
node: true, | ||
'jest/globals': true, | ||
}, | ||
extends: ['eslint:recommended', 'google'], | ||
plugins: ['jest'], | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
}, | ||
rules: { | ||
'max-len': [ | ||
'error', | ||
{ | ||
code: 200, | ||
ignoreTrailingComments: true, | ||
ignoreUrls: true, | ||
ignoreStrings: true, | ||
ignoreTemplateLiterals: true, | ||
ignoreRegExpLiterals: true, | ||
}, | ||
], | ||
'require-jsdoc': 'off', | ||
'quote-props': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,7 @@ | |
coverage | ||
node_modules | ||
npm-debug.log | ||
logs | ||
.vscode | ||
config.json | ||
config.2fa.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,100 @@ | ||
# ADAMANT 2FA Demo application | ||
## What is ADAMANT 2FA | ||
ADAMANT 2FA is a service to deliver one-time passwords (OTP) to ADAMANT Messenger account. | ||
|
||
It is cheaper, more secure and reliable than SMS. [ADAMANT 2FA advantages](https://medium.com/adamant-im/adamant-is-working-on-a-perfect-2fa-solution-15280b8a3349). | ||
# ADAMANT 2FA Demo Application | ||
|
||
Live demo is available at [2fa-demo.adamant.im](https://2fa-demo.adamant.im/signup). For instructions, read [Presenting ADAMANT 2FA article](https://medium.com/adamant-im/presenting-adamant-2fa-838db2322f7a). | ||
## What is ADAMANT 2FA | ||
|
||
## How to connect | ||
If you own your service and want to add 2FA security for users, connect ADAMANT 2FA. It is perfect for crypto exchanges, webmail services, financial services. | ||
ADAMANT 2FA is a service to deliver one-time passwords (OTP) to ADAMANT Messenger account. | ||
|
||
To use ADAMANT 2FA, you have to install [ADAMANT Console](https://github.com/Adamant-im/adamant-console) on your server and use [`Send message`](https://github.com/Adamant-im/adamant-console/wiki/Available-Commands#message) method. 2FA codes are sent from account set in Console’s configuration. Other than that, ADAMANT 2FA implementation is no different from classical approaches of sending one-time codes. Read more: [How to connect ADAMANT 2FA to your business](https://medium.com/adamant-im/go-to-secure-2fa-on-a-blockchain-344500a5f010). | ||
It's cheaper, more secure and reliable than SMS. [ADAMANT 2FA advantages](https://medium.com/adamant-im/adamant-is-working-on-a-perfect-2fa-solution-15280b8a3349). | ||
|
||
This repository is only an example of ADAMANT 2FA implementation. | ||
Live demo is available at [2fa-demo.adamant.im](https://2fa-demo.adamant.im/signup). For details read [Presenting ADAMANT 2FA](https://medium.com/adamant-im/presenting-adamant-2fa-838db2322f7a). | ||
|
||
## Prerequisites | ||
* [adamant-console](https://github.com/Adamant-im/adamant-console/wiki/Installation-and-configuration) | ||
|
||
* [PostgreSQL](https://www.postgresql.org/download/) | ||
|
||
## Setup | ||
### Clone repository and install dependencies | ||
$ git clone https://github.com/Adamant-im/adamant-2fa.git | ||
$ cd adamant-2fa && npm i | ||
$ cd client && yarn install | ||
$ cd ../ | ||
### Create user and database | ||
$ sudo -u postgres psql | ||
postgres=# CREATE USER "adamant-2fa" WITH PASSWORD 'password'; | ||
postgres=# CREATE DATABASE "adamant-2fa" WITH OWNER "adamant-2fa"; | ||
$ sudo nano /etc/postgresql/10/main/pg_hba.conf | ||
local adamant-2fa adamant-2fa md5 | ||
$ sudo service postgresql restart | ||
### Create tables for Loopback models | ||
$ cd server && node create-lb-tables.js | ||
$ cd ../ | ||
## Development | ||
### Serve | ||
$ node . | ||
$ cd client && yarn serve | ||
|
||
Clone repository and install dependencies: | ||
|
||
``` bash | ||
git clone https://github.com/Adamant-im/adamant-2fa.git | ||
cd adamant-2fa && npm i | ||
cd client && yarn install | ||
cd ../ | ||
``` | ||
|
||
Create db-user and 2fa database: | ||
|
||
``` | ||
sudo -u postgres psql | ||
postgres=# CREATE USER "adamant-2fa" WITH PASSWORD 'password'; | ||
postgres=# CREATE DATABASE "adamant-2fa" WITH OWNER "adamant-2fa"; | ||
``` | ||
|
||
Set up md5 auth method. | ||
Get hba_file path: | ||
|
||
``` | ||
postgres=# SHOW hba_file; | ||
hba_file | ||
------------------------------------- | ||
/usr/local/var/postgres/pg_hba.conf | ||
(1 row) | ||
``` | ||
|
||
Update hba_file and restart postgresql: | ||
|
||
``` bash | ||
sudo nano /usr/local/var/postgres/pg_hba.conf | ||
local adamant-2fa adamant-2fa md5 | ||
sudo service postgresql restart | ||
``` | ||
|
||
Create tables for Loopback models: | ||
|
||
``` bash | ||
cd server && node create-lb-tables.js | ||
cd ../ | ||
``` | ||
|
||
Set up ADAMANT `passPhrase` to send 2fa codes from: | ||
|
||
``` | ||
cp config.default.json config.json | ||
nano config.json | ||
``` | ||
|
||
The 2FA app uses `config.json` file. Enter your ADM passphrase into `passPhrase` field. Make sure this account has ADM to send messages with 2fa codes. [How to create ADM account and get free tokens](https://medium.com/adamant-im/how-to-start-with-a-blockchain-messenger-54d1eb9704e6). | ||
|
||
Note: 2FA demo uses [adamant-console](https://github.com/Adamant-im/adamant-console/) to send 2fa codes. If you have this tool installed separately, make sure it's default config doesn't exist, or set to `mainnet` and correct `passPhrase`. | ||
|
||
Note: If the app doesn't send 2FA codes, debug console shows `{"success":false,"errorMessage":"Wrong 'passPhrase' parameter"}`. Make sure you've created `config.json` in the root directory (where `package.json` located), and you've set `passPhrase` and `network` parameters. | ||
|
||
## Start | ||
|
||
### Serve (Dev mode) | ||
|
||
``` bash | ||
node . | ||
cd client && yarn serve | ||
``` | ||
|
||
### Build | ||
$ cd client && yarn build | ||
$ npm i -g serve | ||
$ serve dist | ||
|
||
``` | ||
cd client && yarn build | ||
yarn serve-build | ||
``` | ||
|
||
### Launch as process manager process | ||
|
||
We recommend to use a process manager to start the program, f. e. [`pm2`](https://pm2.keymetrics.io/): | ||
|
||
``` | ||
pm2 start ./server/server.js --name 2fa-demo-server | ||
pm2 start ./client/server.js --name 2fa-demo-client | ||
``` | ||
|
||
## How to connect ADAMANT 2FA to your service | ||
|
||
If you own a service (as email, exchange, financial interface, etc.) and want to add 2FA security for users, connect ADAMANT 2FA. To use ADAMANT 2FA, clone this project and modify client and server parts. Read more: [How to connect ADAMANT 2FA to your business](https://medium.com/adamant-im/go-to-secure-2fa-on-a-blockchain-344500a5f010). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,3 @@ | ||
# client | ||
# Client part of ADAMANT 2FA Demo Application | ||
|
||
## Project setup | ||
``` | ||
yarn install | ||
``` | ||
|
||
### Compiles and hot-reloads for development | ||
``` | ||
yarn run serve | ||
``` | ||
|
||
### Compiles and minifies for production | ||
``` | ||
yarn run build | ||
``` | ||
|
||
### Run your tests | ||
``` | ||
yarn run test | ||
``` | ||
|
||
### Lints and fixes files | ||
``` | ||
yarn run lint | ||
``` | ||
|
||
### Run your end-to-end tests | ||
``` | ||
yarn run test:e2e | ||
``` | ||
|
||
### Run your unit tests | ||
``` | ||
yarn run test:unit | ||
``` | ||
|
||
### Customize configuration | ||
See [Configuration Reference](https://cli.vuejs.org/config/). | ||
See repository's README.md. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.