src/index.js
/**
   * Login user and get JWT token for next calls
   * @async
   * @return {Promise} axios promise and if success Json Web Token (JWT)
   */
Login user and get JWT token for next calls
@async
@return {Promise} axios promise and if success Json Web Token (JWT)
Login user and get JWT token for next calls @async @return { Promise } axios promise and if success Json Web Token ( JWT )
login() {
    const self = this;
    const userDID = `did:sov:${this.identity.did}`;
    const { invitationCode } = this.config;
    let url = this.host;
    url += '/api/login?';
    return self.http
      .get(url, {
        params: {
          invitationCode,
          userDID,
        },
      })
      .then((res) => {
        self.jwt = res.data.token;
        return new Promise((resolve, reject) => {
          resolve(res);
        });
      })
      .catch((error) => {
        if (error.response.status === 401) {
          self.register().then(() => {
            self.login();
          });
        }
        return Promise.reject(error.response);
      });
  }
login ( ) { const self = this ; const userDID = ` ${ this . identity . did } ` ; const { invitationCode } = this . config ; let url = this . host ; url += '/api/login?' ; return self . http . get ( url , { params : { invitationCode , userDID , } , } ) . then ( ( res ) => { self . jwt = res . data . token ; return new Promise ( ( resolve , reject ) => { resolve ( res ) ; } ) ; } ) . catch ( ( error ) => { if ( error . response . status === 401 ) { self . register ( ) . then ( ( ) => { self . login ( ) ; } ) ; } return Promise . reject ( error . response ) ; } ) ; }
Login user and get JWT token for next calls
 @async
 @return {Promise} axios promise and if success Json Web Token (JWT)
Login user and get JWT token for next calls @async @return { Promise } axios promise and if success Json Web Token ( JWT )
// TODO use identity keys for JWT // user not reigsterd, try to register // try to login once more