webservice/src/helpers.js
/**
 * Function to parse a JWT token
 * @param token the token received by keycloak
 * @returns {any} the decrypted token as a JSON object
 */
Function to parse a JWT token
@param token the token received by keycloak
@returns {any} the decrypted token as a JSON object
Function to parse a JWT token @param token the token received by keycloak @returns { any } the decrypted token as a JSON object
function parseJWTtoken(token) {
  const base64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
  return JSON.parse(
    decodeURIComponent(
      atob(base64)
        .split('')
        .map(c => {
          return `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`;
        })
        .join('')
    )
  );
}
function parseJWTtoken ( token ) { const base64 = token . split ( '.' ) [ 1 ] . replace ( / - / g , '+' ) . replace ( / _ / g , '/' ) ; return JSON . parse ( decodeURIComponent ( atob ( base64 ) . split ( '' ) . map ( c => { return ` ${ ` ${ c . charCodeAt ( 0 ) . toString ( 16 ) } ` . slice ( - 2 ) } ` ; } ) . join ( '' ) ) ) ; }
Function to parse a JWT token
 @param token the token received by keycloak
 @returns {any} the decrypted token as a JSON object
Function to parse a JWT token @param token the token received by keycloak @returns { any } the decrypted token as a JSON object