Skip to content

frazur/alastria-identity-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example of how to use the Alastria Identity Library

What it does

This is an example of how to interact with the libraries from alastria-identity-lib. The library alastria-identity-lib recovers the Smart Contracts from alastria-identity.

Important: You need to clone again this repository or update alastria-identity whenever a deploy of new smart contracts is made. You easily update your repo with:

# Being in the alastria-identity-example directory
cd node_modules/alastria-identity-lib/alastria-identity
git pull
cd ..
node src/configFile.js
tsc

Folders of example

Folder What it does Wiki page
exampleCreateAlastriaID Contains an example of how to create an Alastria ID Wiki
exampleTokens Contains an example of how to interact with tokenFactory.ts functions Wiki
exampleCredentials Contains examples of how to add and get Credentials in AlastriaID Wiki
examplePresentations Contains examples of how to create, add and get Presentations in AlastriaID Wiki
exampleIdentityServiceProvider Contains an example of how to add and remove a Identity Service Provider Wiki
exampleIdentityIssuer Contains an example of how to add and remove a Identity Issuer Wiki
exampleFirstEntity Contains an example of how to create the first identity with the admin account Wiki
exampleEntities Contains an example of get list of entities and get entity information Wiki
exampleAuthentication It contains an example of how authentication is done Wiki
keystores Contains the mocked keystores that we used to create the identities with different roles. These roles are explained here

How to use it

Then you can consume this library by running:

npm install

Now, you can use it from any JavaScript file in your working directory.

You can execute some of our examples by running:

cd example<FirstEntity, CreateAlastriaID, Credentials, Presentations, ...>

Then you can run the scripts in the correct order marked in each of the scripts

node x.<script>

Code linter and formatter

The project uses ESLint as Javascript linter and Prettier as code formatter

We strongly recommend using VSCode as code editor due to the plugins available to install, witch will make us work better and easier

The recommended plugins to use these tools are

The repository already has configuration files for both, so you won't have to configure anything after the plugins installation

How to use them?

  • ESLint: running npm run lint will show any linter errors. Some errors may be automatically fixed if the flag --fix is added to the script execution. Also, thanks to the ESLint plugin, VSCode will mark linter errors with red color and warnings with yellow color
  • Prettier: with a file open, cmd+shift+p (macOS) to open VSCode execution menu, write Format document with... and choose Prettier or configure your VSCode workspace to automatically use Prettier if you choose Format document: in your VSCode settings.json add
"[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
"[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }

To automatically format Javascript and Typescript code

If you have installed some plugin that add keyboard shortcuts, like IntelliJ IDEA Keybindings (https://marketplace.visualstudio.com/items?itemName=k--kato.intellij-idea-keybindings) you will be able to format documents with Prettier with shortcuts like cmd+alt+l

About

An example of using alastria-identity-lib

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.8%
  • Shell 3.2%