diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index f94ce65..0000000 --- a/Package.resolved +++ /dev/null @@ -1,32 +0,0 @@ -{ - "pins" : [ - { - "identity" : "bigint", - "kind" : "remoteSourceControl", - "location" : "https://github.com/attaswift/BigInt", - "state" : { - "revision" : "793a7fac0bfc318e85994bf6900652e827aef33e", - "version" : "5.4.1" - } - }, - { - "identity" : "cryptoswift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/krzyzanowskim/CryptoSwift.git", - "state" : { - "revision" : "e45a26384239e028ec87fbcc788f513b67e10d8f", - "version" : "1.9.0" - } - }, - { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "46072478ca365fe48370993833cb22de9b41567f", - "version" : "3.5.2" - } - } - ], - "version" : 2 -} diff --git a/Package.swift b/Package.swift index 420515f..f5f55f4 100644 --- a/Package.swift +++ b/Package.swift @@ -9,9 +9,9 @@ let package = Package( .library(name: "IDKit", targets: ["IDKit"]), ], dependencies: [ - .package(url: "https://api.github.com/repos/worldcoin/idkit-swift/releases/assets/314157476.zip", from: "5.3.0"), - .package(url: "https://api.github.com/repos/worldcoin/idkit-swift/releases/assets/314157476.zip", from: "1.9.0"), - .package(url: "https://api.github.com/repos/worldcoin/idkit-swift/releases/assets/314157476.zip", "1.0.0"..<"4.0.0"), + .package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"), + .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.9.0"), + .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"4.0.0"), ], targets: [ .target( @@ -30,4 +30,3 @@ let package = Package( ) ] ) -// Release version: 3.0.2 diff --git a/README.md b/README.md index 453961b..b845d55 100644 --- a/README.md +++ b/README.md @@ -4,117 +4,79 @@ # IDKit (Swift) -[![Swift Version](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fm1guelpf%2Fziggy-vapor%2Fbadge%3Ftype%3Dswift-versions&color=brightgreen)](http://swift.org) -[![docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://swiftpackageindex.com/worldcoin/idkit-swift) +This repository is the Swift Package Manager (SPM) mirror for the [IDKit](https://github.com/worldcoin/idkit) Rust SDK. The Swift sources are generated via [UniFFI](https://mozilla.github.io/uniffi-rs/), giving Swift clients the exact same surface area as the Rust core without any bespoke glue code. -The `IDKit` library provides a simple Swift interface for prompting users for World ID proofs. For other platforms, check out the following: -- [Kotlin](https://github.com/worldcoin/idkit-kotlin) -- [React and React Native](https://github.com/worldcoin/idkit-js) +## Package Layout -## Usage -There are three main ways to use `idkit-swift`: - -1. To request proof of a minimum verification level. For example, if you ask for proof with a minimum level `document` proof, you may get a `document`, `secure_document` or `orb` proof, depending on the highest verification level that the user has. +``` +Sources/ + IDKit/ + IDKit.swift // Version metadata + Generated/ // UniFFI-generated Swift + C headers +IDKitFFI.xcframework // (added during release automation) +``` - For more on the concept of verification levels, see [this page](https://docs.world.org/world-id/concepts). -2. To request proof of verification with specific credential categories. For example, if you ask for a `secure_document` proof, you will only receive a proof if the user verified using a `secure_document` category of credential. +The `Generated/` directory is copied directly from the build artifacts produced in the main `idkit` repository. Release automation then builds the universal Rust library and publishes an `IDKitFFI.xcframework`, which this package references. -3. To request proof that the user is 18+ years of age. The World App only allows `document` or `secure_document` verifications if the user is 18+. Therefore, you can request proof of verification using one or both of these two categories as a proxy of proof that user is 18+ years of age. +## Installation -All of these require the creation of a `Session` with our hosted [Wallet Bridge service](https://github.com/worldcoin/wallet-bridge), then polling for an update from the World App instance that the user is using to respond to the request. Wallet Bridge acts as a secure relay between your app and World App. +Add the package to your project using SwiftPM: -> [!CAUTION] -> A `Session` instance is valid only for a single proof request, and should not be re-used or cached. It's reasonably inexpensive to create, though does make a network call during initialization. By design, re-using `Sessions` will lead to errors that are user-facing in both World App and your app. +```swift +.package(url: "https://github.com/worldcoin/idkit-swift", from: "3.0.0") +``` -### Proof of Minimum Verification Level -Use the verification level API when you're interested in getting the strongest human assurance level of a user. +## Quick Start ```swift import IDKit - // 1. Initialize your App ID configured in World Developer Portal. -let appID: AppID -do { - appID = try AppID("your_app_id") -} catch { - // Handle error - return -} - -// 2. Create a session with Wallet Bridge. This requests that the user proves they're a human with an orb level verification. -let session = try await Session(appID, action: "your_action", verificationLevel: .orb) - -// 3. Create a universal link compatible with World App. -let verificationURL = session.verificationURL - -// 4. Launch World App with the verification level request. -UIApplication.shared.open(verificationURL) - -// 5. Poll for the result of the request. -for try await status in session.status() { - switch status { - case .waitingForConnection: - print("Waiting for the user to scan the QR Code") - case .awaitingConfirmation: - print("Awaiting user confirmation") - case let .confirmed(proof): - print("Got proof: \(proof)") - case let .failed(error): - print("Got error: \(error)") - } -} -``` +let signal = Signal.fromString(s: "user_action_12345") +let request = Request(credentialType: .orb, signal: signal) -### Proof of Specific Credential Categories -Use this API when you're interested in knowing if a user possesses a credential from one of the specific categories you specify. There are 3 supported categories: +let session = try Session.create( + appId: "app_staging_1234567890abcdef", + action: "vote", + requests: [request] +) -1. `document` - for credentials derived from NFC-enabled documents that can be cloned. -2. `secure_document` - for credentials derived from NFC-enabled documents that can't be cloned. -3. `personhood` - for credentials derived from the Orb. +print("Scan this QR code in World App: \(session.connectUrl())") -```swift -import IDKit +let proof = try session.waitForProofWithTimeout(timeoutSeconds: 900) +print("Verified! Nullifier: \(proof.nullifierHash)") +``` -// 1. Initialize your AppID -let appID: AppID -do { - appID = try AppID("your_app_id") -} catch { - // Handle error - return -} +For manual status polling: -// 2. Create a session with Wallet Bridge. This session requests both a secure document and personhood proof. -let session = try await Session(appID, action: "your_action", credentialCategories: [.secure_document, .personhood]) - -// 3. Create a universal link that opens either World App Clip or World App. This approach significantly speeds up getting proofs from users who don't have a verified World ID. -let deferredOnboardingURL = try session.deferredOnboardingURL - -// 4. Launch World App, or World App Clip, with the credential presentation request. -UIApplication.shared.open(deferredOnboardingURL) - -// 5. Poll for the result of the request. -for try await status in session.status() { - switch status { - case .waitingForConnection: - print("Waiting for the user to scan the QR Code") - case .awaitingConfirmation: - print("Awaiting user confirmation") - case let .confirmed(proof): - print("Got proof: \(proof)") - case let .failed(error): - print("Got error: \(error)") - } +```swift +while true { + let status = try session.poll() + switch status { + case .waitingForConnection: + print("Waiting for the user to scan…") + case .awaitingConfirmation: + print("User is confirming…") + case .confirmed(let proof): + print("Proof ready: \(proof)") + break + case .failed(let error): + fatalError("Verification failed: \(error)") + } + + Thread.sleep(forTimeInterval: 3) } ``` -Note: If `personhood` is requested along with `document` or `secure_document`, a proof of `personhood` will only be returned if the user also has `document` or `secure_document` credentials. Else, the user will be prompted to verify themselves using a `document` or `secure_document` credential first. +## Releasing New Builds -### Proof of Age of 18+ Years +Releases are automated from the main [`idkit`](https://github.com/worldcoin/idkit) repo. Merging a PR into `main` with the `release` label triggers the "Publish Swift Release" workflow, which: -The World App only accepts `document` or `secure_document` verifications if the user is 18+ as determined from the user's date of birth stored on the NFC chip of the document. Therefore, you can request proof of verification using these two categories as proof that user is 18+ years of age. +1. Builds the universal Rust library and regenerates the Swift bindings. +2. Produces `IDKitFFI.xcframework` and uploads it as a draft release asset here. +3. Syncs `Sources/IDKit`, updates `Package.swift` with the new asset URL and checksum, and tags the release. +4. Publishes the release so Swift Package Manager clients can pull the new binary target. -To do this, use credential categories API with the categories set to `[.document, .secure_document]`. +For local testing you can run `scripts/package-swift.sh` in the main repo and follow the same steps manually. diff --git a/Sources/IDKit/Generated/idkit.swift b/Sources/IDKit/Generated/idkit.swift new file mode 100644 index 0000000..c699546 --- /dev/null +++ b/Sources/IDKit/Generated/idkit.swift @@ -0,0 +1,2259 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +// swiftlint:disable all +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(idkitFFI) +import idkitFFI +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func empty() -> RustBuffer { + RustBuffer(capacity: 0, len:0, data: nil) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_idkit_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_idkit_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + self.init( + bytesNoCopy: rustBuffer.data!, + count: Int(rustBuffer.len), + deallocator: .none + ) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous to the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate extension NSLock { + func withLock(f: () throws -> T) rethrows -> T { + self.lock() + defer { self.unlock() } + return try f() + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + let neverThrow: ((RustBuffer) throws -> Never)? = nil + return try makeRustCall(callback, errorHandler: neverThrow) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> E, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> E)? +) throws -> T { + uniffiEnsureIdkitInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> E)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_UNEXPECTED_ERROR: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +private func uniffiTraitInterfaceCall( + callStatus: UnsafeMutablePointer, + makeCall: () throws -> T, + writeReturn: (T) -> () +) { + do { + try writeReturn(makeCall()) + } catch let error { + callStatus.pointee.code = CALL_UNEXPECTED_ERROR + callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) + } +} + +private func uniffiTraitInterfaceCallWithError( + callStatus: UnsafeMutablePointer, + makeCall: () throws -> T, + writeReturn: (T) -> (), + lowerError: (E) -> RustBuffer +) { + do { + try writeReturn(makeCall()) + } catch let error as E { + callStatus.pointee.code = CALL_ERROR + callStatus.pointee.errorBuf = lowerError(error) + } catch { + callStatus.pointee.code = CALL_UNEXPECTED_ERROR + callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) + } +} +// Initial value and increment amount for handles. +// These ensure that SWIFT handles always have the lowest bit set +fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1 +fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2 + +fileprivate final class UniffiHandleMap: @unchecked Sendable { + // All mutation happens with this lock held, which is why we implement @unchecked Sendable. + private let lock = NSLock() + private var map: [UInt64: T] = [:] + private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL + + func insert(obj: T) -> UInt64 { + lock.withLock { + return doInsert(obj) + } + } + + // Low-level insert function, this assumes `lock` is held. + private func doInsert(_ obj: T) -> UInt64 { + let handle = currentHandle + currentHandle += UNIFFI_HANDLEMAP_DELTA + map[handle] = obj + return handle + } + + func get(handle: UInt64) throws -> T { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return obj + } + } + + func clone(handle: UInt64) throws -> UInt64 { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return doInsert(obj) + } + } + + @discardableResult + func remove(handle: UInt64) throws -> T { + try lock.withLock { + guard let obj = map.removeValue(forKey: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return obj + } + } + + var count: Int { + get { + map.count + } + } +} + + +// Public interface members begin here. + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { + typealias FfiType = UInt64 + typealias SwiftType = UInt64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterBool : FfiConverter { + typealias FfiType = Int8 + typealias SwiftType = Bool + + public static func lift(_ value: Int8) throws -> Bool { + return value != 0 + } + + public static func lower(_ value: Bool) -> Int8 { + return value ? 1 : 0 + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Bool, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterData: FfiConverterRustBuffer { + typealias SwiftType = Data + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { + let len: Int32 = try readInt(&buf) + return Data(try readBytes(&buf, count: Int(len))) + } + + public static func write(_ value: Data, into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + writeBytes(&buf, value) + } +} + + + + +/** + * Constraint node for `UniFFI` + * + * Represents a node in a constraint tree (Credential, Any, or All). + */ +public protocol ConstraintNodeProtocol: AnyObject, Sendable { + + /** + * Serializes a constraint node to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ + func toJson() throws -> String + +} +/** + * Constraint node for `UniFFI` + * + * Represents a node in a constraint tree (Credential, Any, or All). + */ +open class ConstraintNode: ConstraintNodeProtocol, @unchecked Sendable { + fileprivate let handle: UInt64 + + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoHandle { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noHandle: NoHandle) { + self.handle = 0 + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_idkit_fn_clone_constraintnode(self.handle, $0) } + } + // No primary constructor declared for this class. + + deinit { + try! rustCall { uniffi_idkit_fn_free_constraintnode(handle, $0) } + } + + + /** + * Creates an "all" (AND) constraint node + * + * All child constraints must be satisfied. + */ +public static func all(nodes: [ConstraintNode]) -> ConstraintNode { + return try! FfiConverterTypeConstraintNode_lift(try! rustCall() { + uniffi_idkit_fn_constructor_constraintnode_all( + FfiConverterSequenceTypeConstraintNode.lower(nodes),$0 + ) +}) +} + + /** + * Creates an "any" (OR) constraint node + * + * At least one of the child constraints must be satisfied. + * Order matters: earlier constraints have higher priority. + */ +public static func any(nodes: [ConstraintNode]) -> ConstraintNode { + return try! FfiConverterTypeConstraintNode_lift(try! rustCall() { + uniffi_idkit_fn_constructor_constraintnode_any( + FfiConverterSequenceTypeConstraintNode.lower(nodes),$0 + ) +}) +} + + /** + * Creates a credential constraint node + */ +public static func credential(credentialType: CredentialType) -> ConstraintNode { + return try! FfiConverterTypeConstraintNode_lift(try! rustCall() { + uniffi_idkit_fn_constructor_constraintnode_credential( + FfiConverterTypeCredentialType_lower(credentialType),$0 + ) +}) +} + + /** + * Deserializes a constraint node from JSON + * + * # Errors + * + * Returns an error if JSON deserialization fails + */ +public static func fromJson(json: String)throws -> ConstraintNode { + return try FfiConverterTypeConstraintNode_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_constructor_constraintnode_from_json( + FfiConverterString.lower(json),$0 + ) +}) +} + + + + /** + * Serializes a constraint node to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ +open func toJson()throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_method_constraintnode_to_json( + self.uniffiCloneHandle(),$0 + ) +}) +} + + + +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeConstraintNode: FfiConverter { + typealias FfiType = UInt64 + typealias SwiftType = ConstraintNode + + public static func lift(_ handle: UInt64) throws -> ConstraintNode { + return ConstraintNode(unsafeFromHandle: handle) + } + + public static func lower(_ value: ConstraintNode) -> UInt64 { + return value.uniffiCloneHandle() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ConstraintNode { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + + public static func write(_ value: ConstraintNode, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeConstraintNode_lift(_ handle: UInt64) throws -> ConstraintNode { + return try FfiConverterTypeConstraintNode.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeConstraintNode_lower(_ value: ConstraintNode) -> UInt64 { + return FfiConverterTypeConstraintNode.lower(value) +} + + + + + + +/** + * Constraints wrapper for `UniFFI` + * + * Represents the top-level constraints for a session. + */ +public protocol ConstraintsProtocol: AnyObject, Sendable { + + /** + * Serializes constraints to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ + func toJson() throws -> String + +} +/** + * Constraints wrapper for `UniFFI` + * + * Represents the top-level constraints for a session. + */ +open class Constraints: ConstraintsProtocol, @unchecked Sendable { + fileprivate let handle: UInt64 + + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoHandle { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noHandle: NoHandle) { + self.handle = 0 + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_idkit_fn_clone_constraints(self.handle, $0) } + } + /** + * Creates constraints from a root node + */ +public convenience init(root: ConstraintNode) { + let handle = + try! rustCall() { + uniffi_idkit_fn_constructor_constraints_new( + FfiConverterTypeConstraintNode_lower(root),$0 + ) +} + self.init(unsafeFromHandle: handle) +} + + deinit { + try! rustCall { uniffi_idkit_fn_free_constraints(handle, $0) } + } + + + /** + * Creates an "all" constraint (all credentials must match) + */ +public static func all(credentials: [CredentialType]) -> Constraints { + return try! FfiConverterTypeConstraints_lift(try! rustCall() { + uniffi_idkit_fn_constructor_constraints_all( + FfiConverterSequenceTypeCredentialType.lower(credentials),$0 + ) +}) +} + + /** + * Creates an "any" constraint (at least one credential must match) + */ +public static func any(credentials: [CredentialType]) -> Constraints { + return try! FfiConverterTypeConstraints_lift(try! rustCall() { + uniffi_idkit_fn_constructor_constraints_any( + FfiConverterSequenceTypeCredentialType.lower(credentials),$0 + ) +}) +} + + /** + * Deserializes constraints from JSON + * + * # Errors + * + * Returns an error if JSON deserialization fails + */ +public static func fromJson(json: String)throws -> Constraints { + return try FfiConverterTypeConstraints_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_constructor_constraints_from_json( + FfiConverterString.lower(json),$0 + ) +}) +} + + + + /** + * Serializes constraints to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ +open func toJson()throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_method_constraints_to_json( + self.uniffiCloneHandle(),$0 + ) +}) +} + + + +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeConstraints: FfiConverter { + typealias FfiType = UInt64 + typealias SwiftType = Constraints + + public static func lift(_ handle: UInt64) throws -> Constraints { + return Constraints(unsafeFromHandle: handle) + } + + public static func lower(_ value: Constraints) -> UInt64 { + return value.uniffiCloneHandle() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Constraints { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + + public static func write(_ value: Constraints, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeConstraints_lift(_ handle: UInt64) throws -> Constraints { + return try FfiConverterTypeConstraints.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeConstraints_lower(_ value: Constraints) -> UInt64 { + return FfiConverterTypeConstraints.lower(value) +} + + + + + + +/** + * Opaque request handle for `UniFFI` + * + * This wraps the core `Request` type to work around `UniFFI` limitations with custom types. + */ +public protocol RequestProtocol: AnyObject, Sendable { + + /** + * Gets the credential type + */ + func credentialType() -> CredentialType + + /** + * Gets the `face_auth` setting + */ + func faceAuth() -> Bool? + + /** + * Gets the signal as raw bytes from a request + */ + func getSignalBytes() -> Data? + + /** + * Serializes a request to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ + func toJson() throws -> String + + /** + * Sets the face authentication requirement on a request + * + * Returns a new request with the face auth set + */ + func withFaceAuth(faceAuth: Bool) -> Request + +} +/** + * Opaque request handle for `UniFFI` + * + * This wraps the core `Request` type to work around `UniFFI` limitations with custom types. + */ +open class Request: RequestProtocol, @unchecked Sendable { + fileprivate let handle: UInt64 + + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoHandle { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noHandle: NoHandle) { + self.handle = 0 + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_idkit_fn_clone_request(self.handle, $0) } + } + /** + * Creates a new credential request + * + * # Arguments + * * `credential_type` - The type of credential to request (Orb, Face, Device, etc.) + * * `signal` - Optional signal for the proof. Use `Signal::from_string()` or `Signal::from_abi_encoded()` + */ +public convenience init(credentialType: CredentialType, signal: Signal?) { + let handle = + try! rustCall() { + uniffi_idkit_fn_constructor_request_new( + FfiConverterTypeCredentialType_lower(credentialType), + FfiConverterOptionTypeSignal.lower(signal),$0 + ) +} + self.init(unsafeFromHandle: handle) +} + + deinit { + try! rustCall { uniffi_idkit_fn_free_request(handle, $0) } + } + + + /** + * Deserializes a request from JSON + * + * # Errors + * + * Returns an error if JSON deserialization fails + */ +public static func fromJson(json: String)throws -> Request { + return try FfiConverterTypeRequest_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_constructor_request_from_json( + FfiConverterString.lower(json),$0 + ) +}) +} + + + + /** + * Gets the credential type + */ +open func credentialType() -> CredentialType { + return try! FfiConverterTypeCredentialType_lift(try! rustCall() { + uniffi_idkit_fn_method_request_credential_type( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Gets the `face_auth` setting + */ +open func faceAuth() -> Bool? { + return try! FfiConverterOptionBool.lift(try! rustCall() { + uniffi_idkit_fn_method_request_face_auth( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Gets the signal as raw bytes from a request + */ +open func getSignalBytes() -> Data? { + return try! FfiConverterOptionData.lift(try! rustCall() { + uniffi_idkit_fn_method_request_get_signal_bytes( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Serializes a request to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ +open func toJson()throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_method_request_to_json( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Sets the face authentication requirement on a request + * + * Returns a new request with the face auth set + */ +open func withFaceAuth(faceAuth: Bool) -> Request { + return try! FfiConverterTypeRequest_lift(try! rustCall() { + uniffi_idkit_fn_method_request_with_face_auth( + self.uniffiCloneHandle(), + FfiConverterBool.lower(faceAuth),$0 + ) +}) +} + + + +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeRequest: FfiConverter { + typealias FfiType = UInt64 + typealias SwiftType = Request + + public static func lift(_ handle: UInt64) throws -> Request { + return Request(unsafeFromHandle: handle) + } + + public static func lower(_ value: Request) -> UInt64 { + return value.uniffiCloneHandle() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Request { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + + public static func write(_ value: Request, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeRequest_lift(_ handle: UInt64) throws -> Request { + return try FfiConverterTypeRequest.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeRequest_lower(_ value: Request) -> UInt64 { + return FfiConverterTypeRequest.lower(value) +} + + + + + + +/** + * Session wrapper for `UniFFI` + * + * Manages a World ID verification session. + */ +public protocol SessionProtocol: AnyObject, Sendable { + + /** + * Returns the connect URL for World App + */ + func connectUrl() -> String + + /** + * Polls the bridge for the current status (non-blocking) + * + * Mirrors the `idkit-rs` `poll_for_status` helper so higher-level SDKs can + * stream updates by repeatedly invoking this method. + * + * # Errors + * + * Returns an error if the request fails or the response is invalid + */ + func pollForStatus() throws -> Status + + /** + * Returns the request ID for this session + */ + func requestId() -> String + + /** + * Waits for a proof with default timeout (15 minutes) + * + * This is a blocking convenience method that polls the bridge until completion. + * For async Rust code, use `poll_for_status()` in a loop instead. + * + * # Errors + * + * Returns an error if polling fails, verification fails, or timeout is reached + */ + func waitForProof() throws -> Proof + + /** + * Waits for a proof with a specific timeout (in seconds) + * + * This is a blocking convenience method that polls the bridge until completion. + * For async Rust code, use `poll_for_status()` in a loop instead. + * + * # Errors + * + * Returns an error if polling fails, verification fails, or timeout is reached + */ + func waitForProofWithTimeout(timeoutSeconds: UInt64) throws -> Proof + +} +/** + * Session wrapper for `UniFFI` + * + * Manages a World ID verification session. + */ +open class Session: SessionProtocol, @unchecked Sendable { + fileprivate let handle: UInt64 + + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoHandle { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noHandle: NoHandle) { + self.handle = 0 + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_idkit_fn_clone_session(self.handle, $0) } + } + // No primary constructor declared for this class. + + deinit { + try! rustCall { uniffi_idkit_fn_free_session(handle, $0) } + } + + + /** + * Creates a new session + * + * # Arguments + * + * * `app_id` - Application ID from the Developer Portal (e.g., `"app_123"`) + * * `action` - Action identifier + * * `requests` - One or more credential requests + * + * # Errors + * + * Returns an error if the session cannot be created or the request fails + */ +public static func create(appId: String, action: String, requests: [Request])throws -> Session { + return try FfiConverterTypeSession_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_constructor_session_create( + FfiConverterString.lower(appId), + FfiConverterString.lower(action), + FfiConverterSequenceTypeRequest.lower(requests),$0 + ) +}) +} + + /** + * Creates a new session with optional configuration + * + * # Arguments + * + * * `app_id` - Application ID from the Developer Portal + * * `action` - Action identifier + * * `requests` - One or more credential requests + * * `action_description` - Optional action description shown to users + * * `constraints` - Optional constraints on which credentials are acceptable + * * `bridge_url` - Optional bridge URL (defaults to production) + * + * # Errors + * + * Returns an error if the session cannot be created or the request fails + */ +public static func createWithOptions(appId: String, action: String, requests: [Request], actionDescription: String?, constraints: Constraints?, bridgeUrl: String?)throws -> Session { + return try FfiConverterTypeSession_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_constructor_session_create_with_options( + FfiConverterString.lower(appId), + FfiConverterString.lower(action), + FfiConverterSequenceTypeRequest.lower(requests), + FfiConverterOptionString.lower(actionDescription), + FfiConverterOptionTypeConstraints.lower(constraints), + FfiConverterOptionString.lower(bridgeUrl),$0 + ) +}) +} + + /** + * Creates a session from a verification level + * + * This is a convenience method that maps a verification level to the appropriate + * set of credential requests and constraints. + * + * # Errors + * + * Returns an error if the session cannot be created or the request fails + */ +public static func fromVerificationLevel(appId: String, action: String, verificationLevel: VerificationLevel, signal: String)throws -> Session { + return try FfiConverterTypeSession_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_constructor_session_from_verification_level( + FfiConverterString.lower(appId), + FfiConverterString.lower(action), + FfiConverterTypeVerificationLevel_lower(verificationLevel), + FfiConverterString.lower(signal),$0 + ) +}) +} + + + + /** + * Returns the connect URL for World App + */ +open func connectUrl() -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_idkit_fn_method_session_connect_url( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Polls the bridge for the current status (non-blocking) + * + * Mirrors the `idkit-rs` `poll_for_status` helper so higher-level SDKs can + * stream updates by repeatedly invoking this method. + * + * # Errors + * + * Returns an error if the request fails or the response is invalid + */ +open func pollForStatus()throws -> Status { + return try FfiConverterTypeStatus_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_method_session_poll_for_status( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Returns the request ID for this session + */ +open func requestId() -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_idkit_fn_method_session_request_id( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Waits for a proof with default timeout (15 minutes) + * + * This is a blocking convenience method that polls the bridge until completion. + * For async Rust code, use `poll_for_status()` in a loop instead. + * + * # Errors + * + * Returns an error if polling fails, verification fails, or timeout is reached + */ +open func waitForProof()throws -> Proof { + return try FfiConverterTypeProof_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_method_session_wait_for_proof( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Waits for a proof with a specific timeout (in seconds) + * + * This is a blocking convenience method that polls the bridge until completion. + * For async Rust code, use `poll_for_status()` in a loop instead. + * + * # Errors + * + * Returns an error if polling fails, verification fails, or timeout is reached + */ +open func waitForProofWithTimeout(timeoutSeconds: UInt64)throws -> Proof { + return try FfiConverterTypeProof_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_method_session_wait_for_proof_with_timeout( + self.uniffiCloneHandle(), + FfiConverterUInt64.lower(timeoutSeconds),$0 + ) +}) +} + + + +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeSession: FfiConverter { + typealias FfiType = UInt64 + typealias SwiftType = Session + + public static func lift(_ handle: UInt64) throws -> Session { + return Session(unsafeFromHandle: handle) + } + + public static func lower(_ value: Session) -> UInt64 { + return value.uniffiCloneHandle() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Session { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + + public static func write(_ value: Session, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSession_lift(_ handle: UInt64) throws -> Session { + return try FfiConverterTypeSession.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSession_lower(_ value: Session) -> UInt64 { + return FfiConverterTypeSession.lower(value) +} + + + + + + +/** + * Signal wrapper for `UniFFI` + * + * Represents a signal that can be either a string or ABI-encoded bytes. + */ +public protocol SignalProtocol: AnyObject, Sendable { + + /** + * Gets the signal as raw bytes + */ + func asBytes() -> Data + + /** + * Gets the signal as a string if it's a UTF-8 string signal + */ + func asString() -> String? + +} +/** + * Signal wrapper for `UniFFI` + * + * Represents a signal that can be either a string or ABI-encoded bytes. + */ +open class Signal: SignalProtocol, @unchecked Sendable { + fileprivate let handle: UInt64 + + /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoHandle { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromHandle handle: UInt64) { + self.handle = handle + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noHandle: NoHandle) { + self.handle = 0 + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiCloneHandle() -> UInt64 { + return try! rustCall { uniffi_idkit_fn_clone_signal(self.handle, $0) } + } + // No primary constructor declared for this class. + + deinit { + try! rustCall { uniffi_idkit_fn_free_signal(handle, $0) } + } + + + /** + * Creates a signal from ABI-encoded bytes + * + * Use this for on-chain use cases where the signal needs to be ABI-encoded + * according to Solidity encoding rules. + */ +public static func fromAbiEncoded(bytes: Data) -> Signal { + return try! FfiConverterTypeSignal_lift(try! rustCall() { + uniffi_idkit_fn_constructor_signal_from_abi_encoded( + FfiConverterData.lower(bytes),$0 + ) +}) +} + + /** + * Creates a signal from a string + */ +public static func fromString(s: String) -> Signal { + return try! FfiConverterTypeSignal_lift(try! rustCall() { + uniffi_idkit_fn_constructor_signal_from_string( + FfiConverterString.lower(s),$0 + ) +}) +} + + + + /** + * Gets the signal as raw bytes + */ +open func asBytes() -> Data { + return try! FfiConverterData.lift(try! rustCall() { + uniffi_idkit_fn_method_signal_as_bytes( + self.uniffiCloneHandle(),$0 + ) +}) +} + + /** + * Gets the signal as a string if it's a UTF-8 string signal + */ +open func asString() -> String? { + return try! FfiConverterOptionString.lift(try! rustCall() { + uniffi_idkit_fn_method_signal_as_string( + self.uniffiCloneHandle(),$0 + ) +}) +} + + + +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeSignal: FfiConverter { + typealias FfiType = UInt64 + typealias SwiftType = Signal + + public static func lift(_ handle: UInt64) throws -> Signal { + return Signal(unsafeFromHandle: handle) + } + + public static func lower(_ value: Signal) -> UInt64 { + return value.uniffiCloneHandle() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Signal { + let handle: UInt64 = try readInt(&buf) + return try lift(handle) + } + + public static func write(_ value: Signal, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSignal_lift(_ handle: UInt64) throws -> Signal { + return try FfiConverterTypeSignal.lift(handle) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeSignal_lower(_ value: Signal) -> UInt64 { + return FfiConverterTypeSignal.lower(value) +} + + + + +/** + * Error type for `UniFFI` bindings + */ +public enum IdkitError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError { + + + + /** + * Invalid configuration provided + */ + case InvalidConfiguration(message: String + ) + /** + * JSON serialization/deserialization error + */ + case JsonError(message: String + ) + /** + * Cryptographic operation error + */ + case CryptoError(message: String + ) + /** + * Base64 encoding/decoding error + */ + case Base64Error(message: String + ) + /** + * URL parsing error + */ + case UrlError(message: String + ) + /** + * Invalid proof provided + */ + case InvalidProof(message: String + ) + /** + * Bridge communication error + */ + case BridgeError(message: String + ) + /** + * Application-level error + */ + case AppError(message: String + ) + /** + * Unexpected response from bridge + */ + case UnexpectedResponse + /** + * Connection to bridge failed + */ + case ConnectionFailed + /** + * Request timed out + */ + case Timeout + + + + + public var errorDescription: String? { + String(reflecting: self) + } + +} + +#if compiler(>=6) +extension IdkitError: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeIdkitError: FfiConverterRustBuffer { + typealias SwiftType = IdkitError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IdkitError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .InvalidConfiguration( + message: try FfiConverterString.read(from: &buf) + ) + case 2: return .JsonError( + message: try FfiConverterString.read(from: &buf) + ) + case 3: return .CryptoError( + message: try FfiConverterString.read(from: &buf) + ) + case 4: return .Base64Error( + message: try FfiConverterString.read(from: &buf) + ) + case 5: return .UrlError( + message: try FfiConverterString.read(from: &buf) + ) + case 6: return .InvalidProof( + message: try FfiConverterString.read(from: &buf) + ) + case 7: return .BridgeError( + message: try FfiConverterString.read(from: &buf) + ) + case 8: return .AppError( + message: try FfiConverterString.read(from: &buf) + ) + case 9: return .UnexpectedResponse + case 10: return .ConnectionFailed + case 11: return .Timeout + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: IdkitError, into buf: inout [UInt8]) { + switch value { + + + + + + case let .InvalidConfiguration(message): + writeInt(&buf, Int32(1)) + FfiConverterString.write(message, into: &buf) + + + case let .JsonError(message): + writeInt(&buf, Int32(2)) + FfiConverterString.write(message, into: &buf) + + + case let .CryptoError(message): + writeInt(&buf, Int32(3)) + FfiConverterString.write(message, into: &buf) + + + case let .Base64Error(message): + writeInt(&buf, Int32(4)) + FfiConverterString.write(message, into: &buf) + + + case let .UrlError(message): + writeInt(&buf, Int32(5)) + FfiConverterString.write(message, into: &buf) + + + case let .InvalidProof(message): + writeInt(&buf, Int32(6)) + FfiConverterString.write(message, into: &buf) + + + case let .BridgeError(message): + writeInt(&buf, Int32(7)) + FfiConverterString.write(message, into: &buf) + + + case let .AppError(message): + writeInt(&buf, Int32(8)) + FfiConverterString.write(message, into: &buf) + + + case .UnexpectedResponse: + writeInt(&buf, Int32(9)) + + + case .ConnectionFailed: + writeInt(&buf, Int32(10)) + + + case .Timeout: + writeInt(&buf, Int32(11)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeIdkitError_lift(_ buf: RustBuffer) throws -> IdkitError { + return try FfiConverterTypeIdkitError.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeIdkitError_lower(_ value: IdkitError) -> RustBuffer { + return FfiConverterTypeIdkitError.lower(value) +} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Status enum for `UniFFI` + * + * Represents the status of a verification request. + */ + +public enum Status: Equatable, Hashable { + + /** + * Waiting for World App to retrieve the request + */ + case waitingForConnection + /** + * World App has retrieved the request, waiting for user confirmation + */ + case awaitingConfirmation + /** + * User has confirmed and provided a proof + */ + case confirmed(proof: Proof + ) + /** + * Request has failed + */ + case failed(error: String + ) + + + +} + +#if compiler(>=6) +extension Status: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeStatus: FfiConverterRustBuffer { + typealias SwiftType = Status + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Status { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .waitingForConnection + + case 2: return .awaitingConfirmation + + case 3: return .confirmed(proof: try FfiConverterTypeProof.read(from: &buf) + ) + + case 4: return .failed(error: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Status, into buf: inout [UInt8]) { + switch value { + + + case .waitingForConnection: + writeInt(&buf, Int32(1)) + + + case .awaitingConfirmation: + writeInt(&buf, Int32(2)) + + + case let .confirmed(proof): + writeInt(&buf, Int32(3)) + FfiConverterTypeProof.write(proof, into: &buf) + + + case let .failed(error): + writeInt(&buf, Int32(4)) + FfiConverterString.write(error, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeStatus_lift(_ buf: RustBuffer) throws -> Status { + return try FfiConverterTypeStatus.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeStatus_lower(_ value: Status) -> RustBuffer { + return FfiConverterTypeStatus.lower(value) +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer { + typealias SwiftType = Bool? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterBool.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 FfiConverterBool.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { + typealias SwiftType = String? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterString.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 FfiConverterString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer { + typealias SwiftType = Data? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterData.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 FfiConverterData.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeConstraints: FfiConverterRustBuffer { + typealias SwiftType = Constraints? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeConstraints.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 FfiConverterTypeConstraints.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeSignal: FfiConverterRustBuffer { + typealias SwiftType = Signal? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeSignal.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 FfiConverterTypeSignal.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeConstraintNode: FfiConverterRustBuffer { + typealias SwiftType = [ConstraintNode] + + public static func write(_ value: [ConstraintNode], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeConstraintNode.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ConstraintNode] { + let len: Int32 = try readInt(&buf) + var seq = [ConstraintNode]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeConstraintNode.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeRequest: FfiConverterRustBuffer { + typealias SwiftType = [Request] + + public static func write(_ value: [Request], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeRequest.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Request] { + let len: Int32 = try readInt(&buf) + var seq = [Request]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeRequest.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeCredentialType: FfiConverterRustBuffer { + typealias SwiftType = [CredentialType] + + public static func write(_ value: [CredentialType], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeCredentialType.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [CredentialType] { + let len: Int32 = try readInt(&buf) + var seq = [CredentialType]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeCredentialType.read(from: &buf)) + } + return seq + } +} +/** + * Gets the string representation of a credential type + */ +public func credentialToString(credential: CredentialType) -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_idkit_fn_func_credential_to_string( + FfiConverterTypeCredentialType_lower(credential),$0 + ) +}) +} +/** + * Deserializes a proof from JSON + * + * # Errors + * + * Returns an error if JSON deserialization fails + */ +public func proofFromJson(json: String)throws -> Proof { + return try FfiConverterTypeProof_lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_func_proof_from_json( + FfiConverterString.lower(json),$0 + ) +}) +} +/** + * Serializes a proof to JSON + * + * # Errors + * + * Returns an error if JSON serialization fails + */ +public func proofToJson(proof: Proof)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeIdkitError_lift) { + uniffi_idkit_fn_func_proof_to_json( + FfiConverterTypeProof_lower(proof),$0 + ) +}) +} + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variable to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private let initializationResult: InitializationResult = { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 30 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_idkit_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + if (uniffi_idkit_checksum_func_credential_to_string() != 61137) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_func_proof_from_json() != 41451) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_func_proof_to_json() != 11599) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_constraintnode_to_json() != 54484) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_constraints_to_json() != 54987) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_request_credential_type() != 11276) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_request_face_auth() != 29714) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_request_get_signal_bytes() != 62795) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_request_to_json() != 58566) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_request_with_face_auth() != 2778) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_session_connect_url() != 12307) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_session_poll_for_status() != 46168) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_session_request_id() != 24304) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_session_wait_for_proof() != 46359) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_session_wait_for_proof_with_timeout() != 38030) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_signal_as_bytes() != 58268) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_method_signal_as_string() != 53522) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraintnode_all() != 34904) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraintnode_any() != 13996) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraintnode_credential() != 25782) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraintnode_from_json() != 8810) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraints_all() != 22097) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraints_any() != 27843) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraints_from_json() != 52569) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_constraints_new() != 48105) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_request_from_json() != 40767) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_request_new() != 56562) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_session_create() != 30873) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_session_create_with_options() != 10844) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_session_from_verification_level() != 29046) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_signal_from_abi_encoded() != 47274) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_idkit_checksum_constructor_signal_from_string() != 7997) { + return InitializationResult.apiChecksumMismatch + } + + uniffiEnsureIdkitCoreInitialized() + return InitializationResult.ok +}() + +// Make the ensure init function public so that other modules which have external type references to +// our types can call it. +public func uniffiEnsureIdkitInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + +// swiftlint:enable all \ No newline at end of file diff --git a/Sources/IDKit/Generated/idkitFFI.h b/Sources/IDKit/Generated/idkitFFI.h new file mode 100644 index 0000000..4d6d066 --- /dev/null +++ b/Sources/IDKit/Generated/idkitFFI.h @@ -0,0 +1,914 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + uint64_t capacity; + uint64_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H +#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +typedef void (*UniffiCallbackInterfaceFree)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +typedef uint64_t (*UniffiCallbackInterfaceClone)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +typedef struct UniffiForeignFutureDroppedCallbackStruct { + uint64_t handle; + UniffiForeignFutureDroppedCallback _Nonnull free; +} UniffiForeignFutureDroppedCallbackStruct; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +typedef struct UniffiForeignFutureResultU8 { + uint8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +typedef struct UniffiForeignFutureResultI8 { + int8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +typedef struct UniffiForeignFutureResultU16 { + uint16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +typedef struct UniffiForeignFutureResultI16 { + int16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +typedef struct UniffiForeignFutureResultU32 { + uint32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +typedef struct UniffiForeignFutureResultI32 { + int32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +typedef struct UniffiForeignFutureResultU64 { + uint64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +typedef struct UniffiForeignFutureResultI64 { + int64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +typedef struct UniffiForeignFutureResultF32 { + float returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +typedef struct UniffiForeignFutureResultF64 { + double returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +typedef struct UniffiForeignFutureResultRustBuffer { + RustBuffer returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultRustBuffer; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +typedef struct UniffiForeignFutureResultVoid { + RustCallStatus callStatus; +} UniffiForeignFutureResultVoid; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid + ); + +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_CONSTRAINTNODE +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_CONSTRAINTNODE +uint64_t uniffi_idkit_fn_clone_constraintnode(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_CONSTRAINTNODE +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_CONSTRAINTNODE +void uniffi_idkit_fn_free_constraintnode(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_ALL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_ALL +uint64_t uniffi_idkit_fn_constructor_constraintnode_all(RustBuffer nodes, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_ANY +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_ANY +uint64_t uniffi_idkit_fn_constructor_constraintnode_any(RustBuffer nodes, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_CREDENTIAL +uint64_t uniffi_idkit_fn_constructor_constraintnode_credential(RustBuffer credential_type, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTNODE_FROM_JSON +uint64_t uniffi_idkit_fn_constructor_constraintnode_from_json(RustBuffer json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_CONSTRAINTNODE_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_CONSTRAINTNODE_TO_JSON +RustBuffer uniffi_idkit_fn_method_constraintnode_to_json(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_CONSTRAINTS +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_CONSTRAINTS +uint64_t uniffi_idkit_fn_clone_constraints(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_CONSTRAINTS +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_CONSTRAINTS +void uniffi_idkit_fn_free_constraints(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_ALL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_ALL +uint64_t uniffi_idkit_fn_constructor_constraints_all(RustBuffer credentials, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_ANY +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_ANY +uint64_t uniffi_idkit_fn_constructor_constraints_any(RustBuffer credentials, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_FROM_JSON +uint64_t uniffi_idkit_fn_constructor_constraints_from_json(RustBuffer json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_NEW +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_CONSTRAINTS_NEW +uint64_t uniffi_idkit_fn_constructor_constraints_new(uint64_t root, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_CONSTRAINTS_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_CONSTRAINTS_TO_JSON +RustBuffer uniffi_idkit_fn_method_constraints_to_json(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_REQUEST +uint64_t uniffi_idkit_fn_clone_request(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_REQUEST +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_REQUEST +void uniffi_idkit_fn_free_request(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_REQUEST_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_REQUEST_FROM_JSON +uint64_t uniffi_idkit_fn_constructor_request_from_json(RustBuffer json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_REQUEST_NEW +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_REQUEST_NEW +uint64_t uniffi_idkit_fn_constructor_request_new(RustBuffer credential_type, RustBuffer signal, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_CREDENTIAL_TYPE +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_CREDENTIAL_TYPE +RustBuffer uniffi_idkit_fn_method_request_credential_type(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_FACE_AUTH +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_FACE_AUTH +RustBuffer uniffi_idkit_fn_method_request_face_auth(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_GET_SIGNAL_BYTES +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_GET_SIGNAL_BYTES +RustBuffer uniffi_idkit_fn_method_request_get_signal_bytes(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_TO_JSON +RustBuffer uniffi_idkit_fn_method_request_to_json(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_WITH_FACE_AUTH +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_REQUEST_WITH_FACE_AUTH +uint64_t uniffi_idkit_fn_method_request_with_face_auth(uint64_t ptr, int8_t face_auth, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_SESSION +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_SESSION +uint64_t uniffi_idkit_fn_clone_session(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_SESSION +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_SESSION +void uniffi_idkit_fn_free_session(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SESSION_CREATE +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SESSION_CREATE +uint64_t uniffi_idkit_fn_constructor_session_create(RustBuffer app_id, RustBuffer action, RustBuffer requests, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SESSION_CREATE_WITH_OPTIONS +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SESSION_CREATE_WITH_OPTIONS +uint64_t uniffi_idkit_fn_constructor_session_create_with_options(RustBuffer app_id, RustBuffer action, RustBuffer requests, RustBuffer action_description, RustBuffer constraints, RustBuffer bridge_url, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SESSION_FROM_VERIFICATION_LEVEL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SESSION_FROM_VERIFICATION_LEVEL +uint64_t uniffi_idkit_fn_constructor_session_from_verification_level(RustBuffer app_id, RustBuffer action, RustBuffer verification_level, RustBuffer signal, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_CONNECT_URL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_CONNECT_URL +RustBuffer uniffi_idkit_fn_method_session_connect_url(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_POLL_FOR_STATUS +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_POLL_FOR_STATUS +RustBuffer uniffi_idkit_fn_method_session_poll_for_status(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_REQUEST_ID +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_REQUEST_ID +RustBuffer uniffi_idkit_fn_method_session_request_id(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_WAIT_FOR_PROOF +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_WAIT_FOR_PROOF +RustBuffer uniffi_idkit_fn_method_session_wait_for_proof(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_WAIT_FOR_PROOF_WITH_TIMEOUT +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SESSION_WAIT_FOR_PROOF_WITH_TIMEOUT +RustBuffer uniffi_idkit_fn_method_session_wait_for_proof_with_timeout(uint64_t ptr, uint64_t timeout_seconds, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_SIGNAL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CLONE_SIGNAL +uint64_t uniffi_idkit_fn_clone_signal(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_SIGNAL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FREE_SIGNAL +void uniffi_idkit_fn_free_signal(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SIGNAL_FROM_ABI_ENCODED +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SIGNAL_FROM_ABI_ENCODED +uint64_t uniffi_idkit_fn_constructor_signal_from_abi_encoded(RustBuffer bytes, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SIGNAL_FROM_STRING +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_CONSTRUCTOR_SIGNAL_FROM_STRING +uint64_t uniffi_idkit_fn_constructor_signal_from_string(RustBuffer s, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SIGNAL_AS_BYTES +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SIGNAL_AS_BYTES +RustBuffer uniffi_idkit_fn_method_signal_as_bytes(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SIGNAL_AS_STRING +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_METHOD_SIGNAL_AS_STRING +RustBuffer uniffi_idkit_fn_method_signal_as_string(uint64_t ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FUNC_CREDENTIAL_TO_STRING +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FUNC_CREDENTIAL_TO_STRING +RustBuffer uniffi_idkit_fn_func_credential_to_string(RustBuffer credential, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FUNC_PROOF_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FUNC_PROOF_FROM_JSON +RustBuffer uniffi_idkit_fn_func_proof_from_json(RustBuffer json, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FUNC_PROOF_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_FN_FUNC_PROOF_TO_JSON +RustBuffer uniffi_idkit_fn_func_proof_to_json(RustBuffer proof, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_ALLOC +#define UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_ALLOC +RustBuffer ffi_idkit_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_FROM_BYTES +#define UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_FROM_BYTES +RustBuffer ffi_idkit_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_FREE +#define UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_FREE +void ffi_idkit_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_RESERVE +#define UNIFFI_FFIDEF_FFI_IDKIT_RUSTBUFFER_RESERVE +RustBuffer ffi_idkit_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U8 +void ffi_idkit_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U8 +void ffi_idkit_rust_future_cancel_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U8 +void ffi_idkit_rust_future_free_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U8 +uint8_t ffi_idkit_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I8 +void ffi_idkit_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I8 +void ffi_idkit_rust_future_cancel_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I8 +void ffi_idkit_rust_future_free_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I8 +int8_t ffi_idkit_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U16 +void ffi_idkit_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U16 +void ffi_idkit_rust_future_cancel_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U16 +void ffi_idkit_rust_future_free_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U16 +uint16_t ffi_idkit_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I16 +void ffi_idkit_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I16 +void ffi_idkit_rust_future_cancel_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I16 +void ffi_idkit_rust_future_free_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I16 +int16_t ffi_idkit_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U32 +void ffi_idkit_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U32 +void ffi_idkit_rust_future_cancel_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U32 +void ffi_idkit_rust_future_free_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U32 +uint32_t ffi_idkit_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I32 +void ffi_idkit_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I32 +void ffi_idkit_rust_future_cancel_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I32 +void ffi_idkit_rust_future_free_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I32 +int32_t ffi_idkit_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_U64 +void ffi_idkit_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_U64 +void ffi_idkit_rust_future_cancel_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_U64 +void ffi_idkit_rust_future_free_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_U64 +uint64_t ffi_idkit_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_I64 +void ffi_idkit_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_I64 +void ffi_idkit_rust_future_cancel_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_I64 +void ffi_idkit_rust_future_free_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_I64 +int64_t ffi_idkit_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_F32 +void ffi_idkit_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_F32 +void ffi_idkit_rust_future_cancel_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_F32 +void ffi_idkit_rust_future_free_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_F32 +float ffi_idkit_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_F64 +void ffi_idkit_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_F64 +void ffi_idkit_rust_future_cancel_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_F64 +void ffi_idkit_rust_future_free_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_F64 +double ffi_idkit_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_RUST_BUFFER +void ffi_idkit_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_RUST_BUFFER +void ffi_idkit_rust_future_cancel_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_RUST_BUFFER +void ffi_idkit_rust_future_free_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_RUST_BUFFER +RustBuffer ffi_idkit_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_POLL_VOID +void ffi_idkit_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_CANCEL_VOID +void ffi_idkit_rust_future_cancel_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_FREE_VOID +void ffi_idkit_rust_future_free_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_RUST_FUTURE_COMPLETE_VOID +void ffi_idkit_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_FUNC_CREDENTIAL_TO_STRING +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_FUNC_CREDENTIAL_TO_STRING +uint16_t uniffi_idkit_checksum_func_credential_to_string(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_FUNC_PROOF_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_FUNC_PROOF_FROM_JSON +uint16_t uniffi_idkit_checksum_func_proof_from_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_FUNC_PROOF_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_FUNC_PROOF_TO_JSON +uint16_t uniffi_idkit_checksum_func_proof_to_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_CONSTRAINTNODE_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_CONSTRAINTNODE_TO_JSON +uint16_t uniffi_idkit_checksum_method_constraintnode_to_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_CONSTRAINTS_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_CONSTRAINTS_TO_JSON +uint16_t uniffi_idkit_checksum_method_constraints_to_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_CREDENTIAL_TYPE +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_CREDENTIAL_TYPE +uint16_t uniffi_idkit_checksum_method_request_credential_type(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_FACE_AUTH +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_FACE_AUTH +uint16_t uniffi_idkit_checksum_method_request_face_auth(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_GET_SIGNAL_BYTES +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_GET_SIGNAL_BYTES +uint16_t uniffi_idkit_checksum_method_request_get_signal_bytes(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_TO_JSON +uint16_t uniffi_idkit_checksum_method_request_to_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_WITH_FACE_AUTH +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_REQUEST_WITH_FACE_AUTH +uint16_t uniffi_idkit_checksum_method_request_with_face_auth(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_CONNECT_URL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_CONNECT_URL +uint16_t uniffi_idkit_checksum_method_session_connect_url(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_POLL_FOR_STATUS +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_POLL_FOR_STATUS +uint16_t uniffi_idkit_checksum_method_session_poll_for_status(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_REQUEST_ID +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_REQUEST_ID +uint16_t uniffi_idkit_checksum_method_session_request_id(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_WAIT_FOR_PROOF +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_WAIT_FOR_PROOF +uint16_t uniffi_idkit_checksum_method_session_wait_for_proof(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_WAIT_FOR_PROOF_WITH_TIMEOUT +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SESSION_WAIT_FOR_PROOF_WITH_TIMEOUT +uint16_t uniffi_idkit_checksum_method_session_wait_for_proof_with_timeout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SIGNAL_AS_BYTES +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SIGNAL_AS_BYTES +uint16_t uniffi_idkit_checksum_method_signal_as_bytes(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SIGNAL_AS_STRING +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_METHOD_SIGNAL_AS_STRING +uint16_t uniffi_idkit_checksum_method_signal_as_string(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_ALL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_ALL +uint16_t uniffi_idkit_checksum_constructor_constraintnode_all(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_ANY +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_ANY +uint16_t uniffi_idkit_checksum_constructor_constraintnode_any(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_CREDENTIAL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_CREDENTIAL +uint16_t uniffi_idkit_checksum_constructor_constraintnode_credential(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTNODE_FROM_JSON +uint16_t uniffi_idkit_checksum_constructor_constraintnode_from_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_ALL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_ALL +uint16_t uniffi_idkit_checksum_constructor_constraints_all(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_ANY +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_ANY +uint16_t uniffi_idkit_checksum_constructor_constraints_any(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_FROM_JSON +uint16_t uniffi_idkit_checksum_constructor_constraints_from_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_NEW +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_CONSTRAINTS_NEW +uint16_t uniffi_idkit_checksum_constructor_constraints_new(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_REQUEST_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_REQUEST_FROM_JSON +uint16_t uniffi_idkit_checksum_constructor_request_from_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_REQUEST_NEW +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_REQUEST_NEW +uint16_t uniffi_idkit_checksum_constructor_request_new(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SESSION_CREATE +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SESSION_CREATE +uint16_t uniffi_idkit_checksum_constructor_session_create(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SESSION_CREATE_WITH_OPTIONS +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SESSION_CREATE_WITH_OPTIONS +uint16_t uniffi_idkit_checksum_constructor_session_create_with_options(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SESSION_FROM_VERIFICATION_LEVEL +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SESSION_FROM_VERIFICATION_LEVEL +uint16_t uniffi_idkit_checksum_constructor_session_from_verification_level(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SIGNAL_FROM_ABI_ENCODED +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SIGNAL_FROM_ABI_ENCODED +uint16_t uniffi_idkit_checksum_constructor_signal_from_abi_encoded(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SIGNAL_FROM_STRING +#define UNIFFI_FFIDEF_UNIFFI_IDKIT_CHECKSUM_CONSTRUCTOR_SIGNAL_FROM_STRING +uint16_t uniffi_idkit_checksum_constructor_signal_from_string(void + +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_UNIFFI_CONTRACT_VERSION +#define UNIFFI_FFIDEF_FFI_IDKIT_UNIFFI_CONTRACT_VERSION +uint32_t ffi_idkit_uniffi_contract_version(void + +); +#endif + diff --git a/Sources/IDKit/Generated/idkitFFI.modulemap b/Sources/IDKit/Generated/idkitFFI.modulemap new file mode 100644 index 0000000..d24aacc --- /dev/null +++ b/Sources/IDKit/Generated/idkitFFI.modulemap @@ -0,0 +1,7 @@ +module idkitFFI { + header "idkitFFI.h" + export * + use "Darwin" + use "_Builtin_stdbool" + use "_Builtin_stdint" +} \ No newline at end of file diff --git a/Sources/IDKit/Generated/idkit_core.swift b/Sources/IDKit/Generated/idkit_core.swift new file mode 100644 index 0000000..dc021ed --- /dev/null +++ b/Sources/IDKit/Generated/idkit_core.swift @@ -0,0 +1,931 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +// swiftlint:disable all +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(idkit_coreFFI) +import idkit_coreFFI +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func empty() -> RustBuffer { + RustBuffer(capacity: 0, len:0, data: nil) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_idkit_core_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_idkit_core_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + self.init( + bytesNoCopy: rustBuffer.data!, + count: Int(rustBuffer.len), + deallocator: .none + ) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous to the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate extension NSLock { + func withLock(f: () throws -> T) rethrows -> T { + self.lock() + defer { self.unlock() } + return try f() + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + let neverThrow: ((RustBuffer) throws -> Never)? = nil + return try makeRustCall(callback, errorHandler: neverThrow) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> E, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> E)? +) throws -> T { + uniffiEnsureIdkitCoreInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> E)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_UNEXPECTED_ERROR: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +private func uniffiTraitInterfaceCall( + callStatus: UnsafeMutablePointer, + makeCall: () throws -> T, + writeReturn: (T) -> () +) { + do { + try writeReturn(makeCall()) + } catch let error { + callStatus.pointee.code = CALL_UNEXPECTED_ERROR + callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) + } +} + +private func uniffiTraitInterfaceCallWithError( + callStatus: UnsafeMutablePointer, + makeCall: () throws -> T, + writeReturn: (T) -> (), + lowerError: (E) -> RustBuffer +) { + do { + try writeReturn(makeCall()) + } catch let error as E { + callStatus.pointee.code = CALL_ERROR + callStatus.pointee.errorBuf = lowerError(error) + } catch { + callStatus.pointee.code = CALL_UNEXPECTED_ERROR + callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error)) + } +} +// Initial value and increment amount for handles. +// These ensure that SWIFT handles always have the lowest bit set +fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1 +fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2 + +fileprivate final class UniffiHandleMap: @unchecked Sendable { + // All mutation happens with this lock held, which is why we implement @unchecked Sendable. + private let lock = NSLock() + private var map: [UInt64: T] = [:] + private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL + + func insert(obj: T) -> UInt64 { + lock.withLock { + return doInsert(obj) + } + } + + // Low-level insert function, this assumes `lock` is held. + private func doInsert(_ obj: T) -> UInt64 { + let handle = currentHandle + currentHandle += UNIFFI_HANDLEMAP_DELTA + map[handle] = obj + return handle + } + + func get(handle: UInt64) throws -> T { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return obj + } + } + + func clone(handle: UInt64) throws -> UInt64 { + try lock.withLock { + guard let obj = map[handle] else { + throw UniffiInternalError.unexpectedStaleHandle + } + return doInsert(obj) + } + } + + @discardableResult + func remove(handle: UInt64) throws -> T { + try lock.withLock { + guard let obj = map.removeValue(forKey: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return obj + } + } + + var count: Int { + get { + map.count + } + } +} + + +// Public interface members begin here. + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + + +/** + * The proof of verification returned by the World ID protocol + */ +public struct Proof: Equatable, Hashable { + /** + * The Zero-knowledge proof of the verification (hex string, ABI encoded) + */ + public var proof: String + /** + * Hash pointer to the root of the Merkle tree (hex string, ABI encoded) + */ + public var merkleRoot: String + /** + * User's unique identifier for the app and action (hex string, ABI encoded) + */ + public var nullifierHash: String + /** + * The verification level used to generate the proof + */ + public var verificationLevel: CredentialType + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * The Zero-knowledge proof of the verification (hex string, ABI encoded) + */proof: String, + /** + * Hash pointer to the root of the Merkle tree (hex string, ABI encoded) + */merkleRoot: String, + /** + * User's unique identifier for the app and action (hex string, ABI encoded) + */nullifierHash: String, + /** + * The verification level used to generate the proof + */verificationLevel: CredentialType) { + self.proof = proof + self.merkleRoot = merkleRoot + self.nullifierHash = nullifierHash + self.verificationLevel = verificationLevel + } + + +} + +#if compiler(>=6) +extension Proof: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeProof: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Proof { + return + try Proof( + proof: FfiConverterString.read(from: &buf), + merkleRoot: FfiConverterString.read(from: &buf), + nullifierHash: FfiConverterString.read(from: &buf), + verificationLevel: FfiConverterTypeCredentialType.read(from: &buf) + ) + } + + public static func write(_ value: Proof, into buf: inout [UInt8]) { + FfiConverterString.write(value.proof, into: &buf) + FfiConverterString.write(value.merkleRoot, into: &buf) + FfiConverterString.write(value.nullifierHash, into: &buf) + FfiConverterTypeCredentialType.write(value.verificationLevel, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeProof_lift(_ buf: RustBuffer) throws -> Proof { + return try FfiConverterTypeProof.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeProof_lower(_ value: Proof) -> RustBuffer { + return FfiConverterTypeProof.lower(value) +} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Errors returned by the World App + */ + +public enum AppError: Equatable, Hashable { + + /** + * User rejected the request + */ + case userRejected + /** + * Credential unavailable + */ + case credentialUnavailable + /** + * Malformed request + */ + case malformedRequest + /** + * Invalid network + */ + case invalidNetwork + /** + * Inclusion proof pending + */ + case inclusionProofPending + /** + * Inclusion proof failed + */ + case inclusionProofFailed + /** + * Unexpected response + */ + case unexpectedResponse + /** + * Connection failed + */ + case connectionFailed + /** + * Generic error + */ + case genericError + + + +} + +#if compiler(>=6) +extension AppError: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAppError: FfiConverterRustBuffer { + typealias SwiftType = AppError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppError { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .userRejected + + case 2: return .credentialUnavailable + + case 3: return .malformedRequest + + case 4: return .invalidNetwork + + case 5: return .inclusionProofPending + + case 6: return .inclusionProofFailed + + case 7: return .unexpectedResponse + + case 8: return .connectionFailed + + case 9: return .genericError + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AppError, into buf: inout [UInt8]) { + switch value { + + + case .userRejected: + writeInt(&buf, Int32(1)) + + + case .credentialUnavailable: + writeInt(&buf, Int32(2)) + + + case .malformedRequest: + writeInt(&buf, Int32(3)) + + + case .invalidNetwork: + writeInt(&buf, Int32(4)) + + + case .inclusionProofPending: + writeInt(&buf, Int32(5)) + + + case .inclusionProofFailed: + writeInt(&buf, Int32(6)) + + + case .unexpectedResponse: + writeInt(&buf, Int32(7)) + + + case .connectionFailed: + writeInt(&buf, Int32(8)) + + + case .genericError: + writeInt(&buf, Int32(9)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAppError_lift(_ buf: RustBuffer) throws -> AppError { + return try FfiConverterTypeAppError.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAppError_lower(_ value: AppError) -> RustBuffer { + return FfiConverterTypeAppError.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Credential types that can be requested + */ + +public enum CredentialType: Equatable, Hashable { + + /** + * Orb credential + */ + case orb + /** + * Face credential + */ + case face + /** + * Secure NFC document with active or passive authentication, eID, or a Japanese MNC + */ + case secureDocument + /** + * NFC document without authentication + */ + case document + /** + * Device-based credential + */ + case device + + + +} + +#if compiler(>=6) +extension CredentialType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeCredentialType: FfiConverterRustBuffer { + typealias SwiftType = CredentialType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CredentialType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .orb + + case 2: return .face + + case 3: return .secureDocument + + case 4: return .document + + case 5: return .device + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: CredentialType, into buf: inout [UInt8]) { + switch value { + + + case .orb: + writeInt(&buf, Int32(1)) + + + case .face: + writeInt(&buf, Int32(2)) + + + case .secureDocument: + writeInt(&buf, Int32(3)) + + + case .document: + writeInt(&buf, Int32(4)) + + + case .device: + writeInt(&buf, Int32(5)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeCredentialType_lift(_ buf: RustBuffer) throws -> CredentialType { + return try FfiConverterTypeCredentialType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeCredentialType_lower(_ value: CredentialType) -> RustBuffer { + return FfiConverterTypeCredentialType.lower(value) +} + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Verification level (for backward compatibility) + */ + +public enum VerificationLevel: Equatable, Hashable { + + /** + * Orb-only verification + */ + case orb + /** + * Face or Orb verification + */ + case face + /** + * Device verification (orb or device) + */ + case device + /** + * Document verification (any document type or orb) + */ + case document + /** + * Secure document verification (secure document or orb) + */ + case secureDocument + + + +} + +#if compiler(>=6) +extension VerificationLevel: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeVerificationLevel: FfiConverterRustBuffer { + typealias SwiftType = VerificationLevel + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> VerificationLevel { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .orb + + case 2: return .face + + case 3: return .device + + case 4: return .document + + case 5: return .secureDocument + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: VerificationLevel, into buf: inout [UInt8]) { + switch value { + + + case .orb: + writeInt(&buf, Int32(1)) + + + case .face: + writeInt(&buf, Int32(2)) + + + case .device: + writeInt(&buf, Int32(3)) + + + case .document: + writeInt(&buf, Int32(4)) + + + case .secureDocument: + writeInt(&buf, Int32(5)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeVerificationLevel_lift(_ buf: RustBuffer) throws -> VerificationLevel { + return try FfiConverterTypeVerificationLevel.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeVerificationLevel_lower(_ value: VerificationLevel) -> RustBuffer { + return FfiConverterTypeVerificationLevel.lower(value) +} + + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variable to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private let initializationResult: InitializationResult = { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 30 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_idkit_core_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +}() + +// Make the ensure init function public so that other modules which have external type references to +// our types can call it. +public func uniffiEnsureIdkitCoreInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} + +// swiftlint:enable all \ No newline at end of file diff --git a/Sources/IDKit/Generated/idkit_coreFFI.h b/Sources/IDKit/Generated/idkit_coreFFI.h new file mode 100644 index 0000000..072b29d --- /dev/null +++ b/Sources/IDKit/Generated/idkit_coreFFI.h @@ -0,0 +1,512 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + uint64_t capacity; + uint64_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H +#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +typedef void (*UniffiRustFutureContinuationCallback)(uint64_t, int8_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +typedef void (*UniffiCallbackInterfaceFree)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +typedef uint64_t (*UniffiCallbackInterfaceClone)(uint64_t + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +typedef struct UniffiForeignFutureDroppedCallbackStruct { + uint64_t handle; + UniffiForeignFutureDroppedCallback _Nonnull free; +} UniffiForeignFutureDroppedCallbackStruct; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +typedef struct UniffiForeignFutureResultU8 { + uint8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +typedef void (*UniffiForeignFutureCompleteU8)(uint64_t, UniffiForeignFutureResultU8 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +typedef struct UniffiForeignFutureResultI8 { + int8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +typedef void (*UniffiForeignFutureCompleteI8)(uint64_t, UniffiForeignFutureResultI8 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +typedef struct UniffiForeignFutureResultU16 { + uint16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +typedef void (*UniffiForeignFutureCompleteU16)(uint64_t, UniffiForeignFutureResultU16 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +typedef struct UniffiForeignFutureResultI16 { + int16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +typedef void (*UniffiForeignFutureCompleteI16)(uint64_t, UniffiForeignFutureResultI16 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +typedef struct UniffiForeignFutureResultU32 { + uint32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +typedef void (*UniffiForeignFutureCompleteU32)(uint64_t, UniffiForeignFutureResultU32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +typedef struct UniffiForeignFutureResultI32 { + int32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +typedef void (*UniffiForeignFutureCompleteI32)(uint64_t, UniffiForeignFutureResultI32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +typedef struct UniffiForeignFutureResultU64 { + uint64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +typedef void (*UniffiForeignFutureCompleteU64)(uint64_t, UniffiForeignFutureResultU64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +typedef struct UniffiForeignFutureResultI64 { + int64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +typedef void (*UniffiForeignFutureCompleteI64)(uint64_t, UniffiForeignFutureResultI64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +typedef struct UniffiForeignFutureResultF32 { + float returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +typedef void (*UniffiForeignFutureCompleteF32)(uint64_t, UniffiForeignFutureResultF32 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +typedef struct UniffiForeignFutureResultF64 { + double returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +typedef void (*UniffiForeignFutureCompleteF64)(uint64_t, UniffiForeignFutureResultF64 + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +typedef struct UniffiForeignFutureResultRustBuffer { + RustBuffer returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultRustBuffer; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t, UniffiForeignFutureResultRustBuffer + ); + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +typedef struct UniffiForeignFutureResultVoid { + RustCallStatus callStatus; +} UniffiForeignFutureResultVoid; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid + ); + +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_ALLOC +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_ALLOC +RustBuffer ffi_idkit_core_rustbuffer_alloc(uint64_t size, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_FROM_BYTES +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_FROM_BYTES +RustBuffer ffi_idkit_core_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_FREE +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_FREE +void ffi_idkit_core_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_RESERVE +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUSTBUFFER_RESERVE +RustBuffer ffi_idkit_core_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U8 +void ffi_idkit_core_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U8 +void ffi_idkit_core_rust_future_cancel_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U8 +void ffi_idkit_core_rust_future_free_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U8 +uint8_t ffi_idkit_core_rust_future_complete_u8(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I8 +void ffi_idkit_core_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I8 +void ffi_idkit_core_rust_future_cancel_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I8 +void ffi_idkit_core_rust_future_free_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I8 +int8_t ffi_idkit_core_rust_future_complete_i8(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U16 +void ffi_idkit_core_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U16 +void ffi_idkit_core_rust_future_cancel_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U16 +void ffi_idkit_core_rust_future_free_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U16 +uint16_t ffi_idkit_core_rust_future_complete_u16(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I16 +void ffi_idkit_core_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I16 +void ffi_idkit_core_rust_future_cancel_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I16 +void ffi_idkit_core_rust_future_free_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I16 +int16_t ffi_idkit_core_rust_future_complete_i16(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U32 +void ffi_idkit_core_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U32 +void ffi_idkit_core_rust_future_cancel_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U32 +void ffi_idkit_core_rust_future_free_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U32 +uint32_t ffi_idkit_core_rust_future_complete_u32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I32 +void ffi_idkit_core_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I32 +void ffi_idkit_core_rust_future_cancel_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I32 +void ffi_idkit_core_rust_future_free_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I32 +int32_t ffi_idkit_core_rust_future_complete_i32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_U64 +void ffi_idkit_core_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_U64 +void ffi_idkit_core_rust_future_cancel_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_U64 +void ffi_idkit_core_rust_future_free_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_U64 +uint64_t ffi_idkit_core_rust_future_complete_u64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_I64 +void ffi_idkit_core_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_I64 +void ffi_idkit_core_rust_future_cancel_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_I64 +void ffi_idkit_core_rust_future_free_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_I64 +int64_t ffi_idkit_core_rust_future_complete_i64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_F32 +void ffi_idkit_core_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_F32 +void ffi_idkit_core_rust_future_cancel_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_F32 +void ffi_idkit_core_rust_future_free_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_F32 +float ffi_idkit_core_rust_future_complete_f32(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_F64 +void ffi_idkit_core_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_F64 +void ffi_idkit_core_rust_future_cancel_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_F64 +void ffi_idkit_core_rust_future_free_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_F64 +double ffi_idkit_core_rust_future_complete_f64(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_RUST_BUFFER +void ffi_idkit_core_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_RUST_BUFFER +void ffi_idkit_core_rust_future_cancel_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_RUST_BUFFER +void ffi_idkit_core_rust_future_free_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_RUST_BUFFER +RustBuffer ffi_idkit_core_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_POLL_VOID +void ffi_idkit_core_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback _Nonnull callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_CANCEL_VOID +void ffi_idkit_core_rust_future_cancel_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_FREE_VOID +void ffi_idkit_core_rust_future_free_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_RUST_FUTURE_COMPLETE_VOID +void ffi_idkit_core_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_IDKIT_CORE_UNIFFI_CONTRACT_VERSION +#define UNIFFI_FFIDEF_FFI_IDKIT_CORE_UNIFFI_CONTRACT_VERSION +uint32_t ffi_idkit_core_uniffi_contract_version(void + +); +#endif + diff --git a/Sources/IDKit/Generated/idkit_coreFFI.modulemap b/Sources/IDKit/Generated/idkit_coreFFI.modulemap new file mode 100644 index 0000000..a39942f --- /dev/null +++ b/Sources/IDKit/Generated/idkit_coreFFI.modulemap @@ -0,0 +1,7 @@ +module idkit_coreFFI { + header "idkit_coreFFI.h" + export * + use "Darwin" + use "_Builtin_stdbool" + use "_Builtin_stdint" +} \ No newline at end of file diff --git a/Tests/IDKitTests/Tests.swift b/Tests/IDKitTests/Tests.swift deleted file mode 100644 index 8a0e0d6..0000000 --- a/Tests/IDKitTests/Tests.swift +++ /dev/null @@ -1,97 +0,0 @@ -@testable import IDKit -import Testing - -@Test(.disabled("Run this manually to test the library!")) func testFlow() async throws { - let session = try await Session(AppID("app_ce4cb73cb75fc3b73b71ffb4de178410"), action: "test-action") - - let verificationURL = session.verificationURL - - // Generate a QR Code with this URL and scan it with World App - print("Connection URL: \(verificationURL)") - - for try await status in session.status() { - switch status { - case .waitingForConnection: - print("Waiting for the user to scan the QR Code") - case .awaitingConfirmation: - print("Awaiting user confirmation") - case let .confirmed(proof): - print("Got proof: \(proof)") - case let .failed(error): - print("Got error: \(error.localizedDescription)") - } - } -} - -// MARK: - encodeSignal Tests - -@Test func testEncodeSignalEmpty() throws { - // Empty string should hash to keccak256("") >> 8 - #expect(try encodeSignal("") == "0x00c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4") -} - -@Test func testEncodeSignalHelloWorld() throws { - #expect(try encodeSignal("hello world") == "0x0047173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01f") -} - -@Test func testEncodeSignalTest() throws { - #expect(try encodeSignal("test") == "0x009c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb6") -} - -@Test func testEncodeSignalMyTestSignal() throws { - #expect(try encodeSignal("my_test_signal") == "0x0063cd863d8abefd774a9cf896b5628208d11c2975639f996c6d05f943a20036") -} - -@Test func testEncodeSignalSignal1() throws { - #expect(try encodeSignal("signal1") == "0x00f20f8ca6b12bd32d799ca43c344265f00191a7455e061ead0b3620ea869f54") -} - -@Test func testEncodeSignalSignal2() throws { - #expect(try encodeSignal("signal2") == "0x0086bfb4197550d7104cfa94a8678249d6dbb1296134ac537231e28da770d843") -} - -@Test func testEncodeSignalAnyString() throws { - #expect(try encodeSignal("any_string") == "0x0092f38309c0e58ba0a94f6d8f5f7a0804013e12611fce779d05761924be6282") -} - -@Test func testEncodeSignalNumeric() throws { - #expect(try encodeSignal("12345") == "0x001841d653f9c4edda9d66a7e7737b39763d6bd40f569a3ec6859d3305b72310") -} - -@Test func testEncodeSignalSingleSpace() throws { - #expect(try encodeSignal(" ") == "0x00681afa780d17da29203322b473d3f210a7d621259a4e6ce9e403f5a266ff71") -} - -@Test func testEncodeSignalDoubleSpace() throws { - #expect(try encodeSignal(" ") == "0x0061b60eed9684ac70562be74e9b9ccb0b2ff8d286a9fc2928b3e798416d65ea") -} - -@Test func testEncodeSignalTab() throws { - #expect(try encodeSignal("\t") == "0x00b2e7b7a21d986ae84d62a7de4a916f006c4e42a596358b93bad65492d174c4") -} - -@Test func testEncodeSignalTestSignal123() throws { - #expect(try encodeSignal("test_signal_123") == "0x00670b177d9cbfa149888e1c0b4fd0826a4eb2f4c1288244a0add43a3409950d") -} - -@Test func testEncodeSignalConsistency() throws { - // Same input should always produce same output - let signal = "consistency_test" - let result1 = try encodeSignal(signal) - let result2 = try encodeSignal(signal) - #expect(result1 == result2) -} - -@Test func testEncodeSignalFormat() throws { - // All outputs should have the format: 0x + 64 hex characters - let testCases = ["test", "hello", "123", ""] - - for testCase in testCases { - let result = try encodeSignal(testCase) - #expect(result.hasPrefix("0x")) - #expect(result.count == 66) - - let hexPart = String(result.dropFirst(2)) - #expect(hexPart.allSatisfy { $0.isHexDigit }) - } -}