How to calculate time of alignment between two points and the moon?

I would like to take a photography of Moon when it is very low on horizon and it is covered by objects on Earth surface (trees, houses,…).
How could I use CesiumJS to calculate at which time two locations and the moon are aligned?
Name the location Observer and Target, I would need to compare Target azimuth to Moon azimuth and Target elevation to Moon elevation w.r.t. Observer location, and define how fare they must be at a given time to trigger an alert.
One important question is: how can I exactly know the O and T distance from Earth center, with 1 to 10 meters approximation?