Variable: erc-server-AUTHENTICATE-functions

erc-server-AUTHENTICATE-functions is a variable defined in erc-sasl.el.gz.

Value

(erc-server-AUTHENTICATE)

Documentation

Hook called upon receiving a AUTHENTICATE server response.

Each function is called with two arguments, the process associated with the response and the parsed response. If the function returns non-nil, stop processing the hook. Otherwise, continue.

See also erc-server-AUTHENTICATE.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-sasl.el.gz
(define-erc-response-handler (AUTHENTICATE)
  "Begin or resume an SASL session." nil
  (if-let* ((response (car (erc-response.command-args parsed)))
            ((= 400 (length response))))
      (cl-callf (lambda (s) (concat s response))
          (erc-sasl--state-pending erc-sasl--state))
    (cl-assert response t)
    (when (string= "+" response)
      (setq response ""))
    (setf response (base64-decode-string
                    (concat (erc-sasl--state-pending erc-sasl--state)
                            response))
          (erc-sasl--state-pending erc-sasl--state) nil)
    (let ((client (erc-sasl--state-client erc-sasl--state))
          (step (erc-sasl--state-step erc-sasl--state))
          data)
      (when step
        (sasl-step-set-data step response))
      (setq step (setf (erc-sasl--state-step erc-sasl--state)
                       (sasl-next-step client step))
            data (sasl-step-data step))
      (when (string= data "")
        (setq data nil))
      (setq data (if data (erc--unfun (base64-encode-string data t)) "+"))
      (while (not (string-empty-p data))
        (let ((end (min 400 (length data))))
          ;; For now, assume this is unlikely to block
          (erc-server-send (concat "AUTHENTICATE " (substring data 0 end)))
          (setq data (concat (substring data end) (and (= end 400) "+"))))))))