Skip to content

Commit

Permalink
switch from Shapeless tagged types to Monix Newtypes
Browse files Browse the repository at this point in the history
  this is a step towards Scala 3 support
  • Loading branch information
bpholt committed Dec 11, 2023
1 parent 0775667 commit e66f972
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
},
Expand Down
21 changes: 8 additions & 13 deletions src/main/scala/com/dwolla/config/package.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
}

0 comments on commit e66f972

Please sign in to comment.