express

This file specifies the Express routes for the API that supports the Directory UI.

express

express

This file contains the configurations for running the Express server that will serve API requests for the API specified in ./routes/api.js.

To run: $ node server.js

To run using forever: $ forever start server.js

express

fs

This file contains functions to query the registrations table in the alpha_kuwa_directory database to support the API in ./routes/api.js.

fs

fs

This program scans the directory in the Kuwa Storage Manager registrations repository containing the Kuwa client directories with the client address as the name of the directory. The directory hierarchy is as follows:

rootDir/ 0x6dc989e6d3582f5c3da1fd510a5b0ad950d67f3a/

  • info.json { "ClientAddress": "0x6dc989e6d3582f5c3da1fd510a5b0ad950d67f3a", "ContractAddress": "0x066335f8A852A6A0C2761e82829524eb8C950515", "ContractABI": "[{\"constant\":true,\"inputs\":[],..." }
  • video.mp4

Each Kuwa client directory will contain an 'info.json', which will contain the client address, the client's contract address, and the contract JSON ABI. It will also contain the video recording of the client speaking the challenge phrase.

The program will read the information necessary to load the Kuwa client's smart contract in order to call the getRegistrationStatus() function to obtain the status of the client.

It will then store this information into the 'registration' table of the MySQL DB so that one can quickly retrieve Kuwa client addresses with a certain status.

fs

Component

This file represents the React UI App for displaying the directory of Kuwa IDs. in tabular form.

The Kuwa client ID (Ethereum address), the client's contract address, the creation time, and the last status update time are displayed.

Users can select to only display Kuwa IDs with a certain status using the select box.

Component

get

Get all Kuwa IDs.

get

get

Get Kuwa IDs based on status.

req.params.status should be one of the following: "Valid", "Invalid", "Credentials-Provided", "Challenge-Expired", "Video-Uploaded", "QR-Code-Scanned"

get

cols

Get the selected columns from "config.json" converted to proper display format for the UI. We can perhaps have the column mappings as another table in the registration DB?

cols()

DirScanner

This class contains functions to scan the Kuwa client directories uploaded to the raw registrations repository by the Kuwa Storage Manager whenever a new user registers to become a Kuwa client.

new DirScanner(dirToScanPath: string, ethClient: EthClient)
Parameters
dirToScanPath (string) The absolute path to the root directory containing all the Kuwa client directories.
ethClient (EthClient) An object containing functions and variables to interact with the Ethereum blockchain.
Instance Members
getClientInfo(clientDir, files)
getDirListing(rootDir)
processClientDir(clientDir)

getAll

Get all Kuwa clients regardless of their status.

getAll(): Promise
Returns
Promise: A Promise object containing the rows of the query

getAllWithStatus

Get Kuwa clients with a certain status ("Valid", "Invalid", "Credentials-Provided", "Challenge-Expired", "Video-Uploaded", "QR-Code-Scanned").

Join with another SQL table? We can put status mappings in the "config.json" but that doesn't look right and is a bit hacky. See https://stackoverflow.com/questions/16753122/sql-how-to-replace-values-of-select-return

getAllWithStatus(status: string): Promise
Parameters
status (string) The status of the Kuwa client
Returns
Promise: A Promise object containing the rows of the query

ClientInfo

ClientInfo

Type: Object

Properties
status (string) : The current status of the Kuwa client
videoFilePath (string) : Absolute path to the video file of the user speaking the challenge phrase
ContractAddress (string) : The Ethereum address of the Kuwa client ("0x123abc...")
ContractABI (string) : The application binary interface (in JSON) of the Kuwa client's deployed contract

constructor

Creates a new MySQL database client.

new constructor(host: any, user: any, password: any, database: any)
Parameters
host (any)
user (any)
password (any)
database (any)

createConnection

Creates a new connection to the MySQL database.

createConnection(host: string, user: string, password: string, database: string): Object
Parameters
host (string) The hostname of the database to connect to
user (string) The user to authenticate as
password (string) The password of the user
database (string) The name of the database for the connection
Returns
Object: The connection object

insertOrUpdateSingle

Insert or update a single row in the table corresponding to a Kuwa client.

insertOrUpdateSingle(tableName: string, data: ClientInfo)
Parameters
tableName (string) Name of the table
data (ClientInfo) Information about a Kuwa client

createFromConfig

Create a database client using a configuration object from a configuration file.

createFromConfig(The: Object): DBClient
Parameters
The (Object) configuration object
Name Description
The.host any
The.user any
The.password any
The.database any
Returns
DBClient: The DBClient object created from a configuration object using destructuring assignment

constructor

Create a new client for interacting with the Ethereum blockchain.

new constructor(myAddress: string, keyStoreDir: string, password: string, ethNetworkUrl: string)
Parameters
myAddress (string) The address transactions should be sent from (the origin EOA or wallet address)
keyStoreDir (string) The Ethereum keystore directory containing the JSON file that contains the public/private key pair for the wallet
password (string) The password for recovering the private key from the JSON file
ethNetworkUrl (string) The URL to access the Ethereum network over HTTP

loadWallet

Loads an Ethereum wallet.

loadWallet()

loadContract

Loads an already deployed contract in the Ethereum blockchain.

loadContract(abi: string, contractAddress: string, gas: number, gasPrice: string)
Parameters
abi (string) The application binary interface (in JSON) of the Kuwa client's deployed contract
contractAddress (string) The address of the contract
gas (number) The maximum gas provided for this transaction (gas limit)
gasPrice (string) Amount of ether you're willing to pay for every unit of gas

createFromConfig

Create an Ethereum client using a configuration object from a configuration file.

createFromConfig(The: Object): EthClient
Parameters
The (Object) configuration object
Name Description
The.my_address any
The.key_store_dir any
The.password any
The.eth_network_url any
Returns
EthClient: An EthClient object created from a configuration object using destructuring assignment

getCurrentDateTime

getCurrentDateTime(): string
Returns
string: The current datetime (UTC) in 'yyyy-MM-dd HH:mm:ss' format.

run

Driver function to run the scan process.

run()