Skip to content

Commit f2f77d8

Browse files
committed
Add ABI checking and other slight improvements.
1 parent 0cda96a commit f2f77d8

12 files changed

Lines changed: 979 additions & 0 deletions

File tree

.api-validation/paseto.api

Whitespace-only changes.

build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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

1718
repositories {
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+
2229
allprojects {
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+
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[versions]
2+
binaryCompatibilityValidator = "0.18.1"
23
bouncycastle = "1.83"
34
clikt = "5.1.0"
45
detekt = "1.23.8"
@@ -30,6 +31,7 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa
3031
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
3132

3233
[plugins]
34+
binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibilityValidator" }
3335
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
3436
gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" }
3537
gradleVersions-filter = { id = "se.ascp.gradle.gradle-versions-filter", version.ref = "gradleFilterVersions" }

justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ update-check:
6060
# Automatically updates all dependencies in the version catalog.
6161
update-apply:
6262
{{gradlew}} versionCatalogUpdate
63+
64+
api-check:
65+
{{gradlew}} apiCheck
66+
67+
api-dump:
68+
{{gradlew}} apiDump

paseto/.api-validation/paseto.api

Lines changed: 921 additions & 0 deletions
Large diffs are not rendered by default.

paseto/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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

paseto/src/main/kotlin/net/aholbrook/paseto/Claims.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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
7273
class 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
9496
class ClaimArrayBuilder @PublishedApi internal constructor() {
9597
private val content: MutableList<ClaimElement> = mutableListOf()
9698

paseto/src/main/kotlin/net/aholbrook/paseto/Token.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ data class PasetoToken internal constructor(
2121
val footer: PasetoFooter?,
2222
)
2323

24+
@PasetoDslMarker
2425
class 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
6769
class 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
119129
fun PasetoToken.claimsJson(): JsonObject = claims.toJson() as JsonObject

paseto/src/main/kotlin/net/aholbrook/paseto/TokenService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ sealed interface Purpose {
2424
class Local(val keyProvider: () -> SymmetricKey) : Purpose
2525
}
2626

27+
@PasetoDslMarker
2728
class TokenServiceBuilder @PublishedApi internal constructor() {
2829
var rules: Rules = rules()
2930

0 commit comments

Comments
 (0)