Skip to content

Commit 377b9ef

Browse files
committed
Move crypto.BufferSource to dom, as a type alias for a union type.
It is defined in the "Common Definitions" of WebIDL.
1 parent 09d733a commit 377b9ef

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

src/main/scala/org/scalajs/dom/crypto/Crypto.scala

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import scala.scalajs.js
44
import scala.scalajs.js.annotation._
55
import scala.scalajs.js.typedarray.ArrayBufferView
66

7+
import org.scalajs.dom.BufferSource
8+
79
@deprecated("use dom.crypto.crypto instead", "2.0.0")
810
@js.native
911
@JSGlobalScope
@@ -464,7 +466,9 @@ trait RsaOaepParams extends Algorithm {
464466
object RsaOaepParams {
465467
@inline
466468
def apply(name: String, label: BufferSource): RsaOaepParams = {
467-
js.Dynamic.literal(name = name, label = label).asInstanceOf[RsaOaepParams]
469+
js.Dynamic
470+
.literal(name = name, label = label.asInstanceOf[js.Any])
471+
.asInstanceOf[RsaOaepParams]
468472
}
469473
}
470474

@@ -556,7 +560,8 @@ object AesCtrParams {
556560
def apply(name: String, counter: BufferSource,
557561
length: Short): AesCtrParams = {
558562
js.Dynamic
559-
.literal(name = name, counter = counter, length = length)
563+
.literal(name = name, counter = counter.asInstanceOf[js.Any],
564+
length = length)
560565
.asInstanceOf[AesCtrParams]
561566
}
562567
}
@@ -612,8 +617,11 @@ trait AesCbcParams extends Algorithm {
612617

613618
object AesCbcParams {
614619
@inline
615-
def apply(name: String, iv: BufferSource): AesCbcParams =
616-
js.Dynamic.literal(name = name, iv = iv).asInstanceOf[AesCbcParams]
620+
def apply(name: String, iv: BufferSource): AesCbcParams = {
621+
js.Dynamic
622+
.literal(name = name, iv = iv.asInstanceOf[js.Any])
623+
.asInstanceOf[AesCbcParams]
624+
}
617625
}
618626

619627
// AES-CMAC
@@ -648,7 +656,8 @@ object AesGcmParams {
648656
def apply(name: String, iv: BufferSource, additionalData: BufferSource,
649657
tagLength: Short): AesGcmParams = {
650658
js.Dynamic
651-
.literal(name = name, iv = iv, additionalData = additionalData,
659+
.literal(name = name, iv = iv.asInstanceOf[js.Any],
660+
additionalData = additionalData.asInstanceOf[js.Any],
652661
tagLength = tagLength)
653662
.asInstanceOf[AesGcmParams]
654663
}
@@ -664,7 +673,9 @@ trait AesCfbParams extends Algorithm {
664673
object AesCfbParams {
665674
@inline
666675
def apply(name: String, iv: BufferSource): AesCfbParams =
667-
js.Dynamic.literal(name = name, iv = iv).asInstanceOf[AesCfbParams]
676+
js.Dynamic
677+
.literal(name = name, iv = iv.asInstanceOf[js.Any])
678+
.asInstanceOf[AesCfbParams]
668679
}
669680

670681
// AES-KW
@@ -817,9 +828,11 @@ object ConcatParams {
817828
privateInfo: BufferSource): ConcatParams = {
818829
js.Dynamic
819830
.literal(name = name, hash = hash.asInstanceOf[js.Any],
820-
algorithmId = algorithmId, partyUInfo = partyUInfo,
821-
partyVInfo = partyVInfo, publicInfo = publicInfo,
822-
privateInfo = privateInfo)
831+
algorithmId = algorithmId.asInstanceOf[js.Any],
832+
partyUInfo = partyUInfo.asInstanceOf[js.Any],
833+
partyVInfo = partyVInfo.asInstanceOf[js.Any],
834+
publicInfo = publicInfo.asInstanceOf[js.Any],
835+
privateInfo = privateInfo.asInstanceOf[js.Any])
823836
.asInstanceOf[ConcatParams]
824837
}
825838
}
@@ -840,8 +853,9 @@ object HkdfCtrParams {
840853
def apply(name: String, hash: HashAlgorithmIdentifier, label: BufferSource,
841854
context: BufferSource): HkdfCtrParams = {
842855
js.Dynamic
843-
.literal(name = name, hash = hash.asInstanceOf[js.Any], label = label,
844-
context = context)
856+
.literal(name = name, hash = hash.asInstanceOf[js.Any],
857+
label = label.asInstanceOf[js.Any],
858+
context = context.asInstanceOf[js.Any])
845859
.asInstanceOf[HkdfCtrParams]
846860
}
847861
}
@@ -862,8 +876,8 @@ object Pbkdf2Params {
862876
def apply(name: String, salt: BufferSource, iterations: Long,
863877
hash: HashAlgorithmIdentifier): Pbkdf2Params = {
864878
js.Dynamic
865-
.literal(name = name, salt = salt, iterations = iterations.toDouble,
866-
hash = hash.asInstanceOf[js.Any])
879+
.literal(name = name, salt = salt.asInstanceOf[js.Any],
880+
iterations = iterations.toDouble, hash = hash.asInstanceOf[js.Any])
867881
.asInstanceOf[Pbkdf2Params]
868882
}
869883
}

src/main/scala/org/scalajs/dom/crypto/package.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import scala.scalajs.js.annotation._
55
import scala.scalajs.js.typedarray.{ArrayBufferView, ArrayBuffer, Uint8Array}
66
import scala.scalajs.js.|
77

8-
import scala.language.implicitConversions
9-
108
package object crypto {
119
@js.native
1210
@JSGlobal("crypto")
@@ -35,13 +33,4 @@ package object crypto {
3533
* Algorithm Identifiers. At the JS layer these have the same structure.
3634
*/
3735
type HashAlgorithmIdentifier = HashAlgorithm | String
38-
39-
@js.native
40-
sealed trait BufferSource extends js.Any
41-
42-
implicit def arrayBuffer2BufferSource(b: ArrayBuffer): BufferSource =
43-
b.asInstanceOf[BufferSource]
44-
45-
implicit def arrayBufferView2BufferSource(b: ArrayBufferView): BufferSource =
46-
b.asInstanceOf[BufferSource]
4736
}

src/main/scala/org/scalajs/dom/experimental/package.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.scalajs.dom
22

3-
import org.scalajs.dom.crypto.BufferSource
4-
53
import scala.scalajs.js
64
import scala.scalajs.js.|
75

src/main/scala/org/scalajs/dom/package.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package org.scalajs
33
import scala.scalajs.js
44
import scala.scalajs.js.|
55
import scala.scalajs.js.annotation._
6-
import scala.scalajs.js.typedarray.ArrayBuffer
6+
import scala.scalajs.js.typedarray.{ArrayBuffer, ArrayBufferView}
77

88
package object dom {
99

@@ -21,6 +21,8 @@ package object dom {
2121
*/
2222
type Transferable = ArrayBuffer | MessagePort
2323

24+
type BufferSource = ArrayBufferView | ArrayBuffer
25+
2426
@js.native
2527
@JSGlobal("window")
2628
val window: Window = js.native

0 commit comments

Comments
 (0)