From e66f97217088f74963c4218182e0cec754e69c4d Mon Sep 17 00:00:00 2001 From: Brian Holt Date: Mon, 25 Sep 2023 15:18:30 -0500 Subject: [PATCH] switch from Shapeless tagged types to Monix Newtypes this is a step towards Scala 3 support --- README.md | 2 +- build.sbt | 2 +- .../scala/com/dwolla/config/package.scala | 21 +++++++------------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1ea87c7..8e95c56 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Dwolla/scala-secure-config CI](https://github.com/Dwolla/scala-secure-config/actions/workflows/ci.yml/badge.svg) [![license](https://img.shields.io/github/license/Dwolla/scala-secure-config.svg?style=flat-square)](https://github.com/Dwolla/scala-secure-config/blob/master/LICENSE) -Tagged type and [PureConfig](https://pureconfig.github.io) [ConfigReader](https://github.com/pureconfig/pureconfig/blob/master/core/src/main/scala/pureconfig/ConfigReader.scala) for automatically decrypting encrypted config values in TypeSafe Config files. + [PureConfig](https://pureconfig.github.io) [ConfigReader](https://github.com/pureconfig/pureconfig/blob/master/core/src/main/scala/pureconfig/ConfigReader.scala) for automatically decrypting encrypted config values using AWS KMS. ## Artifacts diff --git a/build.sbt b/build.sbt index d62c69e..838c18e 100644 --- a/build.sbt +++ b/build.sbt @@ -24,7 +24,7 @@ lazy val `secure-config` = (project in file(".")) libraryDependencies ++= { Seq( "com.github.pureconfig" %% "pureconfig-cats-effect" % "0.17.4", - "com.chuusai" %% "shapeless" % "2.3.10", + "io.monix" %% "newtypes-core" % "0.2.3", "com.dwolla" %% "fs2-aws-java-sdk2" % "3.0.0-RC2", ) }, diff --git a/src/main/scala/com/dwolla/config/package.scala b/src/main/scala/com/dwolla/config/package.scala index 6c40c5d..9fca398 100644 --- a/src/main/scala/com/dwolla/config/package.scala +++ b/src/main/scala/com/dwolla/config/package.scala @@ -1,11 +1,10 @@ package com.dwolla -import cats._ -import cats.syntax.all._ -import com.dwolla.fs2aws.kms._ +import cats.* +import cats.syntax.all.* +import com.dwolla.fs2aws.kms.* +import monix.newtypes.NewtypeWrapped import pureconfig.ConfigReader -import shapeless.tag -import shapeless.tag.@@ package object config { private[this] val secureStringRegex = "^SECURE: (.+)".r @@ -15,14 +14,10 @@ package object config { case secureStringRegex(cryptotext) => for { bytes <- decryptionClient.decrypt(cryptotext) - } yield tagSecurableString(bytes) - case s => tagSecurableString(s).pure[F] + } yield SecurableString(bytes) + case s => SecurableString(s).pure[F] } - type SecurableString = String @@ SecurableStringTag - val tagSecurableString: String => SecurableString = tag[SecurableStringTag][String](_) -} - -package config { - trait SecurableStringTag + type SecurableString = SecurableString.Type + object SecurableString extends NewtypeWrapped[String] }