docs: function ensureCsrfToken(request) {
      const originalRequest = request;
      const method = request.method.toUpperCase();
      const isCsrfExempt = authenticatedAPIClient.isCsrfExempt(originalRequest.url);
      if (!isCsrfExempt && CSRF_PROTECTED_METHODS.includes(method)) {
        const url = new Url(request.url);
        const { protocol } = url;
        const { host } = url;
        const csrfToken = csrfTokens[host];
        if (csrfToken) {
          request.headers[CSRF_HEADER_NAME] = csrfToken;
        } else {
          if (!queueRequests) {
            queueRequests = true;
            authenticatedAPIClient.getCsrfToken(protocol, host)
              .then((response) => {
                queueRequests = false;
                PubSub.publishSync(CSRF_TOKEN_REFRESH, response.data.csrfToken);
              });
          }
  
          return new Promise((resolve) => {
            logInfo(`Queuing API request ${originalRequest.url} while CSRF token is retrieved`);
            PubSub.subscribeOnce(CSRF_TOKEN_REFRESH, (msg, token) => {
              logInfo(`Resolving queued API request ${originalRequest.url}`);
              csrfTokens[host] = token;
              originalRequest.headers[CSRF_HEADER_NAME] = token;
              resolve(originalRequest);
            });
          });
        }
      }
      return request;
    }