I am reading about the Brown-York formalism in https://link.springer.com/article/10.12942/lrr-2004-4. The document says that if we consider a deformation of our end points $(q,t$) in position and time, then the classical mechanics action varies by (equation (65) on p.76)
\begin{align} \nonumber \delta S^1[q^a(t)] := &\int_{t_1}^{t_2} \left( \frac{\partial L}{\partial q^a} - \frac{\mathrm{d}}{\mathrm{d}t} \frac{\partial L}{\partial \dot{q}^a} \right) (\delta q^a - \dot{q}^a \delta t) + \frac{\partial L}{\partial \dot{q}^a}\delta q^a\Big|_{t_1}^{t_2} \\ &- \left( \frac{\partial L}{\partial \dot{q}^a} \dot{q}^a - L \right) \delta t\Big|_{t_1}^{t_2}.\tag{65} \end{align}
Could somebody tell me how we got to this?
Here’s what I’ve tried:
\begin{align} \delta S^1(q,\dot{q},t) = \frac{\partial S^1}{ \partial q} \delta q + \frac{\partial S^1}{ \partial \dot{q}} \delta \dot{q} + \frac{\partial S^1}{ \partial t} \delta t,\tag{a} \end{align}
where the suppressed indices of the vectors $q$ and $\dot{q}$ are implied. The first term gives
$$\begin{equation} \frac{\partial S^1}{ \partial q} \delta q = \int_{t_1}^{t_2} \frac{\partial L}{\partial q} \delta q \mathrm{d} t. \end{equation}\tag{b}$$
The second term gives
$$\begin{align} \nonumber \frac{\partial S^1}{ \partial \dot{q}} \delta \dot{q} &= \int \frac{\partial S}{\partial \dot{q}} \delta \frac{\mathrm{d}}{\mathrm{d} t} q \mathrm{d} t\\ &= \frac{\partial L}{\partial \dot{q}} \delta q\Big|_{t_1}^{t_2} - \int \frac{\mathrm{d}}{\mathrm{d} t} \frac{\partial L}{\partial \dot{q}} \delta q \mathrm{d} t. \end{align}\tag{c}$$
To get to the last line I have used integration by parts. The third terms can be written as
$$\begin{align} \nonumber \frac{\partial S^1}{ \partial t} \delta t &= \int_{t_1}^{t_2} L \mathrm{d}t \delta t \\ \nonumber &= L \delta t |_{t_1}^{t_2}\\ &= \left( p^a \dot{q}_a - E \right) \delta t |_{t_1}^{t_2}. \end{align}\tag{d}$$
The combination of the three terms leads to
$$\begin{align} \delta S^1 &= \int_{t_1}^{t_2} \left( \frac{\partial L}{\partial q} - \frac{\mathrm{d}}{\mathrm{d}t} \frac{\partial L}{\partial \dot{q}} \right) \left( \delta q + \dot{q} \delta t \right) + \frac{\partial L}{\partial \dot{q}}\delta q\Big|_{t_1}^{t_2} + (E + L)\delta t |_{t_1}^{t_2}. \end{align}\tag{e}$$