Skip to content

Commit aa28d33

Browse files
ben-kaufmanclaude
andcommitted
feat: add approver-side Pubky Auth FFI (approve + parse URL)
Add approve_pubky_auth and parse_pubky_auth_url to enable approving auth requests from other apps. Bump version and regenerate bindings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aaa627d commit aa28d33

23 files changed

Lines changed: 658 additions & 10 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.51"
3+
version = "0.1.52"
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.51"
7-
let checksum = "fc2a9b3884dcd1b08d7112458621c589413339e84e52955e0ece4ff1c7596dda"
6+
let tag = "v0.1.52"
7+
let checksum = "e26db56b4090678c214995f299b8cc680c4f57602393ce3e37cd5cd844160d1f"
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.51
6+
version=0.1.52
Binary file not shown.
Binary file not shown.
59.1 KB
Binary file not shown.
91.3 KB
Binary file not shown.

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,10 @@ internal typealias UniffiVTableCallbackInterfaceTrezorUiCallbackUniffiByValue =
14201420

14211421

14221422

1423+
1424+
1425+
1426+
14231427

14241428

14251429

@@ -1476,6 +1480,9 @@ internal object IntegrityCheckingUniffiLib : Library {
14761480
if (uniffi_bitkitcore_checksum_func_add_tags() != 63739.toShort()) {
14771481
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
14781482
}
1483+
if (uniffi_bitkitcore_checksum_func_approve_pubky_auth() != 22222.toShort()) {
1484+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1485+
}
14791486
if (uniffi_bitkitcore_checksum_func_blocktank_remove_all_cjit_entries() != 40127.toShort()) {
14801487
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
14811488
}
@@ -1680,6 +1687,9 @@ internal object IntegrityCheckingUniffiLib : Library {
16801687
if (uniffi_bitkitcore_checksum_func_open_channel() != 21402.toShort()) {
16811688
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
16821689
}
1690+
if (uniffi_bitkitcore_checksum_func_parse_pubky_auth_url() != 56972.toShort()) {
1691+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1692+
}
16831693
if (uniffi_bitkitcore_checksum_func_prepare_sweep_transaction() != 18273.toShort()) {
16841694
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
16851695
}
@@ -1924,6 +1934,9 @@ internal object IntegrityCheckingUniffiLib : Library {
19241934
external fun uniffi_bitkitcore_checksum_func_add_tags(
19251935
): Short
19261936
@JvmStatic
1937+
external fun uniffi_bitkitcore_checksum_func_approve_pubky_auth(
1938+
): Short
1939+
@JvmStatic
19271940
external fun uniffi_bitkitcore_checksum_func_blocktank_remove_all_cjit_entries(
19281941
): Short
19291942
@JvmStatic
@@ -2128,6 +2141,9 @@ internal object IntegrityCheckingUniffiLib : Library {
21282141
external fun uniffi_bitkitcore_checksum_func_open_channel(
21292142
): Short
21302143
@JvmStatic
2144+
external fun uniffi_bitkitcore_checksum_func_parse_pubky_auth_url(
2145+
): Short
2146+
@JvmStatic
21312147
external fun uniffi_bitkitcore_checksum_func_prepare_sweep_transaction(
21322148
): Short
21332149
@JvmStatic
@@ -2506,6 +2522,11 @@ internal object UniffiLib : Library {
25062522
uniffiCallStatus: UniffiRustCallStatus,
25072523
): Unit
25082524
@JvmStatic
2525+
external fun uniffi_bitkitcore_fn_func_approve_pubky_auth(
2526+
`authUrl`: RustBufferByValue,
2527+
`secretKeyHex`: RustBufferByValue,
2528+
): Long
2529+
@JvmStatic
25092530
external fun uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries(
25102531
): Long
25112532
@JvmStatic
@@ -2878,6 +2899,11 @@ internal object UniffiLib : Library {
28782899
`connectionString`: RustBufferByValue,
28792900
): Long
28802901
@JvmStatic
2902+
external fun uniffi_bitkitcore_fn_func_parse_pubky_auth_url(
2903+
`authUrl`: RustBufferByValue,
2904+
uniffiCallStatus: UniffiRustCallStatus,
2905+
): RustBufferByValue
2906+
@JvmStatic
28812907
external fun uniffi_bitkitcore_fn_func_prepare_sweep_transaction(
28822908
`mnemonicPhrase`: RustBufferByValue,
28832909
`network`: RustBufferByValue,
@@ -6635,6 +6661,37 @@ public object FfiConverterTypePubkyAuth: FfiConverterRustBuffer<PubkyAuth> {
66356661

66366662

66376663

6664+
public object FfiConverterTypePubkyAuthDetails: FfiConverterRustBuffer<PubkyAuthDetails> {
6665+
override fun read(buf: ByteBuffer): PubkyAuthDetails {
6666+
return PubkyAuthDetails(
6667+
FfiConverterString.read(buf),
6668+
FfiConverterString.read(buf),
6669+
FfiConverterString.read(buf),
6670+
FfiConverterOptionalString.read(buf),
6671+
FfiConverterOptionalString.read(buf),
6672+
)
6673+
}
6674+
6675+
override fun allocationSize(value: PubkyAuthDetails): ULong = (
6676+
FfiConverterString.allocationSize(value.`kind`) +
6677+
FfiConverterString.allocationSize(value.`capabilities`) +
6678+
FfiConverterString.allocationSize(value.`relay`) +
6679+
FfiConverterOptionalString.allocationSize(value.`homeserver`) +
6680+
FfiConverterOptionalString.allocationSize(value.`signupToken`)
6681+
)
6682+
6683+
override fun write(value: PubkyAuthDetails, buf: ByteBuffer) {
6684+
FfiConverterString.write(value.`kind`, buf)
6685+
FfiConverterString.write(value.`capabilities`, buf)
6686+
FfiConverterString.write(value.`relay`, buf)
6687+
FfiConverterOptionalString.write(value.`homeserver`, buf)
6688+
FfiConverterOptionalString.write(value.`signupToken`, buf)
6689+
}
6690+
}
6691+
6692+
6693+
6694+
66386695
public object FfiConverterTypePubkyProfile: FfiConverterRustBuffer<PubkyProfile> {
66396696
override fun read(buf: ByteBuffer): PubkyProfile {
66406697
return PubkyProfile(
@@ -12115,6 +12172,25 @@ public fun `addTags`(`activityId`: kotlin.String, `tags`: List<kotlin.String>) {
1211512172
}
1211612173
}
1211712174

12175+
@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class)
12176+
public suspend fun `approvePubkyAuth`(`authUrl`: kotlin.String, `secretKeyHex`: kotlin.String) {
12177+
return uniffiRustCallAsync(
12178+
UniffiLib.uniffi_bitkitcore_fn_func_approve_pubky_auth(
12179+
FfiConverterString.lower(`authUrl`),
12180+
FfiConverterString.lower(`secretKeyHex`),
12181+
),
12182+
{ future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) },
12183+
{ future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) },
12184+
{ future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) },
12185+
{ future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) },
12186+
// lift function
12187+
{ Unit },
12188+
12189+
// Error FFI converter
12190+
PubkyExceptionErrorHandler,
12191+
)
12192+
}
12193+
1211812194
@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class)
1211912195
public suspend fun `blocktankRemoveAllCjitEntries`() {
1212012196
return uniffiRustCallAsync(
@@ -13115,6 +13191,16 @@ public suspend fun `openChannel`(`orderId`: kotlin.String, `connectionString`: k
1311513191
)
1311613192
}
1311713193

13194+
@Throws(PubkyException::class)
13195+
public fun `parsePubkyAuthUrl`(`authUrl`: kotlin.String): PubkyAuthDetails {
13196+
return FfiConverterTypePubkyAuthDetails.lift(uniffiRustCallWithError(PubkyExceptionErrorHandler) { uniffiRustCallStatus ->
13197+
UniffiLib.uniffi_bitkitcore_fn_func_parse_pubky_auth_url(
13198+
FfiConverterString.lower(`authUrl`),
13199+
uniffiRustCallStatus,
13200+
)
13201+
})
13202+
}
13203+
1311813204
@Throws(SweepException::class, kotlin.coroutines.cancellation.CancellationException::class)
1311913205
public suspend fun `prepareSweepTransaction`(`mnemonicPhrase`: kotlin.String, `network`: Network?, `bip39Passphrase`: kotlin.String?, `electrumUrl`: kotlin.String, `destinationAddress`: kotlin.String, `feeRateSatsPerVbyte`: kotlin.UInt?): SweepTransactionPreview {
1312013206
return uniffiRustCallAsync(

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,37 @@ public data class PubkyAuth (
13381338

13391339

13401340

1341+
/**
1342+
* Details extracted from a `pubkyauth://` deep-link URL.
1343+
*/
1344+
@kotlinx.serialization.Serializable
1345+
public data class PubkyAuthDetails (
1346+
/**
1347+
* `"signin"` or `"signup"`.
1348+
*/
1349+
val `kind`: kotlin.String,
1350+
/**
1351+
* Requested capabilities (e.g. `"/pub/pubky.app/:rw"`).
1352+
*/
1353+
val `capabilities`: kotlin.String,
1354+
/**
1355+
* Relay URL used for the auth exchange.
1356+
*/
1357+
val `relay`: kotlin.String,
1358+
/**
1359+
* Homeserver public key (z32-encoded). Present only for signup flows.
1360+
*/
1361+
val `homeserver`: kotlin.String?,
1362+
/**
1363+
* Signup token. Present only for signup flows.
1364+
*/
1365+
val `signupToken`: kotlin.String?
1366+
) {
1367+
public companion object
1368+
}
1369+
1370+
1371+
13411372
@kotlinx.serialization.Serializable
13421373
public data class PubkyProfile (
13431374
val `name`: kotlin.String,

0 commit comments

Comments
 (0)