diff --git a/Package.swift b/Package.swift index bba230cdaf..9ced638272 100644 --- a/Package.swift +++ b/Package.swift @@ -7,30 +7,38 @@ import PackageDescription let package = Package( - name: "AriesVCX", + name: "InstntAriesVCX", products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( - name: "AriesVCX", - targets: ["AriesVCX"]), + name: "InstntAriesVCX", + targets: ["InstntAriesVCX"]), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. // Targets can depend on other targets in this package and products from dependencies. .target( - name: "AriesVCX", - path: "aries/agents/ios/ariesvcx/ariesvcx/SPM/Sources/AriesVCX" - ) + name: "InstntAriesVCX", + path: "aries/agents/ios/ariesvcx/ariesvcx/Source/" + ), + .binaryTarget( + name: "VCX_uniffiFFI_Lib", + url: "https://github.com/instnt-inc/instnt-aries-vcx/releases/download/abhishek_GithubAction2/vcx.xcframework.zip", + checksum: "c8964e8a20c2e74199cf40848b7b14afc95a4f3dcae80a4dba974acf54d253ac" + ) ] ) -let MyLibraryVCX3Target = package.targets.first(where: { $0.name == "AriesVCX" }) +let AriesVCXTarget = package.targets.first(where: { $0.name == "InstntAriesVCX" }) -package.targets.append(.binaryTarget( - name: "VCX_uniffiFFI_Lib", - path: "https://github.com/instnt-inc/instnt-aries-vcx/releases/download/abhishek_GithubAction2/vcx.xcframework.zip")) +// package.targets.append(.binaryTarget( +// name: "VCX_uniffiFFI_Lib", +// url: "https://github.com/instnt-inc/instnt-aries-vcx/releases/download/abhishek_GithubAction2/vcx.xcframework.zip", +// checksum: "c8964e8a20c2e74199cf40848b7b14afc95a4f3dcae80a4dba974acf54d253ac" +// )) +//checksum: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" //#path: "aries/agents/ios/ariesvcx/ariesvcx/SPM/vcx.xcframework")) -MyLibraryVCX3Target?.dependencies.append("VCX_uniffiFFI_Lib") +AriesVCXTarget?.dependencies.append("VCX_uniffiFFI_Lib") diff --git a/aries/agents/ios/ariesvcx/ariesvcx/Source/vcx.swift b/aries/agents/ios/ariesvcx/ariesvcx/Source/vcx.swift deleted file mode 100644 index 3f508bc294..0000000000 --- a/aries/agents/ios/ariesvcx/ariesvcx/Source/vcx.swift +++ /dev/null @@ -1,1548 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! -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(vcxFFI) - import vcxFFI -#endif - -private 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 from(_ ptr: UnsafeBufferPointer) -> RustBuffer { - try! rustCall { ffi_vcx_743a_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_vcx_743a_rustbuffer_free(self, $0) } - } -} - -private 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. - -private extension Data { - init(rustBuffer: RustBuffer) { - // TODO: This copies the buffer. Can we read directly from a - // Rust buffer? - self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) - } -} - -// 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 - -private 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. -private func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { - let range = reader.offset ..< reader.offset + MemoryLayout.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 -private func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> [UInt8] { - 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. -private func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { - return try Float(bitPattern: readInt(&reader)) -} - -// Reads a float at the current offset. -private func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { - return try Double(bitPattern: readInt(&reader)) -} - -// Indicates if the offset has reached the end of the buffer. -private 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. - -private func createWriter() -> [UInt8] { - return [] -} - -private 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! -private func writeInt(_ writer: inout [UInt8], _ value: T) { - var value = value.bigEndian - withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } -} - -private func writeFloat(_ writer: inout [UInt8], _ value: Float) { - writeInt(&writer, value.bitPattern) -} - -private func writeDouble(_ writer: inout [UInt8], _ value: Double) { - writeInt(&writer, value.bitPattern) -} - -// Protocol for types that transfer other types across the FFI. This is -// analogous go the Rust trait of the same name. -private 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. -private protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType {} - -extension FfiConverterPrimitive { - public static func lift(_ value: FfiType) throws -> SwiftType { - return value - } - - 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. -private protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} - -extension FfiConverterRustBuffer { - 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 - } - - 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. -private 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 - } - } -} - -private let CALL_SUCCESS: Int8 = 0 -private let CALL_ERROR: Int8 = 1 -private let CALL_PANIC: Int8 = 2 - -private extension RustCallStatus { - init() { - self.init( - code: CALL_SUCCESS, - errorBuf: RustBuffer( - capacity: 0, - len: 0, - data: nil - ) - ) - } -} - -private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { - try makeRustCall(callback, errorHandler: { - $0.deallocate() - return UniffiInternalError.unexpectedRustCallError - }) -} - -private func rustCallWithError -(_ errorFfiConverter: F.Type, _ callback: (UnsafeMutablePointer) -> T) throws -> T - where F.SwiftType: Error, F.FfiType == RustBuffer -{ - try makeRustCall(callback, errorHandler: { try errorFfiConverter.lift($0) }) -} - -private func makeRustCall(_ callback: (UnsafeMutablePointer) -> T, errorHandler: (RustBuffer) throws -> Error) throws -> T { - var callStatus = RustCallStatus() - let returnedVal = callback(&callStatus) - switch callStatus.code { - case CALL_SUCCESS: - return returnedVal - - case CALL_ERROR: - throw try errorHandler(callStatus.errorBuf) - - case CALL_PANIC: - // 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 try UniffiInternalError.rustPanic(FfiConverterString.lift(callStatus.errorBuf)) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.rustPanic("Rust panic") - } - - default: - throw UniffiInternalError.unexpectedRustCallStatusCode - } -} - -// Public interface members begin here. - -private struct FfiConverterUInt32: FfiConverterPrimitive { - typealias FfiType = UInt32 - typealias SwiftType = UInt32 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -private 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)) - } -} - -private 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 try String(bytes: 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) - } -} - -public protocol ConnectionProtocol { - func getState() throws -> ConnectionState - func pairwiseInfo() throws -> PairwiseInfo - func acceptInvitation(profile: ProfileHolder, invitation: String) throws - func handleRequest(profile: ProfileHolder, request: String, serviceEndpoint: String, routingKeys: [String]) throws - func handleResponse(profile: ProfileHolder, response: String) throws - func sendRequest(profile: ProfileHolder, serviceEndpoint: String, routingKeys: [String]) throws - func sendResponse(profile: ProfileHolder) throws - func sendAck(profile: ProfileHolder) throws - func sendMessage(profile: ProfileHolder, message: String) throws -} - -public class Connection: ConnectionProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - - deinit { - try! rustCall { ffi_vcx_743a_Connection_object_free(pointer, $0) } - } - - public func getState() throws -> ConnectionState { - return try FfiConverterTypeConnectionState.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_get_state(self.pointer, $0) - } - ) - } - - public func pairwiseInfo() throws -> PairwiseInfo { - return try FfiConverterTypePairwiseInfo.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_pairwise_info(self.pointer, $0) - } - ) - } - - public func acceptInvitation(profile: ProfileHolder, invitation: String) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_accept_invitation(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(invitation), $0) - } - } - - public func handleRequest(profile: ProfileHolder, request: String, serviceEndpoint: String, routingKeys: [String]) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_handle_request(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(request), - FfiConverterString.lower(serviceEndpoint), - FfiConverterSequenceString.lower(routingKeys), $0) - } - } - - public func handleResponse(profile: ProfileHolder, response: String) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_handle_response(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(response), $0) - } - } - - public func sendRequest(profile: ProfileHolder, serviceEndpoint: String, routingKeys: [String]) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_send_request(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(serviceEndpoint), - FfiConverterSequenceString.lower(routingKeys), $0) - } - } - - public func sendResponse(profile: ProfileHolder) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_send_response(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), $0) - } - } - - public func sendAck(profile: ProfileHolder) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_send_ack(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), $0) - } - } - - public func sendMessage(profile: ProfileHolder, message: String) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Connection_send_message(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(message), $0) - } - } -} - -public struct FfiConverterTypeConnection: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = Connection - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Connection { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if ptr == nil { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: Connection, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> Connection { - return Connection(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: Connection) -> UnsafeMutableRawPointer { - return value.pointer - } -} - -public protocol HolderProtocol { - func setProposal(credentialProposal: String) throws - func prepareCredentialRequest(profile: ProfileHolder, myPwDid: String) throws - func getMsgCredentialRequest() throws -> String - func declineOffer(comment: String?) throws -> String - func processCredential(profile: ProfileHolder, credential: String) throws - func isTerminalState() throws -> Bool - func getState() throws -> HolderState - func getSourceId() throws -> String - func getCredential() throws -> String - func getAttributes() throws -> String - func getAttachment() throws -> String - func getOffer() throws -> String - func getTailsLocation() throws -> String - func getTailsHash() throws -> String - func getRevRegId() throws -> String - func getCredId() throws -> String - func getThreadId() throws -> String - func isRevokable(profile: ProfileHolder) throws -> Bool - func isRevoked(profile: ProfileHolder) throws -> Bool - func getCredRevId(profile: ProfileHolder) throws -> UInt32 - func getProblemReport() throws -> String - func getFinalMessage() throws -> String? -} - -public class Holder: HolderProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - - deinit { - try! rustCall { ffi_vcx_743a_Holder_object_free(pointer, $0) } - } - - public func setProposal(credentialProposal: String) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_set_proposal(self.pointer, - FfiConverterString.lower(credentialProposal), $0) - } - } - - public func prepareCredentialRequest(profile: ProfileHolder, myPwDid: String) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_prepare_credential_request(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(myPwDid), $0) - } - } - - public func getMsgCredentialRequest() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_msg_credential_request(self.pointer, $0) - } - ) - } - - public func declineOffer(comment: String?) throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_decline_offer(self.pointer, - FfiConverterOptionString.lower(comment), $0) - } - ) - } - - public func processCredential(profile: ProfileHolder, credential: String) throws { - try - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_process_credential(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(credential), $0) - } - } - - public func isTerminalState() throws -> Bool { - return try FfiConverterBool.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_is_terminal_state(self.pointer, $0) - } - ) - } - - public func getState() throws -> HolderState { - return try FfiConverterTypeHolderState.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_state(self.pointer, $0) - } - ) - } - - public func getSourceId() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_source_id(self.pointer, $0) - } - ) - } - - public func getCredential() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_credential(self.pointer, $0) - } - ) - } - - public func getAttributes() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_attributes(self.pointer, $0) - } - ) - } - - public func getAttachment() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_attachment(self.pointer, $0) - } - ) - } - - public func getOffer() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_offer(self.pointer, $0) - } - ) - } - - public func getTailsLocation() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_tails_location(self.pointer, $0) - } - ) - } - - public func getTailsHash() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_tails_hash(self.pointer, $0) - } - ) - } - - public func getRevRegId() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_rev_reg_id(self.pointer, $0) - } - ) - } - - public func getCredId() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_cred_id(self.pointer, $0) - } - ) - } - - public func getThreadId() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_thread_id(self.pointer, $0) - } - ) - } - - public func isRevokable(profile: ProfileHolder) throws -> Bool { - return try FfiConverterBool.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_is_revokable(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), $0) - } - ) - } - - public func isRevoked(profile: ProfileHolder) throws -> Bool { - return try FfiConverterBool.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_is_revoked(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), $0) - } - ) - } - - public func getCredRevId(profile: ProfileHolder) throws -> UInt32 { - return try FfiConverterUInt32.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_cred_rev_id(self.pointer, - FfiConverterTypeProfileHolder.lower(profile), $0) - } - ) - } - - public func getProblemReport() throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_problem_report(self.pointer, $0) - } - ) - } - - public func getFinalMessage() throws -> String? { - return try FfiConverterOptionString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_Holder_get_final_message(self.pointer, $0) - } - ) - } -} - -public struct FfiConverterTypeHolder: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = Holder - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Holder { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if ptr == nil { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: Holder, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> Holder { - return Holder(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: Holder) -> UnsafeMutableRawPointer { - return value.pointer - } -} - -public protocol ProfileHolderProtocol {} - -public class ProfileHolder: ProfileHolderProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - - deinit { - try! rustCall { ffi_vcx_743a_ProfileHolder_object_free(pointer, $0) } - } -} - -public struct FfiConverterTypeProfileHolder: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ProfileHolder - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProfileHolder { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if ptr == nil { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: ProfileHolder, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ProfileHolder { - return ProfileHolder(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: ProfileHolder) -> UnsafeMutableRawPointer { - return value.pointer - } -} - -public struct AskarWalletConfig { - public var dbUrl: String - public var keyMethod: KeyMethod - public var passKey: String - public var profile: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(dbUrl: String, keyMethod: KeyMethod, passKey: String, profile: String) { - self.dbUrl = dbUrl - self.keyMethod = keyMethod - self.passKey = passKey - self.profile = profile - } -} - -extension AskarWalletConfig: Equatable, Hashable { - public static func == (lhs: AskarWalletConfig, rhs: AskarWalletConfig) -> Bool { - if lhs.dbUrl != rhs.dbUrl { - return false - } - if lhs.keyMethod != rhs.keyMethod { - return false - } - if lhs.passKey != rhs.passKey { - return false - } - if lhs.profile != rhs.profile { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(dbUrl) - hasher.combine(keyMethod) - hasher.combine(passKey) - hasher.combine(profile) - } -} - -public struct FfiConverterTypeAskarWalletConfig: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AskarWalletConfig { - return try AskarWalletConfig( - dbUrl: FfiConverterString.read(from: &buf), - keyMethod: FfiConverterTypeKeyMethod.read(from: &buf), - passKey: FfiConverterString.read(from: &buf), - profile: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: AskarWalletConfig, into buf: inout [UInt8]) { - FfiConverterString.write(value.dbUrl, into: &buf) - FfiConverterTypeKeyMethod.write(value.keyMethod, into: &buf) - FfiConverterString.write(value.passKey, into: &buf) - FfiConverterString.write(value.profile, into: &buf) - } -} - -public func FfiConverterTypeAskarWalletConfig_lift(_ buf: RustBuffer) throws -> AskarWalletConfig { - return try FfiConverterTypeAskarWalletConfig.lift(buf) -} - -public func FfiConverterTypeAskarWalletConfig_lower(_ value: AskarWalletConfig) -> RustBuffer { - return FfiConverterTypeAskarWalletConfig.lower(value) -} - -public struct ConnectionState { - public var role: ConnectionRole - public var protocolState: ConnectionProtocolState - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(role: ConnectionRole, protocolState: ConnectionProtocolState) { - self.role = role - self.protocolState = protocolState - } -} - -extension ConnectionState: Equatable, Hashable { - public static func == (lhs: ConnectionState, rhs: ConnectionState) -> Bool { - if lhs.role != rhs.role { - return false - } - if lhs.protocolState != rhs.protocolState { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(role) - hasher.combine(protocolState) - } -} - -public struct FfiConverterTypeConnectionState: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ConnectionState { - return try ConnectionState( - role: FfiConverterTypeConnectionRole.read(from: &buf), - protocolState: FfiConverterTypeConnectionProtocolState.read(from: &buf) - ) - } - - public static func write(_ value: ConnectionState, into buf: inout [UInt8]) { - FfiConverterTypeConnectionRole.write(value.role, into: &buf) - FfiConverterTypeConnectionProtocolState.write(value.protocolState, into: &buf) - } -} - -public func FfiConverterTypeConnectionState_lift(_ buf: RustBuffer) throws -> ConnectionState { - return try FfiConverterTypeConnectionState.lift(buf) -} - -public func FfiConverterTypeConnectionState_lower(_ value: ConnectionState) -> RustBuffer { - return FfiConverterTypeConnectionState.lower(value) -} - -public struct PairwiseInfo { - public var pwDid: String - public var pwVk: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(pwDid: String, pwVk: String) { - self.pwDid = pwDid - self.pwVk = pwVk - } -} - -extension PairwiseInfo: Equatable, Hashable { - public static func == (lhs: PairwiseInfo, rhs: PairwiseInfo) -> Bool { - if lhs.pwDid != rhs.pwDid { - return false - } - if lhs.pwVk != rhs.pwVk { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(pwDid) - hasher.combine(pwVk) - } -} - -public struct FfiConverterTypePairwiseInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PairwiseInfo { - return try PairwiseInfo( - pwDid: FfiConverterString.read(from: &buf), - pwVk: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: PairwiseInfo, into buf: inout [UInt8]) { - FfiConverterString.write(value.pwDid, into: &buf) - FfiConverterString.write(value.pwVk, into: &buf) - } -} - -public func FfiConverterTypePairwiseInfo_lift(_ buf: RustBuffer) throws -> PairwiseInfo { - return try FfiConverterTypePairwiseInfo.lift(buf) -} - -public func FfiConverterTypePairwiseInfo_lower(_ value: PairwiseInfo) -> RustBuffer { - return FfiConverterTypePairwiseInfo.lower(value) -} - -public struct UnpackMessage { - public var message: String - public var recipientVerkey: String - public var senderVerkey: String? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(message: String, recipientVerkey: String, senderVerkey: String?) { - self.message = message - self.recipientVerkey = recipientVerkey - self.senderVerkey = senderVerkey - } -} - -extension UnpackMessage: Equatable, Hashable { - public static func == (lhs: UnpackMessage, rhs: UnpackMessage) -> Bool { - if lhs.message != rhs.message { - return false - } - if lhs.recipientVerkey != rhs.recipientVerkey { - return false - } - if lhs.senderVerkey != rhs.senderVerkey { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(message) - hasher.combine(recipientVerkey) - hasher.combine(senderVerkey) - } -} - -public struct FfiConverterTypeUnpackMessage: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UnpackMessage { - return try UnpackMessage( - message: FfiConverterString.read(from: &buf), - recipientVerkey: FfiConverterString.read(from: &buf), - senderVerkey: FfiConverterOptionString.read(from: &buf) - ) - } - - public static func write(_ value: UnpackMessage, into buf: inout [UInt8]) { - FfiConverterString.write(value.message, into: &buf) - FfiConverterString.write(value.recipientVerkey, into: &buf) - FfiConverterOptionString.write(value.senderVerkey, into: &buf) - } -} - -public func FfiConverterTypeUnpackMessage_lift(_ buf: RustBuffer) throws -> UnpackMessage { - return try FfiConverterTypeUnpackMessage.lift(buf) -} - -public func FfiConverterTypeUnpackMessage_lower(_ value: UnpackMessage) -> RustBuffer { - return FfiConverterTypeUnpackMessage.lower(value) -} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum ArgonLevel { - case interactive - case moderate -} - -public struct FfiConverterTypeArgonLevel: FfiConverterRustBuffer { - typealias SwiftType = ArgonLevel - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ArgonLevel { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return .interactive - - case 2: return .moderate - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ArgonLevel, into buf: inout [UInt8]) { - switch value { - case .interactive: - writeInt(&buf, Int32(1)) - - case .moderate: - writeInt(&buf, Int32(2)) - } - } -} - -public func FfiConverterTypeArgonLevel_lift(_ buf: RustBuffer) throws -> ArgonLevel { - return try FfiConverterTypeArgonLevel.lift(buf) -} - -public func FfiConverterTypeArgonLevel_lower(_ value: ArgonLevel) -> RustBuffer { - return FfiConverterTypeArgonLevel.lower(value) -} - -extension ArgonLevel: Equatable, Hashable {} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum AskarKdfMethod { - case argon2i(inner: ArgonLevel) -} - -public struct FfiConverterTypeAskarKdfMethod: FfiConverterRustBuffer { - typealias SwiftType = AskarKdfMethod - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AskarKdfMethod { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return try .argon2i( - inner: FfiConverterTypeArgonLevel.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: AskarKdfMethod, into buf: inout [UInt8]) { - switch value { - case let .argon2i(inner): - writeInt(&buf, Int32(1)) - FfiConverterTypeArgonLevel.write(inner, into: &buf) - } - } -} - -public func FfiConverterTypeAskarKdfMethod_lift(_ buf: RustBuffer) throws -> AskarKdfMethod { - return try FfiConverterTypeAskarKdfMethod.lift(buf) -} - -public func FfiConverterTypeAskarKdfMethod_lower(_ value: AskarKdfMethod) -> RustBuffer { - return FfiConverterTypeAskarKdfMethod.lower(value) -} - -extension AskarKdfMethod: Equatable, Hashable {} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum ConnectionProtocolState { - case initial - case invited - case requested - case responded - case completed -} - -public struct FfiConverterTypeConnectionProtocolState: FfiConverterRustBuffer { - typealias SwiftType = ConnectionProtocolState - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ConnectionProtocolState { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return .initial - - case 2: return .invited - - case 3: return .requested - - case 4: return .responded - - case 5: return .completed - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ConnectionProtocolState, into buf: inout [UInt8]) { - switch value { - case .initial: - writeInt(&buf, Int32(1)) - - case .invited: - writeInt(&buf, Int32(2)) - - case .requested: - writeInt(&buf, Int32(3)) - - case .responded: - writeInt(&buf, Int32(4)) - - case .completed: - writeInt(&buf, Int32(5)) - } - } -} - -public func FfiConverterTypeConnectionProtocolState_lift(_ buf: RustBuffer) throws -> ConnectionProtocolState { - return try FfiConverterTypeConnectionProtocolState.lift(buf) -} - -public func FfiConverterTypeConnectionProtocolState_lower(_ value: ConnectionProtocolState) -> RustBuffer { - return FfiConverterTypeConnectionProtocolState.lower(value) -} - -extension ConnectionProtocolState: Equatable, Hashable {} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum ConnectionRole { - case invitee - case inviter -} - -public struct FfiConverterTypeConnectionRole: FfiConverterRustBuffer { - typealias SwiftType = ConnectionRole - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ConnectionRole { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return .invitee - - case 2: return .inviter - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ConnectionRole, into buf: inout [UInt8]) { - switch value { - case .invitee: - writeInt(&buf, Int32(1)) - - case .inviter: - writeInt(&buf, Int32(2)) - } - } -} - -public func FfiConverterTypeConnectionRole_lift(_ buf: RustBuffer) throws -> ConnectionRole { - return try FfiConverterTypeConnectionRole.lift(buf) -} - -public func FfiConverterTypeConnectionRole_lower(_ value: ConnectionRole) -> RustBuffer { - return FfiConverterTypeConnectionRole.lower(value) -} - -extension ConnectionRole: Equatable, Hashable {} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum HolderState { - case initial - case proposalSet - case offerReceived - case requestSet - case finished - case failed -} - -public struct FfiConverterTypeHolderState: FfiConverterRustBuffer { - typealias SwiftType = HolderState - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HolderState { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return .initial - - case 2: return .proposalSet - - case 3: return .offerReceived - - case 4: return .requestSet - - case 5: return .finished - - case 6: return .failed - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: HolderState, into buf: inout [UInt8]) { - switch value { - case .initial: - writeInt(&buf, Int32(1)) - - case .proposalSet: - writeInt(&buf, Int32(2)) - - case .offerReceived: - writeInt(&buf, Int32(3)) - - case .requestSet: - writeInt(&buf, Int32(4)) - - case .finished: - writeInt(&buf, Int32(5)) - - case .failed: - writeInt(&buf, Int32(6)) - } - } -} - -public func FfiConverterTypeHolderState_lift(_ buf: RustBuffer) throws -> HolderState { - return try FfiConverterTypeHolderState.lift(buf) -} - -public func FfiConverterTypeHolderState_lower(_ value: HolderState) -> RustBuffer { - return FfiConverterTypeHolderState.lower(value) -} - -extension HolderState: Equatable, Hashable {} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum KeyMethod { - case deriveKey(inner: AskarKdfMethod) - case rawKey - case unprotected -} - -public struct FfiConverterTypeKeyMethod: FfiConverterRustBuffer { - typealias SwiftType = KeyMethod - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> KeyMethod { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return try .deriveKey( - inner: FfiConverterTypeAskarKdfMethod.read(from: &buf) - ) - - case 2: return .rawKey - - case 3: return .unprotected - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: KeyMethod, into buf: inout [UInt8]) { - switch value { - case let .deriveKey(inner): - writeInt(&buf, Int32(1)) - FfiConverterTypeAskarKdfMethod.write(inner, into: &buf) - - case .rawKey: - writeInt(&buf, Int32(2)) - - case .unprotected: - writeInt(&buf, Int32(3)) - } - } -} - -public func FfiConverterTypeKeyMethod_lift(_ buf: RustBuffer) throws -> KeyMethod { - return try FfiConverterTypeKeyMethod.lift(buf) -} - -public func FfiConverterTypeKeyMethod_lower(_ value: KeyMethod) -> RustBuffer { - return FfiConverterTypeKeyMethod.lower(value) -} - -extension KeyMethod: Equatable, Hashable {} - -public enum VcxUniFfiError { - // Simple error enums only carry a message - case AriesVcxError(message: String) - - // Simple error enums only carry a message - case AriesVcxWalletError(message: String) - - // Simple error enums only carry a message - case AriesVcxLedgerError(message: String) - - // Simple error enums only carry a message - case AriesVcxAnoncredsError(message: String) - - // Simple error enums only carry a message - case SerializationError(message: String) - - // Simple error enums only carry a message - case InternalError(message: String) - - // Simple error enums only carry a message - case StringParseError(message: String) -} - -public struct FfiConverterTypeVcxUniFfiError: FfiConverterRustBuffer { - typealias SwiftType = VcxUniFfiError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> VcxUniFfiError { - let variant: Int32 = try readInt(&buf) - switch variant { - case 1: return try .AriesVcxError( - message: FfiConverterString.read(from: &buf) - ) - - case 2: return try .AriesVcxWalletError( - message: FfiConverterString.read(from: &buf) - ) - - case 3: return try .AriesVcxLedgerError( - message: FfiConverterString.read(from: &buf) - ) - - case 4: return try .AriesVcxAnoncredsError( - message: FfiConverterString.read(from: &buf) - ) - - case 5: return try .SerializationError( - message: FfiConverterString.read(from: &buf) - ) - - case 6: return try .InternalError( - message: FfiConverterString.read(from: &buf) - ) - - case 7: return try .StringParseError( - message: FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: VcxUniFfiError, into buf: inout [UInt8]) { - switch value { - case let .AriesVcxError(message): - writeInt(&buf, Int32(1)) - FfiConverterString.write(message, into: &buf) - case let .AriesVcxWalletError(message): - writeInt(&buf, Int32(2)) - FfiConverterString.write(message, into: &buf) - case let .AriesVcxLedgerError(message): - writeInt(&buf, Int32(3)) - FfiConverterString.write(message, into: &buf) - case let .AriesVcxAnoncredsError(message): - writeInt(&buf, Int32(4)) - FfiConverterString.write(message, into: &buf) - case let .SerializationError(message): - writeInt(&buf, Int32(5)) - FfiConverterString.write(message, into: &buf) - case let .InternalError(message): - writeInt(&buf, Int32(6)) - FfiConverterString.write(message, into: &buf) - case let .StringParseError(message): - writeInt(&buf, Int32(7)) - FfiConverterString.write(message, into: &buf) - } - } -} - -extension VcxUniFfiError: Equatable, Hashable {} - -extension VcxUniFfiError: Error {} - -private 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 - } - } -} - -private struct FfiConverterSequenceString: FfiConverterRustBuffer { - typealias SwiftType = [String] - - public static func write(_ value: [String], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterString.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] { - let len: Int32 = try readInt(&buf) - var seq = [String]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - try seq.append(FfiConverterString.read(from: &buf)) - } - return seq - } -} - -public func newIndyProfile(walletConfig: AskarWalletConfig, genesisFilePath: String) throws -> ProfileHolder { - return try FfiConverterTypeProfileHolder.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_new_indy_profile( - FfiConverterTypeAskarWalletConfig.lower(walletConfig), - FfiConverterString.lower(genesisFilePath), $0 - ) - } - ) -} - -public func createInviter(profile: ProfileHolder) throws -> Connection { - return try FfiConverterTypeConnection.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_create_inviter( - FfiConverterTypeProfileHolder.lower(profile), $0 - ) - } - ) -} - -public func createInvitee(profile: ProfileHolder) throws -> Connection { - return try FfiConverterTypeConnection.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_create_invitee( - FfiConverterTypeProfileHolder.lower(profile), $0 - ) - } - ) -} - -public func unpackMessage(profile: ProfileHolder, packedMsg: String) throws -> UnpackMessage { - return try FfiConverterTypeUnpackMessage.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_unpack_message( - FfiConverterTypeProfileHolder.lower(profile), - FfiConverterString.lower(packedMsg), $0 - ) - } - ) -} - -public func create(sourceId: String) throws -> Holder { - return try FfiConverterTypeHolder.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_create( - FfiConverterString.lower(sourceId), $0 - ) - } - ) -} - -public func createFromOffer(sourceId: String, offerMessage: String) throws -> Holder { - return try FfiConverterTypeHolder.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_create_from_offer( - FfiConverterString.lower(sourceId), - FfiConverterString.lower(offerMessage), $0 - ) - } - ) -} - -public func createWithProposal(sourceId: String, proposeCredential: String) throws -> Holder { - return try FfiConverterTypeHolder.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_create_with_proposal( - FfiConverterString.lower(sourceId), - FfiConverterString.lower(proposeCredential), $0 - ) - } - ) -} - -public func getCredentials(profile: ProfileHolder) throws -> String { - return try FfiConverterString.lift( - rustCallWithError(FfiConverterTypeVcxUniFfiError.self) { - vcx_743a_get_credentials( - FfiConverterTypeProfileHolder.lower(profile), $0 - ) - } - ) -} - -/** - * Top level initializers and tear down methods. - * - * This is generated by uniffi. - */ -public enum VcxLifecycle { - /** - * Initialize the FFI and Rust library. This should be only called once per application. - */ - func initialize() {} -} diff --git a/aries/wrappers/uniffi-aries-vcx/scripts/ios.build.cargo.sh b/aries/wrappers/uniffi-aries-vcx/scripts/ios.build.cargo.sh index 7f864fc1df..58cf11be9f 100755 --- a/aries/wrappers/uniffi-aries-vcx/scripts/ios.build.cargo.sh +++ b/aries/wrappers/uniffi-aries-vcx/scripts/ios.build.cargo.sh @@ -75,7 +75,10 @@ xcodebuild -create-xcframework -library ${ABI_PATH}/libuniffi_vcx.a -headers ${IOS_APP_DIR}/Source -output "${ABI_PATH}/vcx.xcframework" - zip -r ${ABI_PATH}/vcx.xcframework.zip ${ABI_PATH}/vcx.xcframework + #zip -r ${ABI_PATH}/vcx.xcframework.zip ${ABI_PATH}/vcx.xcframework + + cd ${ABI_PATH} + zip -r vcx.xcframework.zip vcx.xcframework # Remove .a file if it is not required and have large size rm -R ${ABI_PATH}/libuniffi_vcx.a @@ -89,26 +92,6 @@ export IOS_APP_DIR="${ARIES_VCX_ROOT}/aries/agents/ios/ariesvcx/ariesvcx" export ABI_PATH=${IOS_APP_DIR}/Frameworks - # Replace these with your actual values - #GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - #REPO=${{ github.repository }} - #TAG=${{ github.ref_name }} - - # Create a release - - # RESPONSE=$(curl -s -X POST \ - # -H "Authorization: token $GITHUB_TOKEN" \ - # -H "Accept: application/vnd.github.v3+json" \ - # -d "{\"tag_name\":\"$TAG\",\"name\":\"Release $TAG\",\"draft\":false,\"prerelease\":false}" \ - # https://api.github.com/repos/$REPO/releases) - - # Extract the release ID - #RELEASE_ID=$(echo $RESPONSE | jq -r .id) - #echo "Release ID: $RELEASE_ID" - #echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV - - # Define the path to your zip file - #XCFRAMEWORK_PATH="${ARIES_VCX_ROOT}/vcxAPI.swift.zip" XCFRAMEWORK_PATH="${ABI_PATH}/vcx.xcframework.zip" # Print for debugging @@ -183,35 +166,6 @@ echo "Release deletion complete." fi - # echo "Found release ID: $RELEASE_ID" - - # # Fetch all assets for the release - # ASSET_URL="https://api.github.com/repos/$REPO/releases/$RELEASE_ID/assets" - # ASSETS_JSON=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$ASSET_URL") - - # # Check if assets are available - # if [ "$(echo "$ASSETS_JSON" | jq -r '.[] | length')" -eq 0 ]; then - # echo "No assets found for release ID: $RELEASE_ID" - # exit 1 - # fi - - # # List all assets - # echo "Assets for release ID $RELEASE_ID:" - # echo "$ASSETS_JSON" | jq -r '.[] | "\(.id): \(.name)"' - - # # Extract asset ID(s) of the asset with the same name - # ASSET_IDS=$(echo "$ASSETS_JSON" | jq -r ".[] | select(.name == \"$ASSET_NAME\") | .id") - - # if [ -z "$ASSET_IDS" ]; then - # echo "No asset found with name: $ASSET_NAME" - # else - # # Delete the existing asset(s) - # for ASSET_ID in $ASSET_IDS; do - # echo "Deleting existing asset with ID: $ASSET_ID" - # curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID" - # done - # fi - echo "Asset delete process complete." } @@ -260,8 +214,63 @@ } - generate_bindings - build_uniffi_for_demo - build_ios_xcframework - delete_existing_xcframework - upload_framework \ No newline at end of file + checksum() { + + +set -e + +# Variables +URL="https://github.com/instnt-inc/instnt-aries-vcx/releases/download/abhishek_GithubAction2/vcx.xcframework.zip" # Replace with your URL +FILE_NAME="vcx.xcframework.zip" # Name of the downloaded file + +# Function to display usage information +usage() { + echo "Usage: $0 -u -f " + exit 1 +} + +# Parse command-line arguments +while getopts "u:f:" opt; do + case ${opt} in + u ) + URL=$OPTARG + ;; + f ) + FILE_NAME=$OPTARG + ;; + * ) + usage + ;; + esac +done +shift $((OPTIND -1)) + +# Check if URL and FILE_NAME are provided +if [ -z "$URL" ] || [ -z "$FILE_NAME" ]; then + usage +fi + +# Download the file +echo "Downloading file from $URL..." +curl -O "$URL" + +# Verify if the file was downloaded successfully +if [ ! -f "$FILE_NAME" ]; then + echo "Error: File $FILE_NAME not found after download." + exit 1 +fi + +# Compute the SHA-256 checksum +CHECKSUM=$(shasum -a 256 "$FILE_NAME" | awk '{ print $1 }') + +# Output the checksum +echo "Checksum for $FILE_NAME: $CHECKSUM" + } + + # generate_bindings + # build_uniffi_for_demo + # build_ios_xcframework + # delete_existing_xcframework + # upload_framework + + checksum \ No newline at end of file