File tree Expand file tree Collapse file tree
main/kotlin/net/aholbrook/paseto
test/kotlin/net/aholbrook/paseto Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,13 +12,20 @@ plugins {
1212 alias(libs.plugins.gradleVersions)
1313 alias(libs.plugins.gradleVersions.filter)
1414 alias(libs.plugins.gradleVersions.update)
15+ alias(libs.plugins.binaryCompatibilityValidator)
1516}
1617
1718repositories {
1819 mavenLocal()
1920 mavenCentral()
2021}
2122
23+ apiValidation {
24+ apiDumpDirectory = " .api-validation"
25+ nonPublicMarkers + = " net.aholbrook.paseto.InternalApi"
26+ ignoredProjects.addAll(listOf (" vector-gen" ))
27+ }
28+
2229allprojects {
2330 apply (plugin = " java" )
2431 apply (plugin = " org.jmailen.kotlinter" )
@@ -78,3 +85,7 @@ allprojects {
7885 config.setFrom(files(" ${project.rootDir} /detekt-config.yml" ))
7986 }
8087}
88+
89+ tasks.check {
90+ dependsOn(tasks.apiCheck)
91+ }
Original file line number Diff line number Diff line change 11[versions ]
2+ binaryCompatibilityValidator = " 0.18.1"
23bouncycastle = " 1.83"
34clikt = " 5.1.0"
45detekt = " 1.23.8"
@@ -30,6 +31,7 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa
3031mockk = { module = " io.mockk:mockk" , version.ref = " mockk" }
3132
3233[plugins ]
34+ binaryCompatibilityValidator = { id = " org.jetbrains.kotlinx.binary-compatibility-validator" , version.ref = " binaryCompatibilityValidator" }
3335detekt = { id = " io.gitlab.arturbosch.detekt" , version.ref = " detekt" }
3436gradleVersions = { id = " com.github.ben-manes.versions" , version.ref = " gradleVersions" }
3537gradleVersions-filter = { id = " se.ascp.gradle.gradle-versions-filter" , version.ref = " gradleFilterVersions" }
Original file line number Diff line number Diff line change @@ -60,3 +60,9 @@ update-check:
6060# Automatically updates all dependencies in the version catalog.
6161update-apply :
6262 {{ gradlew}} versionCatalogUpdate
63+
64+ api-check :
65+ {{ gradlew}} apiCheck
66+
67+ api-dump :
68+ {{ gradlew}} apiDump
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ tasks {
4242 options.release.set(17 )
4343 }
4444
45+ withType<AbstractPublishToMaven >().configureEach {
46+ dependsOn(rootProject.tasks.named(" check" ))
47+ }
48+
4549 withType<AbstractArchiveTask >().configureEach {
4650 isPreserveFileTimestamps = false
4751 isReproducibleFileOrder = true
Original file line number Diff line number Diff line change 1+ package net.aholbrook.paseto
2+
3+ @DslMarker
4+ internal annotation class PasetoDslMarker
5+
6+ @RequiresOptIn(
7+ message = " This is an internal Paseto API and subject to change without notice." ,
8+ level = RequiresOptIn .Level .ERROR ,
9+ )
10+ @Retention(AnnotationRetention .BINARY )
11+ @Target(
12+ AnnotationTarget .CLASS ,
13+ AnnotationTarget .FUNCTION ,
14+ AnnotationTarget .PROPERTY ,
15+ AnnotationTarget .FIELD ,
16+ AnnotationTarget .TYPEALIAS ,
17+ AnnotationTarget .CONSTRUCTOR ,
18+ )
19+ annotation class Annotations
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ value class ClaimPrimitive internal constructor(internal val primitive: JsonPrim
6969 override fun toString (): String = primitive.toString()
7070}
7171
72+ @PasetoDslMarker
7273class ClaimObjectBuilder @PublishedApi internal constructor() {
7374 private val content: MutableMap <String , ClaimElement > = linkedMapOf()
7475
@@ -91,6 +92,7 @@ inline fun claimObject(init: ClaimObjectBuilder.() -> Unit): ClaimObject {
9192 return builder.build()
9293}
9394
95+ @PasetoDslMarker
9496class ClaimArrayBuilder @PublishedApi internal constructor() {
9597 private val content: MutableList <ClaimElement > = mutableListOf ()
9698
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ data class PasetoToken internal constructor(
2121 val footer : PasetoFooter ? ,
2222)
2323
24+ @PasetoDslMarker
2425class PasetoTokenBuilder @PublishedApi internal constructor(clock : Clock ) {
2526 var issuer: String? = null // iss
2627 var subject: String? = null // sub
@@ -64,6 +65,7 @@ data class ClaimFooter internal constructor(
6465 val claims : ClaimObject ,
6566) : PasetoFooter
6667
68+ @PasetoDslMarker
6769class ClaimFooterBuilder @PublishedApi internal constructor() {
6870 var keyId: String? = null // kid
6971 var wrappedKey: String? = null // wpk
@@ -116,4 +118,12 @@ fun PasetoFooter?.taint(): TaintedPasetoFooter? = when (this) {
116118 is StringFooter -> TaintedStringFooter (value)
117119}
118120
121+ /* *
122+ * Escape hatch for direct access to the token's claims as a [JsonObject].
123+ *
124+ * This is an internal API because it couples the caller to the `kotlinx.serialization` JSON implementation.
125+ * It may change or be removed without notice if the underlying serialization strategy changes.
126+ */
127+
128+ @Annotations
119129fun PasetoToken.claimsJson (): JsonObject = claims.toJson() as JsonObject
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ sealed interface Purpose {
2424 class Local (val keyProvider : () -> SymmetricKey ) : Purpose
2525}
2626
27+ @PasetoDslMarker
2728class TokenServiceBuilder @PublishedApi internal constructor() {
2829 var rules: Rules = rules()
2930
You can’t perform that action at this time.
0 commit comments