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
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 |
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>
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
- ESLint: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
- Prettier: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
The repository already has configuration files for both, so you won't have to configure anything after the plugins installation
- 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, writeFormat document with...
and choose Prettier or configure your VSCode workspace to automatically use Prettier if you chooseFormat document
: in your VSCodesettings.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