The Protoevangelium of James
An anonymous narrative of the birth and childhood of Mary and of the birth of Jesus, written in the second century under the name of James. It was never part of the New Testament but shaped later devotion to Mary.
The book tells of Mary’s parents, Joachim and Anna, her childhood in the temple, her betrothal to Joseph and the birth of Jesus in a cave near Bethlehem. Its last chapter claims that it was written by James in Jerusalem after the death of Herod. That claim is not accepted by historians: the work depends on the Gospels of Matthew and Luke and is usually dated to the later second century. The churches did not receive it as Scripture.
It is cited in this wiki as evidence for what some Christians believed about Mary and Joseph by that time, not as a source for the events. In chapter 9 Joseph is an old man who already has children when Mary is entrusted to him. On this account the brothers of Jesus named in the Gospels would be Joseph’s children by an earlier marriage.