Let me add to Dottard's excellent answer.
Regarding the authorship of the Genesis in general, and specifically the first eight chapters, there are several theories.
Let me first note that in my opinion, the general modus operandi of Bible minimalists is to devise a theory that discredits part of the Bible, award the theory and its author acclaim and acceptance by other Bible minimalists, mock any dissenters, destroy the faith of their seminary students, and when archaeological discoveries eventually discredit one of their theories, either ignore the finding, lie about it, dismiss it with a new theory explaining why the discovery doesn’t disprove their pet theory, destroy the site with their own excavations by never publishing their findings, become hyper-skeptical of the find itself, or scoff at the director of the archaeological dig.
But, on the reverse side of the same coin are Bible sensationalists, who make spectacular claims based on little or fabricated evidence, cater to what they think gullible Christians want to hear, and coincidentally receive generous donations from them. When confronted with Biblical or archaeological evidence, they double down on their claims or make newer, even more preposterous claims. In a few cases, they were caught fabricating evidence. Two sides, same coin.
I’ve found many such areas of controversy.
Mosaic authorship of the Law (Exodus, Leviticus, Numbers, and Deuteronomy) is mentioned by Jesus in John 5:45–47. It was long assumed that Genesis was written or compiled by Moses.
However, Jean Astruc (1684-1766) proposed the “JEDP Documentary Hypothesis” that was further developed by the theologian K.H. Graf (1815-1868), and his student Julius Wellhausen (1844-1918). They noticed that portions of Genesis referred to God as YHWH (J) and in other portions as Elohim (E). The P was a supposedly a “Priestly” author and the D was supposedly a different, “Deuteronomist” author. For example,
“In the beginning, God [Elohim] created the heavens and the earth.”
-Genesis 1:1 ESV
The word, God, is translated from Elohim exclusively through Genesis 2:4, where the name of God, YHWH (Yah-weh or Yah-hu-way), first appears. Perhaps the hypothesized J and E authors are playing “tag team” here:
“These are the generations of the heavens and the earth when they were
created, in the day that the Lord God [i.e. Yahweh Elohim] made the
earth and the heavens." -Genesis 2:4 ESV
And in Deuteronomy with Hebrew text inserted . . .
“I am YHWH your Elohim, who brought you out of slavery in Egypt.”
-Deuteronomy 5:6
An excellent description of the use of YHWH versus Elohim is in the answer that starts with a section subheading, The Meaning of the Names.
The JEPD Hypothesis originally asserted that the earliest parts of the Old Testament could not have been written during the times they described because the technology of writing had not evolved until about 1000 BC. The conclusion that the first five books, Torah, “musta been” passed down orally for hundreds of years before then and the Bible was assumed to have been put into writing by unknown authors beginning well after the time of David, beginning about 800 BCE. Since then, archaeologists have found written cuneiform tablets such as the ancient Sumerian Kish tablet, dating back to around 3500 BCE, and other tablets have been dated even earlier.
In contrast to the JEPD theory, there’s actually strong archaeological evidence that the first part of Genesis was written on clay tablets in the ancient Mesopotamian style based on the "signatures" of 11 authors following (not preceding) the text they wrote. These follow the format of “These are the generations of . . .”
Air Marshall and amateur archaeologist, P.J. Wiseman noticed that the then-recently discovered Mesopotamian tablets used the same format when recording historical events, so he hypothesized that Genesis likely was originally written on clay tablets. He published his theory in 1936 in a book titled New Discoveries in Babylonia About Genesis, and I have a copy of the seventh edition (1958) in front of me.
His “tablet theory of Genesis” is widely scoffed at in academic circles, but then, how does the archaeological evidence of the tablet theory compare against the literary speculation of the JEPD hypothesis?
P.J. Wiseman also noticed that the “pages” of a set of tablets weren’t numbered, so to prevent confusion should the tablets become disordered (perhaps through an earthquake, toddler, or dastardly cat), he noticed that the text included “catch lines” that used similar text from the last line of one tablet to the first line of the following tablet.
To test his theory, the quantity of text between the catch lines connecting successive tablets would each have to fall within the maximum size of the thousands of excavated tablets, which was then about 7” by 3-1/2”. Studying the lengths of the texts, he confirmed that the catch lines bracketed the typical quantity of text for each tablet.
However, this pattern disappears in the last part of Genesis beginning with the story of Joseph, which starts in Egypt. This was explained by the fact that Egyptians didn’t use clay tablets but wrote on papyrus scrolls instead.
All this evidence mounts up significantly.
As to how the authors of the passage in Genesis 8:21 found out what "God said in his heart," I would say that God and Noah had a close relationship, and that Noah passed this assurance from God down to his sons, Shem, Ham, and Japeth, who wrote this section of Genesis according to the tablet theory. It also indicates that the tablets were passed from generation to generation continuing from Shem to Terah, Isaac, Ishmael (!), Jacob, Esau, and finally to Joseph.