From 9937d48ad2b6ad04e7d701a7fec3ba948f2f0ff2 Mon Sep 17 00:00:00 2001 From: exoego Date: Mon, 23 Mar 2020 13:38:26 +0900 Subject: [PATCH] [crypto] Drop legacy Certificate class See https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html#crypto_new_crypto_certificate --- .../scalajs/nodejs/crypto/Certificate.scala | 9 ------- .../io/scalajs/nodejs/crypto/Crypto.scala | 2 -- .../nodejs/crypto/CertificateTest.scala | 25 ------------------- 3 files changed, 36 deletions(-) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala index 6494a23e9..b71c8d426 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala @@ -6,15 +6,6 @@ import scala.scalajs.js import scala.scalajs.js.annotation.JSImport import scala.scalajs.js.| -@deprecated("Legacy API, not recommended to create new instance. Use Certificate object.", "v0.10.0") -@js.native -@JSImport("crypto", "Certificate") -class Certificate extends js.Object { - def exportChallenge(spkac: String | BufferLike): Buffer = js.native - def exportPublicKey(spkac: String | BufferLike, encoding: String = js.native): Buffer = js.native - def verifySpkac(spkac: BufferLike): Boolean = js.native -} - @js.native @JSImport("crypto", "Certificate") object Certificate extends js.Object { diff --git a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala index 8aae4b36f..5555eaf25 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala @@ -282,8 +282,6 @@ trait Crypto extends js.Object { @js.native @JSImport("crypto", JSImport.Namespace) object Crypto extends Crypto { - @deprecated("Legacy API, not recommended to create new instance. Use Certificate object.", "v0.10.0") - type Certificate = io.scalajs.nodejs.crypto.Certificate type Cipher = io.scalajs.nodejs.crypto.Cipher type Decipher = io.scalajs.nodejs.crypto.Decipher type DiffieHellman = io.scalajs.nodejs.crypto.DiffieHellman diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala index 00baa59bb..803e0e371 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala @@ -8,31 +8,6 @@ class CertificateTest extends AnyFunSpec with Matchers { val spkacExample = "MIIBXjCByDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkYzBkZjFlYjctMTU0NC00MWVkLWFmN2EtZDRkYjBkNDc5ZjZmMA0GCSqGSIb3DQEBBAUAA4GBALEiapUjaIPs5uEdvCP0gFK2qofo+4GpeK1A43mu28lirYPAvCWsmYvKIZIT9TxvzmQIxAfxobf70aSNlSm6MJJKmvurAK+Bpn6ZUKQZ6A1m927LvctVSYJuUi+WVmr0fGE/OfdQ+BqSm/eQ3jnm3fBPVx1uwLPgjC5g4EvGMh8M" - describe("Certificate class (Legacy)") { - val instance = new Certificate() - - it("exportChallenge") { - assert(instance.exportChallenge(spkacExample).toString("utf8") === "c0df1eb7-1544-41ed-af7a-d4db0d479f6f") - } - - it("exportPublicKey") { - assert( - instance.exportPublicKey(spkacExample).toString("utf8") === - """-----BEGIN PUBLIC KEY----- - |MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcvQh9SKOPv4DwI8LwSaFx02h7 - |l9QCiDs6sF2GfsSTEUG61SnjQ/v4uJiLKBgbVOagj9rkSCwtTez23ATPeGaBj2Zg - |ipv+tv5IXyqUP8ropXJQ5ELtaXPUN/gvw7cO5EbPHr/7eMhbpw8Gl+AfWxW5hLW8 - |MGw/+AwwjHBOwong/QIDAQAB - |-----END PUBLIC KEY----- - |""".stripMargin - ) - } - - it("verifySpkac") { - assert(instance.verifySpkac(Buffer.from("foo")) === false) - } - } - describe("Certificate object") { it("exportChallenge") { assert(Certificate.exportChallenge(spkacExample).toString("utf8") === "c0df1eb7-1544-41ed-af7a-d4db0d479f6f")