Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MyDidCom/mydid-auth
https://github.com/MyDidCom/mydid-auth
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/MyDidCom/mydid-auth
- Owner: MyDidCom
- Created: 2021-10-25T08:06:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-27T13:34:39.000Z (5 months ago)
- Last Synced: 2024-08-27T14:58:51.051Z (5 months ago)
- Language: TypeScript
- Size: 387 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-ccamel - MyDidCom/mydid-auth - (TypeScript)
README
# mydid-auth
## Usage
Install package :
```shell
npm i @mydidcom/mydid-auth
```Import package :
```javascript
const mydidAuth = require("@mydidcom/mydid-auth");
```
**Initialize with provider and smart contract address :**_initialize: (config: object)_
```javascript
try {
mydidAuth.initialize({
web3GivenProvider: "https://data-seed-prebsc-1-s1.binance.org:8545/",
smartContractAddress: "0x6828adf1aED03be429eE42053a4F72CDd3c70846",
});
} catch (err) {
// Handle error
console.log("Error trying to initialize mydid-auth : " + err);
}
```> If module is not initialized, will used default value :
>
> - web3GivenProvider: 'https://data-seed-prebsc-1-s1.binance.org:8545/'
> - smartContractAddress: '0x6828adf1aED03be429eE42053a4F72CDd3c70846'
**Create verifiable presentation request :**_createVPRequest: (challenge: string, domain: string, verifiableCredentials: string[])_
```javascript
const VPRequest = mydidAuth.createVPRequest(
// Custom string for identifying challenge in database
"6360c6acfe7951946f0532dcee1d314645312a4b5480d80646ff9241ce68892d",
// Callback where will be sent verifiable presentation
"https://mywebsite.com/api/v1/callback",
// Verifiable credentials asked for authentication
["email", "nationality"]
);
```> If not verifiable credentials are needed, set verifiableCredentials to an empty array.
**Validate consistency of verifiable presentation :**_validateVPConsistency: (VPData: object)_
```javascript
try {
mydidAuth.validateVPConsistency(verifiablePresentation);
} catch (err) {
// Handle error
console.log('Can't valid verifiable presentation consistency : ' + err);
}
```
**Validate authenticity of verifiable presentation :**_validateVPAuthenticity: async (VPData: object)_
```javascript
try {
await mydidAuth.validateVPAuthenticity(verifiablePresentation);
} catch (err) {
// Handle error
console.log('Can't valid verifiable presentation authenticity : ' + err);
}
```