Skip to content

Commit b723c97

Browse files
ben-kaufmanclaude
andcommitted
refactor: use PubkyAuthKind enum instead of string for kind field
Replace the raw string kind field with a proper PubkyAuthKind enum (Signin/Signup) for type safety in generated bindings. Bump version and regenerate bindings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aa28d33 commit b723c97

20 files changed

Lines changed: 195 additions & 35 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bitkitcore"
3-
version = "0.1.52"
3+
version = "0.1.53"
44
edition = "2021"
55

66
[lib]

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import PackageDescription
55

6-
let tag = "v0.1.52"
7-
let checksum = "e26db56b4090678c214995f299b8cc680c4f57602393ce3e37cd5cd844160d1f"
6+
let tag = "v0.1.53"
7+
let checksum = "270c8b0d6b4aab23a691ba331958bf1555095db5eb091c282cec8c33c6f3df5f"
88
let url = "https://github.com/synonymdev/bitkit-core/releases/download/\(tag)/BitkitCore.xcframework.zip"
99

1010
let package = Package(

bindings/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ android.useAndroidX=true
33
android.enableJetifier=true
44
kotlin.code.style=official
55
group=com.synonym
6-
version=0.1.52
6+
version=0.1.53
-464 Bytes
Binary file not shown.
-1.29 KB
Binary file not shown.
-31.8 KB
Binary file not shown.
-472 Bytes
Binary file not shown.

bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6664,7 +6664,7 @@ public object FfiConverterTypePubkyAuth: FfiConverterRustBuffer<PubkyAuth> {
66646664
public object FfiConverterTypePubkyAuthDetails: FfiConverterRustBuffer<PubkyAuthDetails> {
66656665
override fun read(buf: ByteBuffer): PubkyAuthDetails {
66666666
return PubkyAuthDetails(
6667-
FfiConverterString.read(buf),
6667+
FfiConverterTypePubkyAuthKind.read(buf),
66686668
FfiConverterString.read(buf),
66696669
FfiConverterString.read(buf),
66706670
FfiConverterOptionalString.read(buf),
@@ -6673,15 +6673,15 @@ public object FfiConverterTypePubkyAuthDetails: FfiConverterRustBuffer<PubkyAuth
66736673
}
66746674

66756675
override fun allocationSize(value: PubkyAuthDetails): ULong = (
6676-
FfiConverterString.allocationSize(value.`kind`) +
6676+
FfiConverterTypePubkyAuthKind.allocationSize(value.`kind`) +
66776677
FfiConverterString.allocationSize(value.`capabilities`) +
66786678
FfiConverterString.allocationSize(value.`relay`) +
66796679
FfiConverterOptionalString.allocationSize(value.`homeserver`) +
66806680
FfiConverterOptionalString.allocationSize(value.`signupToken`)
66816681
)
66826682

66836683
override fun write(value: PubkyAuthDetails, buf: ByteBuffer) {
6684-
FfiConverterString.write(value.`kind`, buf)
6684+
FfiConverterTypePubkyAuthKind.write(value.`kind`, buf)
66856685
FfiConverterString.write(value.`capabilities`, buf)
66866686
FfiConverterString.write(value.`relay`, buf)
66876687
FfiConverterOptionalString.write(value.`homeserver`, buf)
@@ -9223,6 +9223,24 @@ public object FfiConverterTypePaymentType: FfiConverterRustBuffer<PaymentType> {
92239223

92249224

92259225

9226+
9227+
public object FfiConverterTypePubkyAuthKind: FfiConverterRustBuffer<PubkyAuthKind> {
9228+
override fun read(buf: ByteBuffer): PubkyAuthKind = try {
9229+
PubkyAuthKind.entries[buf.getInt() - 1]
9230+
} catch (e: IndexOutOfBoundsException) {
9231+
throw RuntimeException("invalid enum value, something is very wrong!!", e)
9232+
}
9233+
9234+
override fun allocationSize(value: PubkyAuthKind): ULong = 4UL
9235+
9236+
override fun write(value: PubkyAuthKind, buf: ByteBuffer) {
9237+
buf.putInt(value.ordinal + 1)
9238+
}
9239+
}
9240+
9241+
9242+
9243+
92269244
public object PubkyExceptionErrorHandler : UniffiRustCallStatusErrorHandler<PubkyException> {
92279245
override fun lift(errorBuf: RustBufferByValue): PubkyException = FfiConverterTypePubkyError.lift(errorBuf)
92289246
}

bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,9 +1344,9 @@ public data class PubkyAuth (
13441344
@kotlinx.serialization.Serializable
13451345
public data class PubkyAuthDetails (
13461346
/**
1347-
* `"signin"` or `"signup"`.
1347+
* Whether this is a signin or signup flow.
13481348
*/
1349-
val `kind`: kotlin.String,
1349+
val `kind`: PubkyAuthKind,
13501350
/**
13511351
* Requested capabilities (e.g. `"/pub/pubky.app/:rw"`).
13521352
*/
@@ -3407,6 +3407,23 @@ public enum class PaymentType {
34073407

34083408

34093409

3410+
/**
3411+
* The type of a `pubkyauth://` deep-link flow.
3412+
*/
3413+
3414+
@kotlinx.serialization.Serializable
3415+
public enum class PubkyAuthKind {
3416+
3417+
SIGNIN,
3418+
SIGNUP;
3419+
public companion object
3420+
}
3421+
3422+
3423+
3424+
3425+
3426+
34103427

34113428
public sealed class PubkyException: kotlin.Exception() {
34123429

0 commit comments

Comments
 (0)