Skip to content

Commit 6dc2e68

Browse files
authored
Merge pull request #83 from synonymdev/feat/pubky-approve-auth
feat: add approver-side Pubky Auth FFI
2 parents 80f501d + 47cac66 commit 6dc2e68

22 files changed

Lines changed: 829 additions & 6 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.54"
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.54"
7+
let checksum = "8ca81d51d6d9f66ef3c33f81969d07221c21744d131f907be2006d87a807ed05"
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.54
Binary file not shown.
Binary file not shown.
26.3 KB
Binary file not shown.
92.4 KB
Binary file not shown.

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

Lines changed: 104 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+
FfiConverterTypePubkyAuthKind.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+
FfiConverterTypePubkyAuthKind.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+
FfiConverterTypePubkyAuthKind.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(
@@ -9166,6 +9223,24 @@ public object FfiConverterTypePaymentType: FfiConverterRustBuffer<PaymentType> {
91669223

91679224

91689225

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+
91699244
public object PubkyExceptionErrorHandler : UniffiRustCallStatusErrorHandler<PubkyException> {
91709245
override fun lift(errorBuf: RustBufferByValue): PubkyException = FfiConverterTypePubkyError.lift(errorBuf)
91719246
}
@@ -12115,6 +12190,25 @@ public fun `addTags`(`activityId`: kotlin.String, `tags`: List<kotlin.String>) {
1211512190
}
1211612191
}
1211712192

12193+
@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class)
12194+
public suspend fun `approvePubkyAuth`(`authUrl`: kotlin.String, `secretKeyHex`: kotlin.String) {
12195+
return uniffiRustCallAsync(
12196+
UniffiLib.uniffi_bitkitcore_fn_func_approve_pubky_auth(
12197+
FfiConverterString.lower(`authUrl`),
12198+
FfiConverterString.lower(`secretKeyHex`),
12199+
),
12200+
{ future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) },
12201+
{ future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) },
12202+
{ future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) },
12203+
{ future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) },
12204+
// lift function
12205+
{ Unit },
12206+
12207+
// Error FFI converter
12208+
PubkyExceptionErrorHandler,
12209+
)
12210+
}
12211+
1211812212
@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class)
1211912213
public suspend fun `blocktankRemoveAllCjitEntries`() {
1212012214
return uniffiRustCallAsync(
@@ -13115,6 +13209,16 @@ public suspend fun `openChannel`(`orderId`: kotlin.String, `connectionString`: k
1311513209
)
1311613210
}
1311713211

13212+
@Throws(PubkyException::class)
13213+
public fun `parsePubkyAuthUrl`(`authUrl`: kotlin.String): PubkyAuthDetails {
13214+
return FfiConverterTypePubkyAuthDetails.lift(uniffiRustCallWithError(PubkyExceptionErrorHandler) { uniffiRustCallStatus ->
13215+
UniffiLib.uniffi_bitkitcore_fn_func_parse_pubky_auth_url(
13216+
FfiConverterString.lower(`authUrl`),
13217+
uniffiRustCallStatus,
13218+
)
13219+
})
13220+
}
13221+
1311813222
@Throws(SweepException::class, kotlin.coroutines.cancellation.CancellationException::class)
1311913223
public suspend fun `prepareSweepTransaction`(`mnemonicPhrase`: kotlin.String, `network`: Network?, `bip39Passphrase`: kotlin.String?, `electrumUrl`: kotlin.String, `destinationAddress`: kotlin.String, `feeRateSatsPerVbyte`: kotlin.UInt?): SweepTransactionPreview {
1312013224
return uniffiRustCallAsync(

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

Lines changed: 48 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+
* Whether this is a signin or signup flow.
1348+
*/
1349+
val `kind`: PubkyAuthKind,
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,
@@ -3376,6 +3407,23 @@ public enum class PaymentType {
33763407

33773408

33783409

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+
33793427

33803428
public sealed class PubkyException: kotlin.Exception() {
33813429

0 commit comments

Comments
 (0)