src/api.js
/**
     * Attests Identity's credentials
     *
     * @param   {String}     identity     Identity's address
     * @param   {String}     seed         auth seed
     * @param   {String}     authPrivKey  Ecc auth private key. Used to decrypt the auth signature and the identity data
     * @returns {Object}                  An object that contains a boolean and the Identity's data when authorized
     * @memberof Api
     */
Attests Identity's credentials
@param   {String}     identity     Identity's address
@param   {String}     seed         auth seed
@param   {String}     authPrivKey  Ecc auth private key. Used to decrypt the auth signature and the identity data
@returns {Object}                  An object that contains a boolean and the Identity's data when authorized
@memberof Api
Attests Identity ' s credentials @param { String } identity Identity ' s address @param { String } seed auth seed @param { String } authPrivKey Ecc auth private key . Used to decrypt the auth signature and the identity data @returns { Object } An object that contains a boolean and the Identity ' s data when authorized @memberof Api
async checkAuthorized(identity, seed, authPrivKey) {
        let authObject = { authorized : false }
        const authCredentials = await this.ipfsService.getAuthCredentials(seed)
        if(authCredentials) {
            const decryptedSign = await Crypto.decryptEcc(authPrivKey, authCredentials.credentials)
            const signer = await this.web3Service.getCredentialsSigner(seed, decryptedSign.replace(/^"(.*)"$/, '$1'))
            if(signer) {
                try {
                    this.IdentityContract.options.address = identity
                    const identityOwner = await this.IdentityContract.methods.owner().call()
                    authObject.authorized = identityOwner == signer
                    const dataKeys = Object.keys(authCredentials.credentialsData)
                    if(dataKeys.length > 0){
                        let promises = []
                        dataKeys.forEach(nodeLabel => { promises.push(this.decryptCredentialsData(authCredentials, nodeLabel, authPrivKey)) })
                        return Promise.all(promises).then(data => {
                            authObject.data = authCredentials.credentialsData
                            return authObject
                        })
                    }
                }catch(err){}
            } 
        }
        return authObject        
    }
async checkAuthorized ( identity , seed , authPrivKey ) { let authObject = { authorized : false } const authCredentials = await this . ipfsService . getAuthCredentials ( seed ) if ( authCredentials ) { const decryptedSign = await Crypto . decryptEcc ( authPrivKey , authCredentials . credentials ) const signer = await this . web3Service . getCredentialsSigner ( seed , decryptedSign . replace ( / ^"(.*)"$ / , '$1' ) ) if ( signer ) { try { this . IdentityContract . options . address = identity const identityOwner = await this . IdentityContract . methods . owner ( ) . call ( ) authObject . authorized = identityOwner == signer const dataKeys = Object . keys ( authCredentials . credentialsData ) if ( dataKeys . length > 0 ) { let promises = [ ] dataKeys . forEach ( nodeLabel => { promises . push ( this . decryptCredentialsData ( authCredentials , nodeLabel , authPrivKey ) ) } ) return Promise . all ( promises ) . then ( data => { authObject . data = authCredentials . credentialsData return authObject } ) } } catch ( err ) { } } } return authObject }
Attests Identity's credentials
 @param   {String}     identity     Identity's address
 @param   {String}     seed         auth seed
 @param   {String}     authPrivKey  Ecc auth private key.
Attests Identity ' s credentials @param { String } identity Identity ' s address @param { String } seed auth seed @param { String } authPrivKey Ecc auth private key .