Skip to content

Commit

Permalink
Merge pull request #62 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
adamant-al authored Dec 18, 2022
2 parents d70b5dc + 50b2b1c commit 84b1000
Show file tree
Hide file tree
Showing 43 changed files with 18,697 additions and 11,718 deletions.
8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

29 changes: 29 additions & 0 deletions .eslintrc.js
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',
},
};
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
coverage
node_modules
npm-debug.log
logs
.vscode
config.json
config.2fa.json
123 changes: 90 additions & 33 deletions README.md
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).
13 changes: 7 additions & 6 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ module.exports = {
env: {
node: true
},
'extends': [
extends: [
'plugin:vue/essential',
'@vue/standard'
'standard'
],
rules: {
'max-len': [
'error', { 'code': 100 }
'error', { code: 100 }
],
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/multi-word-component-names': 'off'
},
parserOptions: {
parser: 'babel-eslint'
parser: '@babel/eslint-parser'
}
}
40 changes: 2 additions & 38 deletions client/README.md
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.
75 changes: 49 additions & 26 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,75 @@
{
"name": "client",
"version": "0.1.0",
"version": "2.0.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test:e2e": "vue-cli-service test:e2e",
"test:unit": "vue-cli-service test:unit"
"test:unit": "vue-cli-service test:unit",
"serve-build": "node server.js"
},
"dependencies": {
"@mdi/font": "^3.2.89",
"axios": "^0.18.0",
"material-design-icons-iconfont": "^4.0.3",
"register-service-worker": "^1.0.0",
"@mdi/font": "^7.1.96",
"@vue/babel-preset-app": "^5.0.8",
"axios": "^1.2.1",
"compression": "^1.7.4",
"connect-history-api-fallback": "^2.0.0",
"express": "^4.18.2",
"material-design-icons-iconfont": "^6.7.0",
"morgan": "^1.10.0",
"register-service-worker": "^1.7.2",
"roboto-fontface": "^0.10.0",
"split": "^1.0.1",
"vue": "^2.5.17",
"vue-axios": "^2.1.4",
"vue-axios": "^3.5.2",
"vue-i18n": "^8.0.0",
"vue-router": "^3.0.1",
"vuetify": "^1.3.0",
"vuex": "^3.0.1",
"vuex-persistedstate": "^2.5.4"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/eslint-parser": "^7.19.1",
"@kazupon/vue-i18n-loader": "^0.3.0",
"@vue/cli-plugin-babel": "^3.1.1",
"@vue/cli-plugin-e2e-nightwatch": "^3.1.1",
"@vue/cli-plugin-eslint": "^3.1.5",
"@vue/cli-plugin-pwa": "^3.1.2",
"@vue/cli-plugin-unit-jest": "^3.1.1",
"@vue/cli-service": "^3.1.4",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.20",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-plugin-e2e-nightwatch": "^5.0.8",
"@vue/cli-plugin-eslint": "^5.0.8",
"@vue/cli-plugin-pwa": "^5.0.8",
"@vue/cli-plugin-unit-jest": "5.0.8",
"@vue/cli-service": "^5.0.8",
"@vue/eslint-config-standard": "^8.0.1",
"@vue/test-utils": "^2.2.6",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-0",
"lint-staged": "^7.2.2",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.1",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"babel-jest": "^29.3.1",
"babel-plugin-polyfill-corejs2": "^0.3.3",
"babel-plugin-polyfill-corejs3": "^0.6.0",
"babel-plugin-polyfill-regenerator": "^0.4.1",
"chromedriver": "*",
"eslint": "8.29.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.6.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.8.0",
"jest": "^27.1.0",
"lint-staged": "^13.1.0",
"node-sass": "^7.0.1",
"sass-loader": "^13.2.0",
"stylus": "^0.59.0",
"stylus-loader": "^7.1.0",
"vue-cli-plugin-i18n": "^0.5.1",
"vue-cli-plugin-vuetify": "^0.4.6",
"vue-template-compiler": "^2.5.17",
"vuetify-loader": "^1.0.5"
"vue-jest": "^3.0.7",
"vue-template-compiler": "^2.7.14",
"vuetify-loader": "^1.9.2",
"webpack": "^5.75.0"
},
"resolutions": {
"loader-utils": "^2.0.4",
"minimatch": "^3.0.5",
"decode-uri-component": "^0.2.1"
},
"gitHooks": {
"pre-commit": "lint-staged"
Expand Down
Loading

0 comments on commit 84b1000

Please sign in to comment.