From 465718a743a19d202716b17eb5efbfd28f0c34a5 Mon Sep 17 00:00:00 2001 From: Talos <324815472+talosmachina@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:22:35 +0000 Subject: [PATCH] chore: remove unused pubky exports --- Cargo.lock | 103 +------- Cargo.toml | 1 - bindings/ios/bitkitcore.swift | 468 ---------------------------------- bindings/ios/bitkitcoreFFI.h | 178 ------------- src/lib.rs | 197 +------------- src/modules/pubky/auth.rs | 60 ----- src/modules/pubky/keys.rs | 22 -- src/modules/pubky/mod.rs | 5 - src/modules/pubky/profile.rs | 107 -------- src/modules/pubky/resolve.rs | 38 --- src/modules/pubky/session.rs | 136 ---------- src/modules/pubky/tests.rs | 426 +------------------------------ 12 files changed, 5 insertions(+), 1736 deletions(-) delete mode 100644 src/modules/pubky/session.rs diff --git a/Cargo.lock b/Cargo.lock index 757c0bae..33dbcb8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1072,8 +1072,7 @@ dependencies = [ "once_cell", "openssl", "prost", - "pubky 0.6.0", - "pubky-app-specs", + "pubky", "r2d2", "r2d2_sqlite", "rand 0.8.5", @@ -1669,20 +1668,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "cookie_store" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eac901828f88a5241ee0600950ab981148a18f2f756900ffba1b125ca6a3ef9" -dependencies = [ - "cookie", - "document-features", - "idna", - "log", - "time", - "url", -] - [[package]] name = "cookie_store" version = "0.22.1" @@ -4229,12 +4214,6 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "minicbor" version = "2.3.0" @@ -5579,31 +5558,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "pubky" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f7fe978ba733fdb614320e9b1f3910cfecf0509530511c8ba12cc8d32f8bc8" -dependencies = [ - "anyhow", - "base64 0.22.1", - "bytes", - "cookie", - "cookie_store 0.21.1", - "flume", - "futures-lite", - "futures-util", - "log", - "pkarr", - "pubky-common 0.5.4", - "reqwest 0.12.28", - "thiserror 2.0.18", - "tokio", - "tracing", - "url", - "wasm-bindgen-futures", -] - [[package]] name = "pubky" version = "0.6.0" @@ -5618,7 +5572,7 @@ dependencies = [ "httpdate", "log", "pkarr", - "pubky-common 0.6.0", + "pubky-common", "reqwest 0.12.28", "thiserror 2.0.18", "tokio", @@ -5628,46 +5582,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "pubky-app-specs" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "768489143c50693e617f2efd6b2498be0c8b0ac6280b4ba59067a3afc8b01477" -dependencies = [ - "base32", - "blake3", - "js-sys", - "mime", - "pubky 0.5.4", - "serde", - "serde-wasm-bindgen", - "serde_json", - "url", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "pubky-common" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f078584beadafe3bc8669bfd6b245f10f42b8bea24e7ccbff0e09886e310ba9b" -dependencies = [ - "argon2", - "base32", - "blake3", - "crypto_secretbox", - "ed25519-dalek 2.2.0", - "js-sys", - "once_cell", - "pkarr", - "postcard", - "pubky-timestamp", - "rand 0.9.2", - "serde", - "thiserror 2.0.18", -] - [[package]] name = "pubky-common" version = "0.6.0" @@ -6028,7 +5942,7 @@ dependencies = [ "base64 0.22.1", "bytes", "cookie", - "cookie_store 0.22.1", + "cookie_store", "futures-core", "http", "http-body", @@ -6769,17 +6683,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-wasm-bindgen" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" -dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", -] - [[package]] name = "serde-xml-rs" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index 9b630458..a8bba2c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,6 @@ minicbor = { version = "2", features = ["alloc"] } ur = "0.5.2" log = "0.4" pubky = "0.6.0" -pubky-app-specs = "0.4" # Pubky Swaps client: wire types, contract checks and HTLC spends from pubky-swap, # requests over its iroh `pubky-swap/direct/1` protocol, lockups read over Electrum. swap-common = { git = "https://github.com/coreyphillips/pubky-swap", rev = "f45e204ee7646dc91983d90e4782d40760b6c72b" } diff --git a/bindings/ios/bitkitcore.swift b/bindings/ios/bitkitcore.swift index 6b646266..611c43b9 100644 --- a/bindings/ios/bitkitcore.swift +++ b/bindings/ios/bitkitcore.swift @@ -12148,174 +12148,6 @@ public func FfiConverterTypePubkyAuthDetails_lower(_ value: PubkyAuthDetails) -> } -public struct PubkyProfile { - public var name: String - public var bio: String? - public var image: String? - public var links: [PubkyProfileLink]? - public var status: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(name: String, bio: String?, image: String?, links: [PubkyProfileLink]?, status: String?) { - self.name = name - self.bio = bio - self.image = image - self.links = links - self.status = status - } -} - -#if compiler(>=6) -extension PubkyProfile: Sendable {} -#endif - - -extension PubkyProfile: Equatable, Hashable { - public static func ==(lhs: PubkyProfile, rhs: PubkyProfile) -> Bool { - if lhs.name != rhs.name { - return false - } - if lhs.bio != rhs.bio { - return false - } - if lhs.image != rhs.image { - return false - } - if lhs.links != rhs.links { - return false - } - if lhs.status != rhs.status { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(name) - hasher.combine(bio) - hasher.combine(image) - hasher.combine(links) - hasher.combine(status) - } -} - -extension PubkyProfile: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypePubkyProfile: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyProfile { - return - try PubkyProfile( - name: FfiConverterString.read(from: &buf), - bio: FfiConverterOptionString.read(from: &buf), - image: FfiConverterOptionString.read(from: &buf), - links: FfiConverterOptionSequenceTypePubkyProfileLink.read(from: &buf), - status: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: PubkyProfile, into buf: inout [UInt8]) { - FfiConverterString.write(value.name, into: &buf) - FfiConverterOptionString.write(value.bio, into: &buf) - FfiConverterOptionString.write(value.image, into: &buf) - FfiConverterOptionSequenceTypePubkyProfileLink.write(value.links, into: &buf) - FfiConverterOptionString.write(value.status, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePubkyProfile_lift(_ buf: RustBuffer) throws -> PubkyProfile { - return try FfiConverterTypePubkyProfile.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePubkyProfile_lower(_ value: PubkyProfile) -> RustBuffer { - return FfiConverterTypePubkyProfile.lower(value) -} - - -public struct PubkyProfileLink { - public var title: String - public var url: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(title: String, url: String) { - self.title = title - self.url = url - } -} - -#if compiler(>=6) -extension PubkyProfileLink: Sendable {} -#endif - - -extension PubkyProfileLink: Equatable, Hashable { - public static func ==(lhs: PubkyProfileLink, rhs: PubkyProfileLink) -> Bool { - if lhs.title != rhs.title { - return false - } - if lhs.url != rhs.url { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(title) - hasher.combine(url) - } -} - -extension PubkyProfileLink: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypePubkyProfileLink: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyProfileLink { - return - try PubkyProfileLink( - title: FfiConverterString.read(from: &buf), - url: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: PubkyProfileLink, into buf: inout [UInt8]) { - FfiConverterString.write(value.title, into: &buf) - FfiConverterString.write(value.url, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePubkyProfileLink_lift(_ buf: RustBuffer) throws -> PubkyProfileLink { - return try FfiConverterTypePubkyProfileLink.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypePubkyProfileLink_lower(_ value: PubkyProfileLink) -> RustBuffer { - return FfiConverterTypePubkyProfileLink.lower(value) -} - - /** * What `pubky_swaps_restore` found, by swap id. */ @@ -31163,30 +30995,6 @@ fileprivate struct FfiConverterOptionSequenceTypeIManualRefund: FfiConverterRust } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterOptionSequenceTypePubkyProfileLink: FfiConverterRustBuffer { - typealias SwiftType = [PubkyProfileLink]? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterSequenceTypePubkyProfileLink.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterSequenceTypePubkyProfileLink.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -31786,31 +31594,6 @@ fileprivate struct FfiConverterSequenceTypePreActivityMetadata: FfiConverterRust } } -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -fileprivate struct FfiConverterSequenceTypePubkyProfileLink: FfiConverterRustBuffer { - typealias SwiftType = [PubkyProfileLink] - - public static func write(_ value: [PubkyProfileLink], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterTypePubkyProfileLink.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PubkyProfileLink] { - let len: Int32 = try readInt(&buf) - var seq = [PubkyProfileLink]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterTypePubkyProfileLink.read(from: &buf)) - } - return seq - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -33013,20 +32796,6 @@ public func calculateChannelLiquidityOptions(params: ChannelLiquidityParams) -> ) }) } -public func cancelPubkyAuth()async throws { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_cancel_pubky_auth( - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypePubkyError_lift - ) -} public func checkSweepableBalances(mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String)async throws -> SweepableBalances { return try await uniffiRustCallAsync( @@ -33062,20 +32831,6 @@ public func closedChannelsToJson(channels: [ClosedChannelDetails])throws -> Str ) }) } -public func completePubkyAuth()async throws -> String { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_complete_pubky_auth( - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} public func createChannelRequestUrl(k1: String, callback: String, localNodeId: String, isPrivate: Bool, cancel: Bool)throws -> String { return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeLnurlError_lift) { uniffi_bitkitcore_fn_func_create_channel_request_url( @@ -33226,13 +32981,6 @@ public func derivePrivateKey(mnemonicPhrase: String, derivationPathStr: String?, ) }) } -public func derivePubkySecretKey(seed: Data)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypePubkyError_lift) { - uniffi_bitkitcore_fn_func_derive_pubky_secret_key( - FfiConverterData.lower(seed),$0 - ) -}) -} /** * Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet * from its account extended public keys. See `derive_wallet_id` in the activity @@ -33282,62 +33030,6 @@ public func estimateOrderFeeFull(lspBalanceSat: UInt64, channelExpiryWeeks: UInt errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func fetchPubkyContacts(publicKey: String)async throws -> [String] { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_contacts(FfiConverterString.lower(publicKey) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func fetchPubkyFile(uri: String)async throws -> Data { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_file(FfiConverterString.lower(uri) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterData.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func fetchPubkyFileString(uri: String)async throws -> String { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_file_string(FfiConverterString.lower(uri) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func fetchPubkyProfile(publicKey: String)async throws -> PubkyProfile { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_profile(FfiConverterString.lower(publicKey) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypePubkyProfile_lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} /** * Combine and finalize a signed PSBT, then extract its broadcastable transaction. */ @@ -34398,97 +34090,6 @@ public func prepareSweepTransaction(mnemonicPhrase: String, network: Network?, b errorHandler: FfiConverterTypeSweepError_lift ) } -public func pubkyPublicKeyFromSecret(secretKeyHex: String)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypePubkyError_lift) { - uniffi_bitkitcore_fn_func_pubky_public_key_from_secret( - FfiConverterString.lower(secretKeyHex),$0 - ) -}) -} -public func pubkyPutWithSecretKey(secretKeyHex: String, path: String, content: Data)async throws { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_pubky_put_with_secret_key(FfiConverterString.lower(secretKeyHex),FfiConverterString.lower(path),FfiConverterData.lower(content) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func pubkySessionDelete(sessionSecret: String, path: String)async throws { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_pubky_session_delete(FfiConverterString.lower(sessionSecret),FfiConverterString.lower(path) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func pubkySessionList(sessionSecret: String, dirPath: String)async throws -> [String] { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_pubky_session_list(FfiConverterString.lower(sessionSecret),FfiConverterString.lower(dirPath) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func pubkySessionPut(sessionSecret: String, path: String, content: Data)async throws { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_pubky_session_put(FfiConverterString.lower(sessionSecret),FfiConverterString.lower(path),FfiConverterData.lower(content) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func pubkySignIn(secretKeyHex: String)async throws -> String { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_pubky_sign_in(FfiConverterString.lower(secretKeyHex) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} -public func pubkySignUp(secretKeyHex: String, homeserverPublicKeyZ32: String, signupCode: String?)async throws -> String { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_pubky_sign_up(FfiConverterString.lower(secretKeyHex),FfiConverterString.lower(homeserverPublicKeyZ32),FfiConverterOptionString.lower(signupCode) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} /** * Advance a committed route: once the provider's lockup has its confirmations, claim it to the * contact's address. Call after paying the hold invoice, until it reports `Claimed`. @@ -34767,13 +34368,6 @@ public func resetPreActivityMetadataTags(walletId: String, paymentId: String)thr ) } } -public func resolvePubkyUrl(uri: String)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypePubkyError_lift) { - uniffi_bitkitcore_fn_func_resolve_pubky_url( - FfiConverterString.lower(uri),$0 - ) -}) -} public func scanLegacyRnNativeSegwitRecoveryFunds(mnemonicPhrase: String, network: Network?, electrumUrl: String, indexLimit: UInt32, bip39Passphrase: String?)async throws -> LegacyRnCloseRecoveryScanResult { return try await uniffiRustCallAsync( @@ -34795,20 +34389,6 @@ public func serializedExtendedPubkey(xpub: String)throws -> Data { ) }) } -public func startPubkyAuth(caps: String)async throws -> String { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_start_pubky_auth(FfiConverterString.lower(caps) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift - ) -} public func testNotification(deviceToken: String, secretMessage: String, notificationType: String?, customUrl: String?)async throws -> String { return try await uniffiRustCallAsync( @@ -35893,9 +35473,6 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_calculate_channel_liquidity_options() != 51013) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_cancel_pubky_auth() != 61962) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_check_sweepable_balances() != 64201) { return InitializationResult.apiChecksumMismatch } @@ -35905,9 +35482,6 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_closed_channels_to_json() != 54955) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_complete_pubky_auth() != 48191) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_create_channel_request_url() != 9305) { return InitializationResult.apiChecksumMismatch } @@ -35953,9 +35527,6 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_derive_private_key() != 25155) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_derive_pubky_secret_key() != 36989) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_derive_wallet_id() != 30111) { return InitializationResult.apiChecksumMismatch } @@ -35968,18 +35539,6 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_estimate_order_fee_full() != 13361) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_fetch_pubky_contacts() != 18744) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_fetch_pubky_file() != 24890) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_fetch_pubky_file_string() != 47799) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_fetch_pubky_profile() != 19709) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_finalize_psbt() != 37120) { return InitializationResult.apiChecksumMismatch } @@ -36229,27 +35788,6 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_prepare_sweep_transaction() != 18273) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_pubky_public_key_from_secret() != 47481) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_pubky_put_with_secret_key() != 36562) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_pubky_session_delete() != 39070) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_pubky_session_list() != 7225) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_pubky_session_put() != 25203) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_pubky_sign_in() != 26706) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_bitkitcore_checksum_func_pubky_sign_up() != 61692) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_pubky_swaps_advance() != 27871) { return InitializationResult.apiChecksumMismatch } @@ -36304,18 +35842,12 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_reset_pre_activity_metadata_tags() != 49760) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_resolve_pubky_url() != 43253) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_scan_legacy_rn_native_segwit_recovery_funds() != 52496) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitkitcore_checksum_func_serialized_extended_pubkey() != 12807) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitkitcore_checksum_func_start_pubky_auth() != 18158) { - return InitializationResult.apiChecksumMismatch - } if (uniffi_bitkitcore_checksum_func_test_notification() != 32857) { return InitializationResult.apiChecksumMismatch } diff --git a/bindings/ios/bitkitcoreFFI.h b/bindings/ios/bitkitcoreFFI.h index 10a0c056..d0521b27 100644 --- a/bindings/ios/bitkitcoreFFI.h +++ b/bindings/ios/bitkitcoreFFI.h @@ -959,12 +959,6 @@ uint64_t uniffi_bitkitcore_fn_func_broadcast_sweep_transaction(RustBuffer psbt, #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CALCULATE_CHANNEL_LIQUIDITY_OPTIONS #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CALCULATE_CHANNEL_LIQUIDITY_OPTIONS RustBuffer uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options(RustBuffer params, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CANCEL_PUBKY_AUTH -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CANCEL_PUBKY_AUTH -uint64_t uniffi_bitkitcore_fn_func_cancel_pubky_auth(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CHECK_SWEEPABLE_BALANCES @@ -980,12 +974,6 @@ RustBuffer uniffi_bitkitcore_fn_func_closed_channels_from_json(RustBuffer json, #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CLOSED_CHANNELS_TO_JSON #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CLOSED_CHANNELS_TO_JSON RustBuffer uniffi_bitkitcore_fn_func_closed_channels_to_json(RustBuffer channels, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_COMPLETE_PUBKY_AUTH -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_COMPLETE_PUBKY_AUTH -uint64_t uniffi_bitkitcore_fn_func_complete_pubky_auth(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_CREATE_CHANNEL_REQUEST_URL @@ -1063,11 +1051,6 @@ RustBuffer uniffi_bitkitcore_fn_func_derive_onchain_descriptor(RustBuffer mnemon RustBuffer uniffi_bitkitcore_fn_func_derive_private_key(RustBuffer mnemonic_phrase, RustBuffer derivation_path_str, RustBuffer network, RustBuffer bip39_passphrase, RustCallStatus *_Nonnull out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_DERIVE_PUBKY_SECRET_KEY -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_DERIVE_PUBKY_SECRET_KEY -RustBuffer uniffi_bitkitcore_fn_func_derive_pubky_secret_key(RustBuffer seed, RustCallStatus *_Nonnull out_status -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_DERIVE_WALLET_ID #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_DERIVE_WALLET_ID RustBuffer uniffi_bitkitcore_fn_func_derive_wallet_id(RustBuffer device_type, RustBuffer xpubs, RustCallStatus *_Nonnull out_status @@ -1088,26 +1071,6 @@ uint64_t uniffi_bitkitcore_fn_func_estimate_order_fee(uint64_t lsp_balance_sat, uint64_t uniffi_bitkitcore_fn_func_estimate_order_fee_full(uint64_t lsp_balance_sat, uint32_t channel_expiry_weeks, RustBuffer options ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_CONTACTS -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_CONTACTS -uint64_t uniffi_bitkitcore_fn_func_fetch_pubky_contacts(RustBuffer public_key -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_FILE -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_FILE -uint64_t uniffi_bitkitcore_fn_func_fetch_pubky_file(RustBuffer uri -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_FILE_STRING -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_FILE_STRING -uint64_t uniffi_bitkitcore_fn_func_fetch_pubky_file_string(RustBuffer uri -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_PROFILE -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FETCH_PUBKY_PROFILE -uint64_t uniffi_bitkitcore_fn_func_fetch_pubky_profile(RustBuffer public_key -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FINALIZE_PSBT #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_FINALIZE_PSBT RustBuffer uniffi_bitkitcore_fn_func_finalize_psbt(RustBuffer original_psbt, RustBuffer signed_psbt, RustCallStatus *_Nonnull out_status @@ -1541,41 +1504,6 @@ uint64_t uniffi_bitkitcore_fn_func_prepare_legacy_rn_native_segwit_recovery_swee uint64_t uniffi_bitkitcore_fn_func_prepare_sweep_transaction(RustBuffer mnemonic_phrase, RustBuffer network, RustBuffer bip39_passphrase, RustBuffer electrum_url, RustBuffer destination_address, RustBuffer fee_rate_sats_per_vbyte ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_PUBLIC_KEY_FROM_SECRET -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_PUBLIC_KEY_FROM_SECRET -RustBuffer uniffi_bitkitcore_fn_func_pubky_public_key_from_secret(RustBuffer secret_key_hex, RustCallStatus *_Nonnull out_status -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_PUT_WITH_SECRET_KEY -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_PUT_WITH_SECRET_KEY -uint64_t uniffi_bitkitcore_fn_func_pubky_put_with_secret_key(RustBuffer secret_key_hex, RustBuffer path, RustBuffer content -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SESSION_DELETE -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SESSION_DELETE -uint64_t uniffi_bitkitcore_fn_func_pubky_session_delete(RustBuffer session_secret, RustBuffer path -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SESSION_LIST -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SESSION_LIST -uint64_t uniffi_bitkitcore_fn_func_pubky_session_list(RustBuffer session_secret, RustBuffer dir_path -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SESSION_PUT -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SESSION_PUT -uint64_t uniffi_bitkitcore_fn_func_pubky_session_put(RustBuffer session_secret, RustBuffer path, RustBuffer content -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SIGN_IN -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SIGN_IN -uint64_t uniffi_bitkitcore_fn_func_pubky_sign_in(RustBuffer secret_key_hex -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SIGN_UP -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SIGN_UP -uint64_t uniffi_bitkitcore_fn_func_pubky_sign_up(RustBuffer secret_key_hex, RustBuffer homeserver_public_key_z32, RustBuffer signup_code -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_ADVANCE #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_PUBKY_SWAPS_ADVANCE uint64_t uniffi_bitkitcore_fn_func_pubky_swaps_advance(RustBuffer swap_id, RustBuffer mnemonic, RustBuffer bip39_passphrase @@ -1668,11 +1596,6 @@ void uniffi_bitkitcore_fn_func_remove_tags(RustBuffer wallet_id, RustBuffer acti void uniffi_bitkitcore_fn_func_reset_pre_activity_metadata_tags(RustBuffer wallet_id, RustBuffer payment_id, RustCallStatus *_Nonnull out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_RESOLVE_PUBKY_URL -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_RESOLVE_PUBKY_URL -RustBuffer uniffi_bitkitcore_fn_func_resolve_pubky_url(RustBuffer uri, RustCallStatus *_Nonnull out_status -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_SCAN_LEGACY_RN_NATIVE_SEGWIT_RECOVERY_FUNDS #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_SCAN_LEGACY_RN_NATIVE_SEGWIT_RECOVERY_FUNDS uint64_t uniffi_bitkitcore_fn_func_scan_legacy_rn_native_segwit_recovery_funds(RustBuffer mnemonic_phrase, RustBuffer network, RustBuffer electrum_url, uint32_t index_limit, RustBuffer bip39_passphrase @@ -1683,11 +1606,6 @@ uint64_t uniffi_bitkitcore_fn_func_scan_legacy_rn_native_segwit_recovery_funds(R RustBuffer uniffi_bitkitcore_fn_func_serialized_extended_pubkey(RustBuffer xpub, RustCallStatus *_Nonnull out_status ); #endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_START_PUBKY_AUTH -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_START_PUBKY_AUTH -uint64_t uniffi_bitkitcore_fn_func_start_pubky_auth(RustBuffer caps -); -#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TEST_NOTIFICATION #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_TEST_NOTIFICATION uint64_t uniffi_bitkitcore_fn_func_test_notification(RustBuffer device_token, RustBuffer secret_message, RustBuffer notification_type, RustBuffer custom_url @@ -2497,12 +2415,6 @@ uint16_t uniffi_bitkitcore_checksum_func_broadcast_sweep_transaction(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_CALCULATE_CHANNEL_LIQUIDITY_OPTIONS uint16_t uniffi_bitkitcore_checksum_func_calculate_channel_liquidity_options(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_CANCEL_PUBKY_AUTH -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_CANCEL_PUBKY_AUTH -uint16_t uniffi_bitkitcore_checksum_func_cancel_pubky_auth(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_CHECK_SWEEPABLE_BALANCES @@ -2521,12 +2433,6 @@ uint16_t uniffi_bitkitcore_checksum_func_closed_channels_from_json(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_CLOSED_CHANNELS_TO_JSON uint16_t uniffi_bitkitcore_checksum_func_closed_channels_to_json(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_COMPLETE_PUBKY_AUTH -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_COMPLETE_PUBKY_AUTH -uint16_t uniffi_bitkitcore_checksum_func_complete_pubky_auth(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_CREATE_CHANNEL_REQUEST_URL @@ -2617,12 +2523,6 @@ uint16_t uniffi_bitkitcore_checksum_func_derive_onchain_descriptor(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_DERIVE_PRIVATE_KEY uint16_t uniffi_bitkitcore_checksum_func_derive_private_key(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_DERIVE_PUBKY_SECRET_KEY -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_DERIVE_PUBKY_SECRET_KEY -uint16_t uniffi_bitkitcore_checksum_func_derive_pubky_secret_key(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_DERIVE_WALLET_ID @@ -2647,30 +2547,6 @@ uint16_t uniffi_bitkitcore_checksum_func_estimate_order_fee(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_ESTIMATE_ORDER_FEE_FULL uint16_t uniffi_bitkitcore_checksum_func_estimate_order_fee_full(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_CONTACTS -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_CONTACTS -uint16_t uniffi_bitkitcore_checksum_func_fetch_pubky_contacts(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_FILE -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_FILE -uint16_t uniffi_bitkitcore_checksum_func_fetch_pubky_file(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_FILE_STRING -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_FILE_STRING -uint16_t uniffi_bitkitcore_checksum_func_fetch_pubky_file_string(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_PROFILE -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FETCH_PUBKY_PROFILE -uint16_t uniffi_bitkitcore_checksum_func_fetch_pubky_profile(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_FINALIZE_PSBT @@ -3169,48 +3045,6 @@ uint16_t uniffi_bitkitcore_checksum_func_prepare_legacy_rn_native_segwit_recover #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PREPARE_SWEEP_TRANSACTION uint16_t uniffi_bitkitcore_checksum_func_prepare_sweep_transaction(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_PUBLIC_KEY_FROM_SECRET -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_PUBLIC_KEY_FROM_SECRET -uint16_t uniffi_bitkitcore_checksum_func_pubky_public_key_from_secret(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_PUT_WITH_SECRET_KEY -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_PUT_WITH_SECRET_KEY -uint16_t uniffi_bitkitcore_checksum_func_pubky_put_with_secret_key(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SESSION_DELETE -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SESSION_DELETE -uint16_t uniffi_bitkitcore_checksum_func_pubky_session_delete(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SESSION_LIST -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SESSION_LIST -uint16_t uniffi_bitkitcore_checksum_func_pubky_session_list(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SESSION_PUT -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SESSION_PUT -uint16_t uniffi_bitkitcore_checksum_func_pubky_session_put(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SIGN_IN -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SIGN_IN -uint16_t uniffi_bitkitcore_checksum_func_pubky_sign_in(void - -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SIGN_UP -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SIGN_UP -uint16_t uniffi_bitkitcore_checksum_func_pubky_sign_up(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_PUBKY_SWAPS_ADVANCE @@ -3319,12 +3153,6 @@ uint16_t uniffi_bitkitcore_checksum_func_remove_tags(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_RESET_PRE_ACTIVITY_METADATA_TAGS uint16_t uniffi_bitkitcore_checksum_func_reset_pre_activity_metadata_tags(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_RESOLVE_PUBKY_URL -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_RESOLVE_PUBKY_URL -uint16_t uniffi_bitkitcore_checksum_func_resolve_pubky_url(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_SCAN_LEGACY_RN_NATIVE_SEGWIT_RECOVERY_FUNDS @@ -3337,12 +3165,6 @@ uint16_t uniffi_bitkitcore_checksum_func_scan_legacy_rn_native_segwit_recovery_f #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_SERIALIZED_EXTENDED_PUBKEY uint16_t uniffi_bitkitcore_checksum_func_serialized_extended_pubkey(void -); -#endif -#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_START_PUBKY_AUTH -#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_START_PUBKY_AUTH -uint16_t uniffi_bitkitcore_checksum_func_start_pubky_auth(void - ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_TEST_NOTIFICATION diff --git a/src/lib.rs b/src/lib.rs index af33b748..8e1b211c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ pub use crate::modules::jade::{ JadeState, JadeTransportCallback, JadeTransportErrorCode, JadeTransportKind, JadeTransportReadResult, JadeTransportResult, JadeVersionInfo, JadeXpubResponse, }; -use crate::modules::pubky::{PubkyAuthDetails, PubkyAuthKind, PubkyError, PubkyProfile}; +use crate::modules::pubky::{PubkyAuthDetails, PubkyError}; use crate::modules::pubky_swaps::{ self as pubky_swaps, PubkySwapError, PubkySwapRestoreReport, PubkySwapRoutePayment, PubkySwapRouteStatus, PubkySwapSentPayment, SwapRouteEdge, @@ -2151,59 +2151,6 @@ pub fn get_default_lsp_balance(params: DefaultLspBalanceParams) -> u64 { // Pubky Functions // ============================================================================ -#[uniffi::export] -pub fn resolve_pubky_url(uri: String) -> Result { - crate::modules::pubky::resolve_pubky_url(uri) -} - -#[uniffi::export] -pub async fn fetch_pubky_file(uri: String) -> Result, PubkyError> { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::fetch_pubky_file(uri).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::ResolutionFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn start_pubky_auth(caps: String) -> Result { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::start_pubky_auth(caps).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::AuthFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn cancel_pubky_auth() -> Result<(), PubkyError> { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::cancel_pubky_auth().await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::AuthFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn complete_pubky_auth() -> Result { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::complete_pubky_auth().await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::AuthFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - #[uniffi::export] pub fn parse_pubky_auth_url(auth_url: String) -> Result { crate::modules::pubky::parse_pubky_auth_url(auth_url) @@ -2226,148 +2173,6 @@ pub async fn approve_pubky_auth( }) } -#[uniffi::export] -pub async fn fetch_pubky_profile(public_key: String) -> Result { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::fetch_pubky_profile(public_key).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::FetchFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn fetch_pubky_contacts(public_key: String) -> Result, PubkyError> { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::fetch_pubky_contacts(public_key).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::FetchFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn fetch_pubky_file_string(uri: String) -> Result { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::fetch_pubky_file_string(uri).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::FetchFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub fn derive_pubky_secret_key(seed: Vec) -> Result { - crate::modules::pubky::derive_pubky_secret_key(seed) -} - -#[uniffi::export] -pub fn pubky_public_key_from_secret(secret_key_hex: String) -> Result { - crate::modules::pubky::pubky_public_key_from_secret(secret_key_hex) -} - -#[uniffi::export] -pub async fn pubky_sign_up( - secret_key_hex: String, - homeserver_public_key_z32: String, - signup_code: Option, -) -> Result { - let rt = ensure_runtime(); - rt.spawn(async move { - crate::modules::pubky::pubky_sign_up(secret_key_hex, homeserver_public_key_z32, signup_code) - .await - }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::AuthFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn pubky_sign_in(secret_key_hex: String) -> Result { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::pubky_sign_in(secret_key_hex).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::AuthFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn pubky_session_put( - session_secret: String, - path: String, - content: Vec, -) -> Result<(), PubkyError> { - let rt = ensure_runtime(); - rt.spawn(async move { - crate::modules::pubky::pubky_session_put(session_secret, path, content).await - }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::WriteFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn pubky_session_delete(session_secret: String, path: String) -> Result<(), PubkyError> { - let rt = ensure_runtime(); - rt.spawn(async move { crate::modules::pubky::pubky_session_delete(session_secret, path).await }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::WriteFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn pubky_put_with_secret_key( - secret_key_hex: String, - path: String, - content: Vec, -) -> Result<(), PubkyError> { - let rt = ensure_runtime(); - rt.spawn(async move { - crate::modules::pubky::pubky_put_with_secret_key(secret_key_hex, path, content).await - }) - .await - .unwrap_or_else(|e| { - Err(PubkyError::WriteFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - -#[uniffi::export] -pub async fn pubky_session_list( - session_secret: String, - dir_path: String, -) -> Result, PubkyError> { - let rt = ensure_runtime(); - rt.spawn( - async move { crate::modules::pubky::pubky_session_list(session_secret, dir_path).await }, - ) - .await - .unwrap_or_else(|e| { - Err(PubkyError::FetchFailed { - reason: format!("Runtime error: {}", e), - }) - }) -} - // ============================================================================ // Wake Functions // ============================================================================ diff --git a/src/modules/pubky/auth.rs b/src/modules/pubky/auth.rs index 92c9f8f9..dec0a9a6 100644 --- a/src/modules/pubky/auth.rs +++ b/src/modules/pubky/auth.rs @@ -1,69 +1,9 @@ -use once_cell::sync::OnceCell; use pubky::deep_links::DeepLink; -use pubky::{AuthFlowKind, Capabilities, PubkyAuthFlow}; -use tokio::sync::Mutex as TokioMutex; use super::errors::PubkyError; use super::keys::keypair_from_hex; use super::resolve::get_pubky; -static AUTH_FLOW: OnceCell>> = OnceCell::new(); - -fn auth_flow_slot() -> &'static TokioMutex> { - AUTH_FLOW.get_or_init(|| TokioMutex::new(None)) -} - -/// Start a Pubky auth flow and return the `pubkyauth://` deep-link URL. -pub async fn start_pubky_auth(caps: String) -> Result { - let capabilities = - Capabilities::try_from(caps.as_str()).map_err(|e| PubkyError::InvalidCapabilities { - reason: e.to_string(), - })?; - - let mut guard = auth_flow_slot().lock().await; - - if guard.is_some() { - return Err(PubkyError::AuthFailed { - reason: "An auth flow is already in progress".into(), - }); - } - - let flow = PubkyAuthFlow::start(&capabilities, AuthFlowKind::signin()).map_err(|e| { - PubkyError::AuthFailed { - reason: e.to_string(), - } - })?; - - let url = flow.authorization_url().to_string(); - *guard = Some(flow); - - Ok(url) -} - -/// Cancel an in-progress auth flow, freeing the slot for a new one. -pub async fn cancel_pubky_auth() -> Result<(), PubkyError> { - let mut guard = auth_flow_slot().lock().await; - guard.take().ok_or(PubkyError::NoActiveFlow)?; - Ok(()) -} - -/// Await Ring approval and return the session secret (`":"`). -pub async fn complete_pubky_auth() -> Result { - let flow = { - let mut guard = auth_flow_slot().lock().await; - guard.take().ok_or(PubkyError::NoActiveFlow)? - }; - - let session = flow - .await_approval() - .await - .map_err(|e| PubkyError::AuthFailed { - reason: e.to_string(), - })?; - - Ok(session.export_secret()) -} - /// The type of a `pubkyauth://` deep-link flow. #[derive(uniffi::Enum, Debug, Clone, PartialEq)] pub enum PubkyAuthKind { diff --git a/src/modules/pubky/keys.rs b/src/modules/pubky/keys.rs index 95b14ede..fe49a84f 100644 --- a/src/modules/pubky/keys.rs +++ b/src/modules/pubky/keys.rs @@ -1,4 +1,3 @@ -use bitcoin::hashes::{hmac, sha256, Hash, HashEngine, HmacEngine}; use pubky::Keypair; use super::errors::PubkyError; @@ -17,24 +16,3 @@ pub(super) fn keypair_from_hex(secret_key_hex: &str) -> Result) -> Result { - if seed.len() != 64 { - return Err(PubkyError::KeyError { - reason: format!("expected 64-byte BIP39 seed, got {}", seed.len()), - }); - } - - let mut engine = hmac::HmacEngine::::new(b"paykit/pubky"); - engine.input(&seed); - let result = hmac::Hmac::::from_engine(engine); - - Ok(hex::encode(result.to_byte_array())) -} - -/// Derive the z32-encoded public key from a hex-encoded secret key. -pub fn pubky_public_key_from_secret(secret_key_hex: String) -> Result { - let kp = keypair_from_hex(&secret_key_hex)?; - Ok(kp.public_key().z32()) -} diff --git a/src/modules/pubky/mod.rs b/src/modules/pubky/mod.rs index d16c5d5f..ff365326 100644 --- a/src/modules/pubky/mod.rs +++ b/src/modules/pubky/mod.rs @@ -3,14 +3,9 @@ mod errors; mod keys; mod profile; mod resolve; -mod session; #[cfg(test)] mod tests; pub use auth::*; pub use errors::*; -pub use keys::*; pub(crate) use profile::fetch_public_file_if_any; -pub use profile::*; -pub use resolve::*; -pub use session::*; diff --git a/src/modules/pubky/profile.rs b/src/modules/pubky/profile.rs index 76681969..ee71296b 100644 --- a/src/modules/pubky/profile.rs +++ b/src/modules/pubky/profile.rs @@ -1,49 +1,6 @@ -use pubky_app_specs::{PubkyAppUser, PubkyAppUserLink}; - use super::errors::PubkyError; use super::resolve::get_pubky; -const PROFILE_PATH: &str = "/pub/pubky.app/profile.json"; -const FOLLOWS_PATH: &str = "/pub/pubky.app/follows/"; - -#[derive(uniffi::Record, Debug, Clone)] -pub struct PubkyProfileLink { - pub title: String, - pub url: String, -} - -#[derive(uniffi::Record, Debug, Clone)] -pub struct PubkyProfile { - pub name: String, - pub bio: Option, - pub image: Option, - pub links: Option>, - pub status: Option, -} - -impl From for PubkyProfileLink { - fn from(link: PubkyAppUserLink) -> Self { - PubkyProfileLink { - title: link.title, - url: link.url, - } - } -} - -impl From for PubkyProfile { - fn from(user: PubkyAppUser) -> Self { - PubkyProfile { - name: user.name, - bio: user.bio, - image: user.image, - links: user - .links - .map(|links| links.into_iter().map(PubkyProfileLink::from).collect()), - status: user.status, - } - } -} - fn is_not_found(err: &impl std::fmt::Display) -> bool { let msg = err.to_string(); msg.contains("404") || msg.to_lowercase().contains("not found") @@ -69,67 +26,3 @@ pub(crate) async fn fetch_public_file_if_any(addr: &str) -> Result Result { - let pubky = get_pubky()?; - let addr = format!("{public_key}{PROFILE_PATH}"); - - let response = pubky.public_storage().get(&addr).await.map_err(|e| { - if is_not_found(&e) { - PubkyError::ProfileNotFound - } else { - PubkyError::FetchFailed { - reason: e.to_string(), - } - } - })?; - - let bytes = response - .bytes() - .await - .map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - })?; - - let user: PubkyAppUser = - serde_json::from_slice(&bytes).map_err(|e| PubkyError::ProfileParseFailed { - reason: e.to_string(), - })?; - - Ok(PubkyProfile::from(user)) -} - -/// Fetch the followed public keys for a user. Returns an empty list if the user has no follows. -pub async fn fetch_pubky_contacts(public_key: String) -> Result, PubkyError> { - let pubky = get_pubky()?; - let addr = format!("{public_key}{FOLLOWS_PATH}"); - let storage = pubky.public_storage(); - - let list_builder = storage.list(&addr).map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - })?; - - let entries = match list_builder.send().await { - Ok(entries) => entries, - Err(e) if is_not_found(&e) => return Ok(Vec::new()), - Err(e) => { - return Err(PubkyError::FetchFailed { - reason: e.to_string(), - }) - } - }; - - let mut contacts = Vec::new(); - for entry in entries { - let url_str = entry.to_pubky_url(); - if url_str.ends_with('/') { - continue; - } - if let Some(pk_str) = url_str.rsplit('/').next().filter(|s| !s.is_empty()) { - contacts.push(pk_str.to_string()); - } - } - - Ok(contacts) -} diff --git a/src/modules/pubky/resolve.rs b/src/modules/pubky/resolve.rs index 62b6aec8..595157ed 100644 --- a/src/modules/pubky/resolve.rs +++ b/src/modules/pubky/resolve.rs @@ -12,41 +12,3 @@ pub(super) fn get_pubky() -> Result<&'static Pubky, PubkyError> { }) }) } - -/// Convert a `pubky://` URI to its `https://_pubky./…` transport URL. -pub fn resolve_pubky_url(uri: String) -> Result { - let url = pubky::resolve_pubky(&uri).map_err(|e| PubkyError::ResolutionFailed { - reason: e.to_string(), - })?; - Ok(url.to_string()) -} - -/// Fetch a public resource from a `pubky://` URI and return as a UTF-8 string. -pub async fn fetch_pubky_file_string(uri: String) -> Result { - let bytes = fetch_pubky_file(uri).await?; - String::from_utf8(bytes).map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - }) -} - -/// Fetch a public resource from a `pubky://` URI and return its raw bytes. -pub async fn fetch_pubky_file(uri: String) -> Result, PubkyError> { - let pubky = get_pubky()?; - - let response = pubky - .public_storage() - .get(&uri) - .await - .map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - })?; - - let bytes = response - .bytes() - .await - .map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - })?; - - Ok(bytes.to_vec()) -} diff --git a/src/modules/pubky/session.rs b/src/modules/pubky/session.rs deleted file mode 100644 index 591ac34f..00000000 --- a/src/modules/pubky/session.rs +++ /dev/null @@ -1,136 +0,0 @@ -use pubky::{PubkySession, PublicKey}; - -use super::errors::PubkyError; -use super::keys::keypair_from_hex; -use super::resolve::get_pubky; - -/// Sign up on a homeserver and return the session secret (`":"`). -pub async fn pubky_sign_up( - secret_key_hex: String, - homeserver_public_key_z32: String, - signup_code: Option, -) -> Result { - let kp = keypair_from_hex(&secret_key_hex)?; - - let homeserver_pk = - PublicKey::try_from_z32(&homeserver_public_key_z32).map_err(|e| PubkyError::KeyError { - reason: e.to_string(), - })?; - - let pubky = get_pubky()?; - let signer = pubky.signer(kp); - - let session = signer - .signup(&homeserver_pk, signup_code.as_deref()) - .await - .map_err(|e| PubkyError::AuthFailed { - reason: e.to_string(), - })?; - - Ok(session.export_secret()) -} - -/// Re-authenticate with an existing secret key and return a new session secret. -pub async fn pubky_sign_in(secret_key_hex: String) -> Result { - let kp = keypair_from_hex(&secret_key_hex)?; - - let pubky = get_pubky()?; - let signer = pubky.signer(kp); - - let session = signer.signin().await.map_err(|e| PubkyError::AuthFailed { - reason: e.to_string(), - })?; - - Ok(session.export_secret()) -} - -/// Write content to a path on the user's homeserver using their session. -pub async fn pubky_session_put( - session_secret: String, - path: String, - content: Vec, -) -> Result<(), PubkyError> { - let session = import_session(&session_secret).await?; - - session - .storage() - .put(path.as_str(), content) - .await - .map_err(|e| PubkyError::WriteFailed { - reason: e.to_string(), - })?; - - Ok(()) -} - -/// Delete a resource at path on the user's homeserver. -pub async fn pubky_session_delete(session_secret: String, path: String) -> Result<(), PubkyError> { - let session = import_session(&session_secret).await?; - - session - .storage() - .delete(path.as_str()) - .await - .map_err(|e| PubkyError::WriteFailed { - reason: format!("delete failed: {e}"), - })?; - - Ok(()) -} - -/// Sign in with a secret key and write content in one shot (e.g., redirect.json on old identity). -pub async fn pubky_put_with_secret_key( - secret_key_hex: String, - path: String, - content: Vec, -) -> Result<(), PubkyError> { - let kp = keypair_from_hex(&secret_key_hex)?; - - let pubky = get_pubky()?; - let signer = pubky.signer(kp); - - let session = signer.signin().await.map_err(|e| PubkyError::AuthFailed { - reason: e.to_string(), - })?; - - session - .storage() - .put(path.as_str(), content) - .await - .map_err(|e| PubkyError::WriteFailed { - reason: e.to_string(), - })?; - - Ok(()) -} - -/// List resources in a directory on the user's homeserver. `dir_path` must end with `/`. -pub async fn pubky_session_list( - session_secret: String, - dir_path: String, -) -> Result, PubkyError> { - let session = import_session(&session_secret).await?; - - let entries = session - .storage() - .list(dir_path.as_str()) - .map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - })? - .send() - .await - .map_err(|e| PubkyError::FetchFailed { - reason: e.to_string(), - })?; - - Ok(entries.iter().map(|e| e.to_pubky_url()).collect()) -} - -/// Import a session from its secret token, validating it against the homeserver. -async fn import_session(session_secret: &str) -> Result { - PubkySession::import_secret(session_secret, None) - .await - .map_err(|e| PubkyError::AuthFailed { - reason: e.to_string(), - }) -} diff --git a/src/modules/pubky/tests.rs b/src/modules/pubky/tests.rs index 4c8daa1b..998b00a7 100644 --- a/src/modules/pubky/tests.rs +++ b/src/modules/pubky/tests.rs @@ -1,414 +1,5 @@ use super::*; -// ============================================================================ -// Resolution tests -// ============================================================================ - -#[test] -fn resolve_pubky_uri() { - let pk = "operrr8wsbpr3ue9d4qj41ge1kcc6r7fdiy6o3ugjrrhi4y77rdo"; - let uri = format!("pubky://{pk}/pub/pubky.app/files/0034RC8872KNG"); - let result = resolve_pubky_url(uri).unwrap(); - assert_eq!( - result, - format!("https://_pubky.{pk}/pub/pubky.app/files/0034RC8872KNG") - ); -} - -#[test] -fn resolve_pubky_prefixed_form() { - let pk = "operrr8wsbpr3ue9d4qj41ge1kcc6r7fdiy6o3ugjrrhi4y77rdo"; - let uri = format!("pubky{pk}/pub/pubky.app/profile.json"); - let result = resolve_pubky_url(uri).unwrap(); - assert_eq!( - result, - format!("https://_pubky.{pk}/pub/pubky.app/profile.json") - ); -} - -#[test] -fn resolve_invalid_uri() { - let result = resolve_pubky_url("not-a-pubky-uri".into()); - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::ResolutionFailed { .. } => {} - other => panic!("expected ResolutionFailed, got: {other:?}"), - } -} - -// ============================================================================ -// Auth flow tests -// ============================================================================ - -#[tokio::test] -async fn complete_without_active_flow_returns_no_active_flow() { - let result = complete_pubky_auth().await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::NoActiveFlow => {} - other => panic!("expected NoActiveFlow, got: {other:?}"), - } -} - -#[tokio::test] -async fn cancel_without_active_flow_returns_no_active_flow() { - let result = cancel_pubky_auth().await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::NoActiveFlow => {} - other => panic!("expected NoActiveFlow, got: {other:?}"), - } -} - -// ============================================================================ -// File fetch tests -// ============================================================================ - -#[tokio::test] -async fn fetch_malformed_uri_returns_error() { - let result = fetch_pubky_file("totally-not-a-pubky-uri".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::FetchFailed { .. } => {} - other => panic!("expected FetchFailed, got: {other:?}"), - } -} - -// ============================================================================ -// Profile conversion tests -// ============================================================================ - -#[test] -fn profile_from_full_app_user() { - use pubky_app_specs::{PubkyAppUser, PubkyAppUserLink}; - - let user = PubkyAppUser::new( - "Alice".to_string(), - Some("Hello world".to_string()), - Some("https://example.com/avatar.png".to_string()), - Some(vec![PubkyAppUserLink::new( - "Website".to_string(), - "https://alice.example.com".to_string(), - )]), - Some("Online".to_string()), - ); - - let profile = PubkyProfile::from(user); - assert_eq!(profile.name, "Alice"); - assert_eq!(profile.bio.as_deref(), Some("Hello world")); - assert_eq!( - profile.image.as_deref(), - Some("https://example.com/avatar.png") - ); - assert_eq!(profile.status.as_deref(), Some("Online")); - - let links = profile.links.unwrap(); - assert_eq!(links.len(), 1); - assert_eq!(links[0].title, "Website"); - assert!(links[0].url.starts_with("https://alice.example.com")); -} - -#[test] -fn profile_from_minimal_app_user() { - use pubky_app_specs::PubkyAppUser; - - let user = PubkyAppUser::new("Bob".to_string(), None, None, None, None); - - let profile = PubkyProfile::from(user); - assert_eq!(profile.name, "Bob"); - assert!(profile.bio.is_none()); - assert!(profile.image.is_none()); - assert!(profile.links.is_none()); - assert!(profile.status.is_none()); -} - -#[test] -fn profile_from_user_with_empty_links() { - use pubky_app_specs::PubkyAppUser; - - let user = PubkyAppUser::new( - "Carol".to_string(), - Some("Bio".to_string()), - None, - Some(vec![]), - None, - ); - - let profile = PubkyProfile::from(user); - assert_eq!(profile.name, "Carol"); - let links = profile.links.unwrap(); - assert!(links.is_empty()); -} - -// ============================================================================ -// Profile JSON deserialization tests -// ============================================================================ - -#[test] -fn profile_deserialized_from_full_json() { - let json = r#"{ - "name": "Dave", - "bio": "Hello", - "image": "https://example.com/img.png", - "links": [ - {"title": "Blog", "url": "https://blog.example.com"}, - {"title": "GitHub", "url": "https://github.com/dave"} - ], - "status": "Away" - }"#; - - let user: pubky_app_specs::PubkyAppUser = serde_json::from_str(json).unwrap(); - let profile = PubkyProfile::from(user); - - assert_eq!(profile.name, "Dave"); - assert_eq!(profile.bio.as_deref(), Some("Hello")); - assert_eq!( - profile.image.as_deref(), - Some("https://example.com/img.png") - ); - assert_eq!(profile.status.as_deref(), Some("Away")); - let links = profile.links.unwrap(); - assert_eq!(links.len(), 2); - assert_eq!(links[0].title, "Blog"); - assert_eq!(links[1].title, "GitHub"); -} - -#[test] -fn profile_deserialized_from_name_only_json() { - let json = r#"{"name": "Eve"}"#; - let user: pubky_app_specs::PubkyAppUser = serde_json::from_str(json).unwrap(); - let profile = PubkyProfile::from(user); - - assert_eq!(profile.name, "Eve"); - assert!(profile.bio.is_none()); - assert!(profile.image.is_none()); - assert!(profile.links.is_none()); - assert!(profile.status.is_none()); -} - -#[test] -fn profile_missing_name_json_fails() { - let json = r#"{"bio": "no name field"}"#; - let result: Result = serde_json::from_str(json); - assert!(result.is_err()); -} - -#[test] -fn profile_invalid_json_fails() { - let json = r#"not valid json"#; - let result: Result = serde_json::from_str(json); - assert!(result.is_err()); -} - -// ============================================================================ -// Profile fetch error tests -// ============================================================================ - -#[tokio::test] -async fn fetch_profile_invalid_key_returns_fetch_failed() { - let result = fetch_pubky_profile("not-a-valid-public-key".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::FetchFailed { .. } | PubkyError::ProfileNotFound => {} - other => panic!("expected FetchFailed or ProfileNotFound, got: {other:?}"), - } -} - -#[tokio::test] -async fn fetch_profile_empty_key_returns_fetch_failed() { - let result = fetch_pubky_profile(String::new()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::FetchFailed { .. } | PubkyError::ProfileNotFound => {} - other => panic!("expected FetchFailed or ProfileNotFound, got: {other:?}"), - } -} - -// ============================================================================ -// Contacts fetch error tests -// ============================================================================ - -#[tokio::test] -async fn fetch_contacts_invalid_key_returns_fetch_failed() { - let result = fetch_pubky_contacts("not-a-valid-public-key".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::FetchFailed { .. } => {} - other => panic!("expected FetchFailed, got: {other:?}"), - } -} - -#[tokio::test] -async fn fetch_contacts_empty_key_returns_fetch_failed() { - let result = fetch_pubky_contacts(String::new()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::FetchFailed { .. } => {} - other => panic!("expected FetchFailed, got: {other:?}"), - } -} - -// ============================================================================ -// Key derivation tests -// ============================================================================ - -#[test] -fn derive_secret_key_returns_valid_hex() { - let seed = vec![0xABu8; 64]; - let hex_str = derive_pubky_secret_key(seed).unwrap(); - assert_eq!(hex_str.len(), 64); // 32 bytes = 64 hex chars - assert!(hex::decode(&hex_str).is_ok()); -} - -#[test] -fn derive_secret_key_is_deterministic() { - let seed = vec![0x42u8; 64]; - let key1 = derive_pubky_secret_key(seed.clone()).unwrap(); - let key2 = derive_pubky_secret_key(seed).unwrap(); - assert_eq!(key1, key2); -} - -#[test] -fn derive_secret_key_different_seeds_produce_different_keys() { - let key1 = derive_pubky_secret_key(vec![0x01u8; 64]).unwrap(); - let key2 = derive_pubky_secret_key(vec![0x02u8; 64]).unwrap(); - assert_ne!(key1, key2); -} - -#[test] -fn derive_secret_key_rejects_short_seed() { - let result = derive_pubky_secret_key(vec![0u8; 32]); - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -#[test] -fn derive_secret_key_rejects_empty_seed() { - let result = derive_pubky_secret_key(vec![]); - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -#[test] -fn public_key_from_derived_secret_roundtrips() { - let seed = vec![0xCDu8; 64]; - let secret = derive_pubky_secret_key(seed).unwrap(); - let pk1 = pubky_public_key_from_secret(secret.clone()).unwrap(); - let pk2 = pubky_public_key_from_secret(secret).unwrap(); - assert_eq!(pk1, pk2); - assert!(!pk1.is_empty()); - // z32-encoded public keys are 52 characters - assert_eq!(pk1.len(), 52); -} - -#[test] -fn public_key_from_invalid_hex_returns_error() { - let result = pubky_public_key_from_secret("not-valid-hex".into()); - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -#[test] -fn public_key_from_empty_hex_returns_error() { - let result = pubky_public_key_from_secret(String::new()); - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -#[test] -fn public_key_from_wrong_length_hex_returns_error() { - let result = pubky_public_key_from_secret("aabb".into()); // only 2 bytes, need 32 - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -// ============================================================================ -// Sign up / sign in error tests -// ============================================================================ - -#[tokio::test] -async fn sign_up_invalid_secret_key_returns_error() { - let result = pubky_sign_up("bad-hex".into(), "some-homeserver".into(), None).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -#[tokio::test] -async fn sign_in_invalid_secret_key_returns_error() { - let result = pubky_sign_in("bad-hex".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -// ============================================================================ -// Put with secret key error tests -// ============================================================================ - -#[tokio::test] -async fn put_with_secret_key_invalid_key_returns_error() { - let result = pubky_put_with_secret_key("bad-hex".into(), "/pub/test".into(), vec![]).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::KeyError { .. } => {} - other => panic!("expected KeyError, got: {other:?}"), - } -} - -// ============================================================================ -// Session operation error tests -// ============================================================================ - -#[tokio::test] -async fn session_put_invalid_session_returns_error() { - let result = pubky_session_put("bad-session".into(), "/pub/test".into(), vec![]).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::AuthFailed { .. } => {} - other => panic!("expected AuthFailed, got: {other:?}"), - } -} - -#[tokio::test] -async fn session_delete_invalid_session_returns_error() { - let result = pubky_session_delete("bad-session".into(), "/pub/test".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::AuthFailed { .. } => {} - other => panic!("expected AuthFailed, got: {other:?}"), - } -} - -#[tokio::test] -async fn session_list_invalid_session_returns_error() { - let result = pubky_session_list("bad-session".into(), "/pub/test/".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::AuthFailed { .. } => {} - other => panic!("expected AuthFailed, got: {other:?}"), - } -} - // ============================================================================ // Approver auth tests // ============================================================================ @@ -502,8 +93,7 @@ async fn approve_auth_invalid_key_returns_error() { #[tokio::test] async fn approve_auth_invalid_url_returns_error() { - let seed = vec![0xABu8; 64]; - let secret = derive_pubky_secret_key(seed).unwrap(); + let secret = hex::encode([0xABu8; 32]); let result = approve_pubky_auth("not-a-url".into(), secret).await; assert!(result.is_err()); match result.unwrap_err() { @@ -511,17 +101,3 @@ async fn approve_auth_invalid_url_returns_error() { other => panic!("expected AuthFailed, got: {other:?}"), } } - -// ============================================================================ -// String fetch tests -// ============================================================================ - -#[tokio::test] -async fn fetch_file_string_malformed_uri_returns_error() { - let result = fetch_pubky_file_string("not-a-uri".into()).await; - assert!(result.is_err()); - match result.unwrap_err() { - PubkyError::FetchFailed { .. } => {} - other => panic!("expected FetchFailed, got: {other:?}"), - } -}