Protevangelium of James 14
1And Joseph was sore afraid and ceased from speaking unto her ( or left her alone), and pondered what he should do with her. And Joseph said: If I hide her sin, I shall be found fighting against the law of the Lord: and if I manifest her unto the children of Israel, I fear lest that which is in her be the seed of an angel, and I shall be found delivering up innocent blood to the judgement of death. What then shall I do? I will let her go from me privily. And the night came upon him.
2And behold an angel of the Lord appeared unto him in a dream, saying: Fear not this child, for that which is in her is of the Holy Ghost, and she shall bear a son and thou shalt call his name Jesus, for he shall save his people from their sins. And Joseph arose from sleep and glorified the God of Israel which had shown this favour unto her: and he watched over her.