base64ToUint8Array = str => {
  const bytes = window.atob(str.replace(/-/g, '+').replace(/_/g, '/'));
  const result = new Uint8Array(bytes.length);
  for (let i = 0; i < bytes.length; ++i) {
    result[i] = bytes.charCodeAt(i);
  }
  return result;
}
From: https://github.com/google/shaka-player/blob/f9fc4adbe69c108ff752323e9983a93c86c97e36/lib/util/uint8array_utils.js#L53