diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 88725ae45..7fd0c3c34 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -25514,7 +25514,7 @@ crypto/package[SO] @deprecated("use dom.RsaKeyGenParams instead", "2.0.0") val R crypto/package[SO] @deprecated("use dom.RsaOaepParams instead", "2.0.0") val RsaOaepParams = dom.RsaOaepParams crypto/package[SO] @deprecated("use dom.RsaPssParams instead", "2.0.0") val RsaPssParams = dom.RsaPssParams crypto/package[SO] def crypto: Crypto (@deprecated in 2.0.0) -crypto/package[SO] @JSGlobal("crypto.getRandomValues") @js.native def getRandomValues(array: ArrayBufferView): ArrayBufferView +crypto/package[SO] def getRandomValues(array: ArrayBufferView)(implicit dummy: DummyImplicit): ArrayBufferView crypto/package[SO] @JSGlobal("crypto.subtle") @js.native val subtle: dom.SubtleCrypto experimental/Fullscreen[SO] (@deprecated in 2.0.0) experimental/PointerLock[SO] type PointerLockDocument = dom.Document (@deprecated in 2.0.0) diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 88725ae45..7fd0c3c34 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -25514,7 +25514,7 @@ crypto/package[SO] @deprecated("use dom.RsaKeyGenParams instead", "2.0.0") val R crypto/package[SO] @deprecated("use dom.RsaOaepParams instead", "2.0.0") val RsaOaepParams = dom.RsaOaepParams crypto/package[SO] @deprecated("use dom.RsaPssParams instead", "2.0.0") val RsaPssParams = dom.RsaPssParams crypto/package[SO] def crypto: Crypto (@deprecated in 2.0.0) -crypto/package[SO] @JSGlobal("crypto.getRandomValues") @js.native def getRandomValues(array: ArrayBufferView): ArrayBufferView +crypto/package[SO] def getRandomValues(array: ArrayBufferView)(implicit dummy: DummyImplicit): ArrayBufferView crypto/package[SO] @JSGlobal("crypto.subtle") @js.native val subtle: dom.SubtleCrypto experimental/Fullscreen[SO] (@deprecated in 2.0.0) experimental/PointerLock[SO] type PointerLockDocument = dom.Document (@deprecated in 2.0.0) diff --git a/dom/src/main/scala/org/scalajs/dom/crypto/package.scala b/dom/src/main/scala/org/scalajs/dom/crypto/package.scala index 9b2d3dbd0..735b07f2f 100644 --- a/dom/src/main/scala/org/scalajs/dom/crypto/package.scala +++ b/dom/src/main/scala/org/scalajs/dom/crypto/package.scala @@ -14,10 +14,14 @@ package object crypto { @js.native val subtle: dom.SubtleCrypto = js.native - /** Fills the passed TypedArray with cryptographically sound random values. */ + // for binary compat; unusable @JSGlobal("crypto.getRandomValues") @js.native - def getRandomValues(array: ArrayBufferView): ArrayBufferView = js.native + protected[crypto] def getRandomValues(array: ArrayBufferView): ArrayBufferView = js.native + + /** Fills the passed TypedArray with cryptographically sound random values. */ + @inline def getRandomValues(array: ArrayBufferView)(implicit dummy: DummyImplicit): ArrayBufferView = + webcrypto.getRandomValues(array) @deprecated("use dom.crypto instead", "2.0.0") @inline def crypto: Crypto = GlobalCrypto.crypto diff --git a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/WebCryptoApiTests.scala b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/WebCryptoApiTests.scala index 17b0c8725..2d28f7535 100644 --- a/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/WebCryptoApiTests.scala +++ b/tests-shared/src/main/scala/org/scalajs/dom/tests/shared/WebCryptoApiTests.scala @@ -10,6 +10,10 @@ import scala.scalajs.js.typedarray._ trait WebCryptoApiTests { + // https://github.com/scala-js/scala-js-dom/issues/668 + @Test final def cryptoGetRandomValues(): Unit = + dom.crypto.getRandomValues(new Uint8Array(1)) + @Test final def getRandomValuesWork: Unit = { dom.webcrypto.getRandomValues(Array.ofDim[Byte](8).toTypedArray) }