diff --git a/Package.swift b/Package.swift index 07bbbe6..e606530 100644 --- a/Package.swift +++ b/Package.swift @@ -27,8 +27,8 @@ let package = Package( swiftSettings: [.unsafeFlags(["-suppress-warnings"])]), .binaryTarget( name: "BitwardenFFI", - url: "https://bwlivefronttest.blob.core.windows.net/sdk/6d45212-BitwardenFFI.xcframework.zip", - checksum: "6a30607da29c161656301e5aadfd763d34b37ef655af4059c7cef4a7ae072e08"), + url: "https://bwlivefronttest.blob.core.windows.net/sdk/57fa7fa-BitwardenFFI.xcframework.zip", + checksum: "3149f9060ebc66313f91bcd67303ad41272407fa51b56b19fb999e6500ef83ab"), .testTarget( name: "BitwardenSdkTests", dependencies: ["BitwardenSdk"]) diff --git a/Sources/BitwardenSdk/BitwardenCore.swift b/Sources/BitwardenSdk/BitwardenCore.swift index 2a31ccd..7dabd99 100644 --- a/Sources/BitwardenSdk/BitwardenCore.swift +++ b/Sources/BitwardenSdk/BitwardenCore.swift @@ -1,5 +1,7 @@ // 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 @@ -18,6 +20,10 @@ fileprivate extension RustBuffer { 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_bitwarden_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } } @@ -220,9 +226,17 @@ fileprivate enum UniffiInternalError: LocalizedError { } } +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_PANIC: Int8 = 2 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 fileprivate let CALL_CANCELLED: Int8 = 3 fileprivate extension RustCallStatus { @@ -275,7 +289,7 @@ private func uniffiCheckCallStatus( throw UniffiInternalError.unexpectedRustCallError } - case CALL_PANIC: + 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. @@ -294,6 +308,76 @@ private func uniffiCheckCallStatus( } } +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)) + } +} +fileprivate class UniffiHandleMap { + private var map: [UInt64: T] = [:] + private let lock = NSLock() + private var currentHandle: UInt64 = 1 + + func insert(obj: T) -> UInt64 { + lock.withLock { + let handle = currentHandle + currentHandle += 1 + 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 + } + } + + @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. @@ -323,6 +407,19 @@ fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { } } +fileprivate struct FfiConverterInt64: FfiConverterPrimitive { + typealias FfiType = Int64 + typealias SwiftType = Int64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Int64, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + fileprivate struct FfiConverterBool : FfiConverter { typealias FfiType = Int8 typealias SwiftType = Bool @@ -446,16 +543,10 @@ public struct Attachment { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: String?, - url: String?, - size: String?, + public init(id: String?, url: String?, size: String?, /** * Readable size, ex: "4.2 KB" or "1.43 GB" - */ - sizeName: String?, - fileName: EncString?, - key: EncString?) { + */sizeName: String?, fileName: EncString?, key: EncString?) { self.id = id self.url = url self.size = size @@ -466,6 +557,7 @@ public struct Attachment { } + extension Attachment: Equatable, Hashable { public static func ==(lhs: Attachment, rhs: Attachment) -> Bool { if lhs.id != rhs.id { @@ -539,15 +631,14 @@ public struct AttachmentEncryptResult { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - attachment: Attachment, - contents: Data) { + public init(attachment: Attachment, contents: Data) { self.attachment = attachment self.contents = contents } } + extension AttachmentEncryptResult: Equatable, Hashable { public static func ==(lhs: AttachmentEncryptResult, rhs: AttachmentEncryptResult) -> Bool { if lhs.attachment != rhs.attachment { @@ -596,18 +687,12 @@ public struct AttachmentView { public let url: String? public let size: String? public let sizeName: String? - public let fileName: String? + public let fileName: SensitiveString? public let key: EncString? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: String?, - url: String?, - size: String?, - sizeName: String?, - fileName: String?, - key: EncString?) { + public init(id: String?, url: String?, size: String?, sizeName: String?, fileName: SensitiveString?, key: EncString?) { self.id = id self.url = url self.size = size @@ -618,6 +703,7 @@ public struct AttachmentView { } + extension AttachmentView: Equatable, Hashable { public static func ==(lhs: AttachmentView, rhs: AttachmentView) -> Bool { if lhs.id != rhs.id { @@ -660,7 +746,7 @@ public struct FfiConverterTypeAttachmentView: FfiConverterRustBuffer { url: FfiConverterOptionString.read(from: &buf), size: FfiConverterOptionString.read(from: &buf), sizeName: FfiConverterOptionString.read(from: &buf), - fileName: FfiConverterOptionString.read(from: &buf), + fileName: FfiConverterOptionTypeSensitiveString.read(from: &buf), key: FfiConverterOptionTypeEncString.read(from: &buf) ) } @@ -670,7 +756,7 @@ public struct FfiConverterTypeAttachmentView: FfiConverterRustBuffer { FfiConverterOptionString.write(value.url, into: &buf) FfiConverterOptionString.write(value.size, into: &buf) FfiConverterOptionString.write(value.sizeName, into: &buf) - FfiConverterOptionString.write(value.fileName, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.fileName, into: &buf) FfiConverterOptionTypeEncString.write(value.key, into: &buf) } } @@ -690,7 +776,7 @@ public struct AuthRequestResponse { * Base64 encoded private key * This key is temporarily passed back and will most likely not be available in the future */ - public let privateKey: String + public let privateKey: SensitiveString /** * Base64 encoded public key */ @@ -710,20 +796,16 @@ public struct AuthRequestResponse { /** * Base64 encoded private key * This key is temporarily passed back and will most likely not be available in the future - */ - privateKey: String, + */privateKey: SensitiveString, /** * Base64 encoded public key - */ - publicKey: String, + */publicKey: String, /** * Fingerprint of the public key - */ - fingerprint: String, + */fingerprint: String, /** * Access code - */ - accessCode: String) { + */accessCode: String) { self.privateKey = privateKey self.publicKey = publicKey self.fingerprint = fingerprint @@ -732,6 +814,7 @@ public struct AuthRequestResponse { } + extension AuthRequestResponse: Equatable, Hashable { public static func ==(lhs: AuthRequestResponse, rhs: AuthRequestResponse) -> Bool { if lhs.privateKey != rhs.privateKey { @@ -762,7 +845,7 @@ public struct FfiConverterTypeAuthRequestResponse: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AuthRequestResponse { return try AuthRequestResponse( - privateKey: FfiConverterString.read(from: &buf), + privateKey: FfiConverterTypeSensitiveString.read(from: &buf), publicKey: FfiConverterString.read(from: &buf), fingerprint: FfiConverterString.read(from: &buf), accessCode: FfiConverterString.read(from: &buf) @@ -770,7 +853,7 @@ public struct FfiConverterTypeAuthRequestResponse: FfiConverterRustBuffer { } public static func write(_ value: AuthRequestResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.privateKey, into: &buf) + FfiConverterTypeSensitiveString.write(value.privateKey, into: &buf) FfiConverterString.write(value.publicKey, into: &buf) FfiConverterString.write(value.fingerprint, into: &buf) FfiConverterString.write(value.accessCode, into: &buf) @@ -787,6 +870,168 @@ public func FfiConverterTypeAuthRequestResponse_lower(_ value: AuthRequestRespon } +public struct AuthenticatorAssertionResponse { + public let clientDataJson: Data + public let authenticatorData: Data + public let signature: Data + public let userHandle: Data + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(clientDataJson: Data, authenticatorData: Data, signature: Data, userHandle: Data) { + self.clientDataJson = clientDataJson + self.authenticatorData = authenticatorData + self.signature = signature + self.userHandle = userHandle + } +} + + + +extension AuthenticatorAssertionResponse: Equatable, Hashable { + public static func ==(lhs: AuthenticatorAssertionResponse, rhs: AuthenticatorAssertionResponse) -> Bool { + if lhs.clientDataJson != rhs.clientDataJson { + return false + } + if lhs.authenticatorData != rhs.authenticatorData { + return false + } + if lhs.signature != rhs.signature { + return false + } + if lhs.userHandle != rhs.userHandle { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(clientDataJson) + hasher.combine(authenticatorData) + hasher.combine(signature) + hasher.combine(userHandle) + } +} + + +public struct FfiConverterTypeAuthenticatorAssertionResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AuthenticatorAssertionResponse { + return + try AuthenticatorAssertionResponse( + clientDataJson: FfiConverterData.read(from: &buf), + authenticatorData: FfiConverterData.read(from: &buf), + signature: FfiConverterData.read(from: &buf), + userHandle: FfiConverterData.read(from: &buf) + ) + } + + public static func write(_ value: AuthenticatorAssertionResponse, into buf: inout [UInt8]) { + FfiConverterData.write(value.clientDataJson, into: &buf) + FfiConverterData.write(value.authenticatorData, into: &buf) + FfiConverterData.write(value.signature, into: &buf) + FfiConverterData.write(value.userHandle, into: &buf) + } +} + + +public func FfiConverterTypeAuthenticatorAssertionResponse_lift(_ buf: RustBuffer) throws -> AuthenticatorAssertionResponse { + return try FfiConverterTypeAuthenticatorAssertionResponse.lift(buf) +} + +public func FfiConverterTypeAuthenticatorAssertionResponse_lower(_ value: AuthenticatorAssertionResponse) -> RustBuffer { + return FfiConverterTypeAuthenticatorAssertionResponse.lower(value) +} + + +public struct AuthenticatorAttestationResponse { + public let clientDataJson: Data + public let authenticatorData: Data + public let publicKey: Data? + public let publicKeyAlgorithm: Int64 + public let attestationObject: Data + public let transports: [String]? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(clientDataJson: Data, authenticatorData: Data, publicKey: Data?, publicKeyAlgorithm: Int64, attestationObject: Data, transports: [String]?) { + self.clientDataJson = clientDataJson + self.authenticatorData = authenticatorData + self.publicKey = publicKey + self.publicKeyAlgorithm = publicKeyAlgorithm + self.attestationObject = attestationObject + self.transports = transports + } +} + + + +extension AuthenticatorAttestationResponse: Equatable, Hashable { + public static func ==(lhs: AuthenticatorAttestationResponse, rhs: AuthenticatorAttestationResponse) -> Bool { + if lhs.clientDataJson != rhs.clientDataJson { + return false + } + if lhs.authenticatorData != rhs.authenticatorData { + return false + } + if lhs.publicKey != rhs.publicKey { + return false + } + if lhs.publicKeyAlgorithm != rhs.publicKeyAlgorithm { + return false + } + if lhs.attestationObject != rhs.attestationObject { + return false + } + if lhs.transports != rhs.transports { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(clientDataJson) + hasher.combine(authenticatorData) + hasher.combine(publicKey) + hasher.combine(publicKeyAlgorithm) + hasher.combine(attestationObject) + hasher.combine(transports) + } +} + + +public struct FfiConverterTypeAuthenticatorAttestationResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AuthenticatorAttestationResponse { + return + try AuthenticatorAttestationResponse( + clientDataJson: FfiConverterData.read(from: &buf), + authenticatorData: FfiConverterData.read(from: &buf), + publicKey: FfiConverterOptionData.read(from: &buf), + publicKeyAlgorithm: FfiConverterInt64.read(from: &buf), + attestationObject: FfiConverterData.read(from: &buf), + transports: FfiConverterOptionSequenceString.read(from: &buf) + ) + } + + public static func write(_ value: AuthenticatorAttestationResponse, into buf: inout [UInt8]) { + FfiConverterData.write(value.clientDataJson, into: &buf) + FfiConverterData.write(value.authenticatorData, into: &buf) + FfiConverterOptionData.write(value.publicKey, into: &buf) + FfiConverterInt64.write(value.publicKeyAlgorithm, into: &buf) + FfiConverterData.write(value.attestationObject, into: &buf) + FfiConverterOptionSequenceString.write(value.transports, into: &buf) + } +} + + +public func FfiConverterTypeAuthenticatorAttestationResponse_lift(_ buf: RustBuffer) throws -> AuthenticatorAttestationResponse { + return try FfiConverterTypeAuthenticatorAttestationResponse.lift(buf) +} + +public func FfiConverterTypeAuthenticatorAttestationResponse_lower(_ value: AuthenticatorAttestationResponse) -> RustBuffer { + return FfiConverterTypeAuthenticatorAttestationResponse.lower(value) +} + + public struct Card { public let cardholderName: EncString? public let expMonth: EncString? @@ -797,13 +1042,7 @@ public struct Card { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - cardholderName: EncString?, - expMonth: EncString?, - expYear: EncString?, - code: EncString?, - brand: EncString?, - number: EncString?) { + public init(cardholderName: EncString?, expMonth: EncString?, expYear: EncString?, code: EncString?, brand: EncString?, number: EncString?) { self.cardholderName = cardholderName self.expMonth = expMonth self.expYear = expYear @@ -814,6 +1053,7 @@ public struct Card { } + extension Card: Equatable, Hashable { public static func ==(lhs: Card, rhs: Card) -> Bool { if lhs.cardholderName != rhs.cardholderName { @@ -882,22 +1122,16 @@ public func FfiConverterTypeCard_lower(_ value: Card) -> RustBuffer { public struct CardView { - public let cardholderName: String? - public let expMonth: String? - public let expYear: String? - public let code: String? - public let brand: String? - public let number: String? + public let cardholderName: SensitiveString? + public let expMonth: SensitiveString? + public let expYear: SensitiveString? + public let code: SensitiveString? + public let brand: SensitiveString? + public let number: SensitiveString? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - cardholderName: String?, - expMonth: String?, - expYear: String?, - code: String?, - brand: String?, - number: String?) { + public init(cardholderName: SensitiveString?, expMonth: SensitiveString?, expYear: SensitiveString?, code: SensitiveString?, brand: SensitiveString?, number: SensitiveString?) { self.cardholderName = cardholderName self.expMonth = expMonth self.expYear = expYear @@ -908,6 +1142,7 @@ public struct CardView { } + extension CardView: Equatable, Hashable { public static func ==(lhs: CardView, rhs: CardView) -> Bool { if lhs.cardholderName != rhs.cardholderName { @@ -946,22 +1181,22 @@ public struct FfiConverterTypeCardView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CardView { return try CardView( - cardholderName: FfiConverterOptionString.read(from: &buf), - expMonth: FfiConverterOptionString.read(from: &buf), - expYear: FfiConverterOptionString.read(from: &buf), - code: FfiConverterOptionString.read(from: &buf), - brand: FfiConverterOptionString.read(from: &buf), - number: FfiConverterOptionString.read(from: &buf) + cardholderName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + expMonth: FfiConverterOptionTypeSensitiveString.read(from: &buf), + expYear: FfiConverterOptionTypeSensitiveString.read(from: &buf), + code: FfiConverterOptionTypeSensitiveString.read(from: &buf), + brand: FfiConverterOptionTypeSensitiveString.read(from: &buf), + number: FfiConverterOptionTypeSensitiveString.read(from: &buf) ) } public static func write(_ value: CardView, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.cardholderName, into: &buf) - FfiConverterOptionString.write(value.expMonth, into: &buf) - FfiConverterOptionString.write(value.expYear, into: &buf) - FfiConverterOptionString.write(value.code, into: &buf) - FfiConverterOptionString.write(value.brand, into: &buf) - FfiConverterOptionString.write(value.number, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.cardholderName, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.expMonth, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.expYear, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.code, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.brand, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.number, into: &buf) } } @@ -1007,35 +1242,11 @@ public struct Cipher { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - organizationId: Uuid?, - folderId: Uuid?, - collectionIds: [Uuid], + public init(id: Uuid?, organizationId: Uuid?, folderId: Uuid?, collectionIds: [Uuid], /** * More recent ciphers uses individual encryption keys to encrypt the other fields of the * Cipher. - */ - key: EncString?, - name: EncString, - notes: EncString?, - type: CipherType, - login: Login?, - identity: Identity?, - card: Card?, - secureNote: SecureNote?, - favorite: Bool, - reprompt: CipherRepromptType, - organizationUseTotp: Bool, - edit: Bool, - viewPassword: Bool, - localData: LocalData?, - attachments: [Attachment]?, - fields: [Field]?, - passwordHistory: [PasswordHistory]?, - creationDate: DateTime, - deletedDate: DateTime?, - revisionDate: DateTime) { + */key: EncString?, name: EncString, notes: EncString?, type: CipherType, login: Login?, identity: Identity?, card: Card?, secureNote: SecureNote?, favorite: Bool, reprompt: CipherRepromptType, organizationUseTotp: Bool, edit: Bool, viewPassword: Bool, localData: LocalData?, attachments: [Attachment]?, fields: [Field]?, passwordHistory: [PasswordHistory]?, creationDate: DateTime, deletedDate: DateTime?, revisionDate: DateTime) { self.id = id self.organizationId = organizationId self.folderId = folderId @@ -1064,6 +1275,7 @@ public struct Cipher { } + extension Cipher: Equatable, Hashable { public static func ==(lhs: Cipher, rhs: Cipher) -> Bool { if lhs.id != rhs.id { @@ -1244,8 +1456,8 @@ public struct CipherListView { public let organizationId: Uuid? public let folderId: Uuid? public let collectionIds: [Uuid] - public let name: String - public let subTitle: String + public let name: SensitiveString + public let subTitle: SensitiveString public let type: CipherType public let favorite: Bool public let reprompt: CipherRepromptType @@ -1261,25 +1473,10 @@ public struct CipherListView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - organizationId: Uuid?, - folderId: Uuid?, - collectionIds: [Uuid], - name: String, - subTitle: String, - type: CipherType, - favorite: Bool, - reprompt: CipherRepromptType, - edit: Bool, - viewPassword: Bool, + public init(id: Uuid?, organizationId: Uuid?, folderId: Uuid?, collectionIds: [Uuid], name: SensitiveString, subTitle: SensitiveString, type: CipherType, favorite: Bool, reprompt: CipherRepromptType, edit: Bool, viewPassword: Bool, /** * The number of attachments - */ - attachments: UInt32, - creationDate: DateTime, - deletedDate: DateTime?, - revisionDate: DateTime) { + */attachments: UInt32, creationDate: DateTime, deletedDate: DateTime?, revisionDate: DateTime) { self.id = id self.organizationId = organizationId self.folderId = folderId @@ -1299,6 +1496,7 @@ public struct CipherListView { } + extension CipherListView: Equatable, Hashable { public static func ==(lhs: CipherListView, rhs: CipherListView) -> Bool { if lhs.id != rhs.id { @@ -1377,8 +1575,8 @@ public struct FfiConverterTypeCipherListView: FfiConverterRustBuffer { organizationId: FfiConverterOptionTypeUuid.read(from: &buf), folderId: FfiConverterOptionTypeUuid.read(from: &buf), collectionIds: FfiConverterSequenceTypeUuid.read(from: &buf), - name: FfiConverterString.read(from: &buf), - subTitle: FfiConverterString.read(from: &buf), + name: FfiConverterTypeSensitiveString.read(from: &buf), + subTitle: FfiConverterTypeSensitiveString.read(from: &buf), type: FfiConverterTypeCipherType.read(from: &buf), favorite: FfiConverterBool.read(from: &buf), reprompt: FfiConverterTypeCipherRepromptType.read(from: &buf), @@ -1396,8 +1594,8 @@ public struct FfiConverterTypeCipherListView: FfiConverterRustBuffer { FfiConverterOptionTypeUuid.write(value.organizationId, into: &buf) FfiConverterOptionTypeUuid.write(value.folderId, into: &buf) FfiConverterSequenceTypeUuid.write(value.collectionIds, into: &buf) - FfiConverterString.write(value.name, into: &buf) - FfiConverterString.write(value.subTitle, into: &buf) + FfiConverterTypeSensitiveString.write(value.name, into: &buf) + FfiConverterTypeSensitiveString.write(value.subTitle, into: &buf) FfiConverterTypeCipherType.write(value.type, into: &buf) FfiConverterBool.write(value.favorite, into: &buf) FfiConverterTypeCipherRepromptType.write(value.reprompt, into: &buf) @@ -1426,8 +1624,8 @@ public struct CipherView { public let folderId: Uuid? public let collectionIds: [Uuid] public let key: EncString? - public let name: String - public let notes: String? + public let name: SensitiveString + public let notes: SensitiveString? public let type: CipherType public let login: LoginView? public let identity: IdentityView? @@ -1448,31 +1646,7 @@ public struct CipherView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - organizationId: Uuid?, - folderId: Uuid?, - collectionIds: [Uuid], - key: EncString?, - name: String, - notes: String?, - type: CipherType, - login: LoginView?, - identity: IdentityView?, - card: CardView?, - secureNote: SecureNoteView?, - favorite: Bool, - reprompt: CipherRepromptType, - organizationUseTotp: Bool, - edit: Bool, - viewPassword: Bool, - localData: LocalDataView?, - attachments: [AttachmentView]?, - fields: [FieldView]?, - passwordHistory: [PasswordHistoryView]?, - creationDate: DateTime, - deletedDate: DateTime?, - revisionDate: DateTime) { + public init(id: Uuid?, organizationId: Uuid?, folderId: Uuid?, collectionIds: [Uuid], key: EncString?, name: SensitiveString, notes: SensitiveString?, type: CipherType, login: LoginView?, identity: IdentityView?, card: CardView?, secureNote: SecureNoteView?, favorite: Bool, reprompt: CipherRepromptType, organizationUseTotp: Bool, edit: Bool, viewPassword: Bool, localData: LocalDataView?, attachments: [AttachmentView]?, fields: [FieldView]?, passwordHistory: [PasswordHistoryView]?, creationDate: DateTime, deletedDate: DateTime?, revisionDate: DateTime) { self.id = id self.organizationId = organizationId self.folderId = folderId @@ -1501,6 +1675,7 @@ public struct CipherView { } + extension CipherView: Equatable, Hashable { public static func ==(lhs: CipherView, rhs: CipherView) -> Bool { if lhs.id != rhs.id { @@ -1616,8 +1791,8 @@ public struct FfiConverterTypeCipherView: FfiConverterRustBuffer { folderId: FfiConverterOptionTypeUuid.read(from: &buf), collectionIds: FfiConverterSequenceTypeUuid.read(from: &buf), key: FfiConverterOptionTypeEncString.read(from: &buf), - name: FfiConverterString.read(from: &buf), - notes: FfiConverterOptionString.read(from: &buf), + name: FfiConverterTypeSensitiveString.read(from: &buf), + notes: FfiConverterOptionTypeSensitiveString.read(from: &buf), type: FfiConverterTypeCipherType.read(from: &buf), login: FfiConverterOptionTypeLoginView.read(from: &buf), identity: FfiConverterOptionTypeIdentityView.read(from: &buf), @@ -1644,8 +1819,8 @@ public struct FfiConverterTypeCipherView: FfiConverterRustBuffer { FfiConverterOptionTypeUuid.write(value.folderId, into: &buf) FfiConverterSequenceTypeUuid.write(value.collectionIds, into: &buf) FfiConverterOptionTypeEncString.write(value.key, into: &buf) - FfiConverterString.write(value.name, into: &buf) - FfiConverterOptionString.write(value.notes, into: &buf) + FfiConverterTypeSensitiveString.write(value.name, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.notes, into: &buf) FfiConverterTypeCipherType.write(value.type, into: &buf) FfiConverterOptionTypeLoginView.write(value.login, into: &buf) FfiConverterOptionTypeIdentityView.write(value.identity, into: &buf) @@ -1716,20 +1891,16 @@ public struct ClientSettings { public init( /** * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com` - */ - identityUrl: String, + */identityUrl: String, /** * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com` - */ - apiUrl: String, + */apiUrl: String, /** * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK` - */ - userAgent: String, + */userAgent: String, /** * Device type to send to Bitwarden. Defaults to SDK - */ - deviceType: DeviceType) { + */deviceType: DeviceType) { self.identityUrl = identityUrl self.apiUrl = apiUrl self.userAgent = userAgent @@ -1738,6 +1909,7 @@ public struct ClientSettings { } + extension ClientSettings: Equatable, Hashable { public static func ==(lhs: ClientSettings, rhs: ClientSettings) -> Bool { if lhs.identityUrl != rhs.identityUrl { @@ -1803,13 +1975,7 @@ public struct Collection { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - organizationId: Uuid, - name: EncString, - externalId: String?, - hidePasswords: Bool, - readOnly: Bool) { + public init(id: Uuid?, organizationId: Uuid, name: EncString, externalId: String?, hidePasswords: Bool, readOnly: Bool) { self.id = id self.organizationId = organizationId self.name = name @@ -1820,6 +1986,7 @@ public struct Collection { } + extension Collection: Equatable, Hashable { public static func ==(lhs: Collection, rhs: Collection) -> Bool { if lhs.id != rhs.id { @@ -1890,20 +2057,14 @@ public func FfiConverterTypeCollection_lower(_ value: Collection) -> RustBuffer public struct CollectionView { public let id: Uuid? public let organizationId: Uuid - public let name: String + public let name: SensitiveString public let externalId: String? public let hidePasswords: Bool public let readOnly: Bool // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - organizationId: Uuid, - name: String, - externalId: String?, - hidePasswords: Bool, - readOnly: Bool) { + public init(id: Uuid?, organizationId: Uuid, name: SensitiveString, externalId: String?, hidePasswords: Bool, readOnly: Bool) { self.id = id self.organizationId = organizationId self.name = name @@ -1914,6 +2075,7 @@ public struct CollectionView { } + extension CollectionView: Equatable, Hashable { public static func ==(lhs: CollectionView, rhs: CollectionView) -> Bool { if lhs.id != rhs.id { @@ -1954,7 +2116,7 @@ public struct FfiConverterTypeCollectionView: FfiConverterRustBuffer { try CollectionView( id: FfiConverterOptionTypeUuid.read(from: &buf), organizationId: FfiConverterTypeUuid.read(from: &buf), - name: FfiConverterString.read(from: &buf), + name: FfiConverterTypeSensitiveString.read(from: &buf), externalId: FfiConverterOptionString.read(from: &buf), hidePasswords: FfiConverterBool.read(from: &buf), readOnly: FfiConverterBool.read(from: &buf) @@ -1964,7 +2126,7 @@ public struct FfiConverterTypeCollectionView: FfiConverterRustBuffer { public static func write(_ value: CollectionView, into buf: inout [UInt8]) { FfiConverterOptionTypeUuid.write(value.id, into: &buf) FfiConverterTypeUuid.write(value.organizationId, into: &buf) - FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeSensitiveString.write(value.name, into: &buf) FfiConverterOptionString.write(value.externalId, into: &buf) FfiConverterBool.write(value.hidePasswords, into: &buf) FfiConverterBool.write(value.readOnly, into: &buf) @@ -1983,11 +2145,11 @@ public func FfiConverterTypeCollectionView_lower(_ value: CollectionView) -> Rus public struct DerivePinKeyResponse { /** - * [UserKey] protected by PIN + * [UserKey](bitwarden_crypto::UserKey) protected by PIN */ public let pinProtectedUserKey: EncString /** - * PIN protected by [UserKey] + * PIN protected by [UserKey](bitwarden_crypto::UserKey) */ public let encryptedPin: EncString @@ -1995,19 +2157,18 @@ public struct DerivePinKeyResponse { // declare one manually. public init( /** - * [UserKey] protected by PIN - */ - pinProtectedUserKey: EncString, + * [UserKey](bitwarden_crypto::UserKey) protected by PIN + */pinProtectedUserKey: EncString, /** - * PIN protected by [UserKey] - */ - encryptedPin: EncString) { + * PIN protected by [UserKey](bitwarden_crypto::UserKey) + */encryptedPin: EncString) { self.pinProtectedUserKey = pinProtectedUserKey self.encryptedPin = encryptedPin } } + extension DerivePinKeyResponse: Equatable, Hashable { public static func ==(lhs: DerivePinKeyResponse, rhs: DerivePinKeyResponse) -> Bool { if lhs.pinProtectedUserKey != rhs.pinProtectedUserKey { @@ -2068,20 +2229,7 @@ public struct Fido2Credential { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - credentialId: EncString, - keyType: EncString, - keyAlgorithm: EncString, - keyCurve: EncString, - keyValue: EncString, - rpId: EncString, - userHandle: EncString?, - userName: EncString?, - counter: EncString, - rpName: EncString?, - userDisplayName: EncString?, - discoverable: EncString, - creationDate: DateTime) { + public init(credentialId: EncString, keyType: EncString, keyAlgorithm: EncString, keyCurve: EncString, keyValue: EncString, rpId: EncString, userHandle: EncString?, userName: EncString?, counter: EncString, rpName: EncString?, userDisplayName: EncString?, discoverable: EncString, creationDate: DateTime) { self.credentialId = credentialId self.keyType = keyType self.keyAlgorithm = keyAlgorithm @@ -2099,6 +2247,7 @@ public struct Fido2Credential { } + extension Fido2Credential: Equatable, Hashable { public static func ==(lhs: Fido2Credential, rhs: Fido2Credential) -> Bool { if lhs.credentialId != rhs.credentialId { @@ -2208,6 +2357,151 @@ public func FfiConverterTypeFido2Credential_lower(_ value: Fido2Credential) -> R } +public struct Fido2CredentialView { + public let credentialId: SensitiveString + public let keyType: SensitiveString + public let keyAlgorithm: SensitiveString + public let keyCurve: SensitiveString + public let keyValue: SensitiveString + public let rpId: SensitiveString + public let userHandle: SensitiveString? + public let userName: SensitiveString? + public let counter: SensitiveString + public let rpName: SensitiveString? + public let userDisplayName: SensitiveString? + public let discoverable: SensitiveString + public let creationDate: DateTime + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(credentialId: SensitiveString, keyType: SensitiveString, keyAlgorithm: SensitiveString, keyCurve: SensitiveString, keyValue: SensitiveString, rpId: SensitiveString, userHandle: SensitiveString?, userName: SensitiveString?, counter: SensitiveString, rpName: SensitiveString?, userDisplayName: SensitiveString?, discoverable: SensitiveString, creationDate: DateTime) { + self.credentialId = credentialId + self.keyType = keyType + self.keyAlgorithm = keyAlgorithm + self.keyCurve = keyCurve + self.keyValue = keyValue + self.rpId = rpId + self.userHandle = userHandle + self.userName = userName + self.counter = counter + self.rpName = rpName + self.userDisplayName = userDisplayName + self.discoverable = discoverable + self.creationDate = creationDate + } +} + + + +extension Fido2CredentialView: Equatable, Hashable { + public static func ==(lhs: Fido2CredentialView, rhs: Fido2CredentialView) -> Bool { + if lhs.credentialId != rhs.credentialId { + return false + } + if lhs.keyType != rhs.keyType { + return false + } + if lhs.keyAlgorithm != rhs.keyAlgorithm { + return false + } + if lhs.keyCurve != rhs.keyCurve { + return false + } + if lhs.keyValue != rhs.keyValue { + return false + } + if lhs.rpId != rhs.rpId { + return false + } + if lhs.userHandle != rhs.userHandle { + return false + } + if lhs.userName != rhs.userName { + return false + } + if lhs.counter != rhs.counter { + return false + } + if lhs.rpName != rhs.rpName { + return false + } + if lhs.userDisplayName != rhs.userDisplayName { + return false + } + if lhs.discoverable != rhs.discoverable { + return false + } + if lhs.creationDate != rhs.creationDate { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(credentialId) + hasher.combine(keyType) + hasher.combine(keyAlgorithm) + hasher.combine(keyCurve) + hasher.combine(keyValue) + hasher.combine(rpId) + hasher.combine(userHandle) + hasher.combine(userName) + hasher.combine(counter) + hasher.combine(rpName) + hasher.combine(userDisplayName) + hasher.combine(discoverable) + hasher.combine(creationDate) + } +} + + +public struct FfiConverterTypeFido2CredentialView: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Fido2CredentialView { + return + try Fido2CredentialView( + credentialId: FfiConverterTypeSensitiveString.read(from: &buf), + keyType: FfiConverterTypeSensitiveString.read(from: &buf), + keyAlgorithm: FfiConverterTypeSensitiveString.read(from: &buf), + keyCurve: FfiConverterTypeSensitiveString.read(from: &buf), + keyValue: FfiConverterTypeSensitiveString.read(from: &buf), + rpId: FfiConverterTypeSensitiveString.read(from: &buf), + userHandle: FfiConverterOptionTypeSensitiveString.read(from: &buf), + userName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + counter: FfiConverterTypeSensitiveString.read(from: &buf), + rpName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + userDisplayName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + discoverable: FfiConverterTypeSensitiveString.read(from: &buf), + creationDate: FfiConverterTypeDateTime.read(from: &buf) + ) + } + + public static func write(_ value: Fido2CredentialView, into buf: inout [UInt8]) { + FfiConverterTypeSensitiveString.write(value.credentialId, into: &buf) + FfiConverterTypeSensitiveString.write(value.keyType, into: &buf) + FfiConverterTypeSensitiveString.write(value.keyAlgorithm, into: &buf) + FfiConverterTypeSensitiveString.write(value.keyCurve, into: &buf) + FfiConverterTypeSensitiveString.write(value.keyValue, into: &buf) + FfiConverterTypeSensitiveString.write(value.rpId, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.userHandle, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.userName, into: &buf) + FfiConverterTypeSensitiveString.write(value.counter, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.rpName, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.userDisplayName, into: &buf) + FfiConverterTypeSensitiveString.write(value.discoverable, into: &buf) + FfiConverterTypeDateTime.write(value.creationDate, into: &buf) + } +} + + +public func FfiConverterTypeFido2CredentialView_lift(_ buf: RustBuffer) throws -> Fido2CredentialView { + return try FfiConverterTypeFido2CredentialView.lift(buf) +} + +public func FfiConverterTypeFido2CredentialView_lower(_ value: Fido2CredentialView) -> RustBuffer { + return FfiConverterTypeFido2CredentialView.lower(value) +} + + public struct Field { public let name: EncString? public let value: EncString? @@ -2216,11 +2510,7 @@ public struct Field { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - name: EncString?, - value: EncString?, - type: FieldType, - linkedId: LinkedIdType?) { + public init(name: EncString?, value: EncString?, type: FieldType, linkedId: LinkedIdType?) { self.name = name self.value = value self.type = type @@ -2229,6 +2519,7 @@ public struct Field { } + extension Field: Equatable, Hashable { public static func ==(lhs: Field, rhs: Field) -> Bool { if lhs.name != rhs.name { @@ -2285,18 +2576,14 @@ public func FfiConverterTypeField_lower(_ value: Field) -> RustBuffer { public struct FieldView { - public let name: String? - public let value: String? + public let name: SensitiveString? + public let value: SensitiveString? public let type: FieldType public let linkedId: LinkedIdType? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - name: String?, - value: String?, - type: FieldType, - linkedId: LinkedIdType?) { + public init(name: SensitiveString?, value: SensitiveString?, type: FieldType, linkedId: LinkedIdType?) { self.name = name self.value = value self.type = type @@ -2305,6 +2592,7 @@ public struct FieldView { } + extension FieldView: Equatable, Hashable { public static func ==(lhs: FieldView, rhs: FieldView) -> Bool { if lhs.name != rhs.name { @@ -2335,16 +2623,16 @@ public struct FfiConverterTypeFieldView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FieldView { return try FieldView( - name: FfiConverterOptionString.read(from: &buf), - value: FfiConverterOptionString.read(from: &buf), + name: FfiConverterOptionTypeSensitiveString.read(from: &buf), + value: FfiConverterOptionTypeSensitiveString.read(from: &buf), type: FfiConverterTypeFieldType.read(from: &buf), linkedId: FfiConverterOptionTypeLinkedIdType.read(from: &buf) ) } public static func write(_ value: FieldView, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.name, into: &buf) - FfiConverterOptionString.write(value.value, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.name, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.value, into: &buf) FfiConverterTypeFieldType.write(value.type, into: &buf) FfiConverterOptionTypeLinkedIdType.write(value.linkedId, into: &buf) } @@ -2375,18 +2663,17 @@ public struct FingerprintRequest { public init( /** * The input material, used in the fingerprint generation process. - */ - fingerprintMaterial: String, + */fingerprintMaterial: String, /** * The user's public key encoded with base64. - */ - publicKey: String) { + */publicKey: String) { self.fingerprintMaterial = fingerprintMaterial self.publicKey = publicKey } } + extension FingerprintRequest: Equatable, Hashable { public static func ==(lhs: FingerprintRequest, rhs: FingerprintRequest) -> Bool { if lhs.fingerprintMaterial != rhs.fingerprintMaterial { @@ -2437,10 +2724,7 @@ public struct Folder { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - name: EncString, - revisionDate: DateTime) { + public init(id: Uuid?, name: EncString, revisionDate: DateTime) { self.id = id self.name = name self.revisionDate = revisionDate @@ -2448,6 +2732,7 @@ public struct Folder { } + extension Folder: Equatable, Hashable { public static func ==(lhs: Folder, rhs: Folder) -> Bool { if lhs.id != rhs.id { @@ -2499,15 +2784,12 @@ public func FfiConverterTypeFolder_lower(_ value: Folder) -> RustBuffer { public struct FolderView { public let id: Uuid? - public let name: String + public let name: SensitiveString public let revisionDate: DateTime // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - name: String, - revisionDate: DateTime) { + public init(id: Uuid?, name: SensitiveString, revisionDate: DateTime) { self.id = id self.name = name self.revisionDate = revisionDate @@ -2515,6 +2797,7 @@ public struct FolderView { } + extension FolderView: Equatable, Hashable { public static func ==(lhs: FolderView, rhs: FolderView) -> Bool { if lhs.id != rhs.id { @@ -2542,14 +2825,14 @@ public struct FfiConverterTypeFolderView: FfiConverterRustBuffer { return try FolderView( id: FfiConverterOptionTypeUuid.read(from: &buf), - name: FfiConverterString.read(from: &buf), + name: FfiConverterTypeSensitiveString.read(from: &buf), revisionDate: FfiConverterTypeDateTime.read(from: &buf) ) } public static func write(_ value: FolderView, into buf: inout [UInt8]) { FfiConverterOptionTypeUuid.write(value.id, into: &buf) - FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeSensitiveString.write(value.name, into: &buf) FfiConverterTypeDateTime.write(value.revisionDate, into: &buf) } } @@ -2564,6 +2847,176 @@ public func FfiConverterTypeFolderView_lower(_ value: FolderView) -> RustBuffer } +public struct GetAssertionRequest { + public let rpId: String + public let clientDataHash: Data + public let allowList: [PublicKeyCredentialDescriptor]? + public let options: Options + public let extensions: [String: String]? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(rpId: String, clientDataHash: Data, allowList: [PublicKeyCredentialDescriptor]?, options: Options, extensions: [String: String]?) { + self.rpId = rpId + self.clientDataHash = clientDataHash + self.allowList = allowList + self.options = options + self.extensions = extensions + } +} + + + +extension GetAssertionRequest: Equatable, Hashable { + public static func ==(lhs: GetAssertionRequest, rhs: GetAssertionRequest) -> Bool { + if lhs.rpId != rhs.rpId { + return false + } + if lhs.clientDataHash != rhs.clientDataHash { + return false + } + if lhs.allowList != rhs.allowList { + return false + } + if lhs.options != rhs.options { + return false + } + if lhs.extensions != rhs.extensions { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(rpId) + hasher.combine(clientDataHash) + hasher.combine(allowList) + hasher.combine(options) + hasher.combine(extensions) + } +} + + +public struct FfiConverterTypeGetAssertionRequest: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GetAssertionRequest { + return + try GetAssertionRequest( + rpId: FfiConverterString.read(from: &buf), + clientDataHash: FfiConverterData.read(from: &buf), + allowList: FfiConverterOptionSequenceTypePublicKeyCredentialDescriptor.read(from: &buf), + options: FfiConverterTypeOptions.read(from: &buf), + extensions: FfiConverterOptionDictionaryStringString.read(from: &buf) + ) + } + + public static func write(_ value: GetAssertionRequest, into buf: inout [UInt8]) { + FfiConverterString.write(value.rpId, into: &buf) + FfiConverterData.write(value.clientDataHash, into: &buf) + FfiConverterOptionSequenceTypePublicKeyCredentialDescriptor.write(value.allowList, into: &buf) + FfiConverterTypeOptions.write(value.options, into: &buf) + FfiConverterOptionDictionaryStringString.write(value.extensions, into: &buf) + } +} + + +public func FfiConverterTypeGetAssertionRequest_lift(_ buf: RustBuffer) throws -> GetAssertionRequest { + return try FfiConverterTypeGetAssertionRequest.lift(buf) +} + +public func FfiConverterTypeGetAssertionRequest_lower(_ value: GetAssertionRequest) -> RustBuffer { + return FfiConverterTypeGetAssertionRequest.lower(value) +} + + +public struct GetAssertionResult { + public let credentialId: Data + public let authenticatorData: Data + public let signature: Data + public let userHandle: Data + /** + * * SDK IMPL NOTE: This is not part of the spec and is not returned by passkey-rs. + * * The SDK needs to add this after the response from passkey-rs is received. + */ + public let selectedCredential: SelectedCredential + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(credentialId: Data, authenticatorData: Data, signature: Data, userHandle: Data, + /** + * * SDK IMPL NOTE: This is not part of the spec and is not returned by passkey-rs. + * * The SDK needs to add this after the response from passkey-rs is received. + */selectedCredential: SelectedCredential) { + self.credentialId = credentialId + self.authenticatorData = authenticatorData + self.signature = signature + self.userHandle = userHandle + self.selectedCredential = selectedCredential + } +} + + + +extension GetAssertionResult: Equatable, Hashable { + public static func ==(lhs: GetAssertionResult, rhs: GetAssertionResult) -> Bool { + if lhs.credentialId != rhs.credentialId { + return false + } + if lhs.authenticatorData != rhs.authenticatorData { + return false + } + if lhs.signature != rhs.signature { + return false + } + if lhs.userHandle != rhs.userHandle { + return false + } + if lhs.selectedCredential != rhs.selectedCredential { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(credentialId) + hasher.combine(authenticatorData) + hasher.combine(signature) + hasher.combine(userHandle) + hasher.combine(selectedCredential) + } +} + + +public struct FfiConverterTypeGetAssertionResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GetAssertionResult { + return + try GetAssertionResult( + credentialId: FfiConverterData.read(from: &buf), + authenticatorData: FfiConverterData.read(from: &buf), + signature: FfiConverterData.read(from: &buf), + userHandle: FfiConverterData.read(from: &buf), + selectedCredential: FfiConverterTypeSelectedCredential.read(from: &buf) + ) + } + + public static func write(_ value: GetAssertionResult, into buf: inout [UInt8]) { + FfiConverterData.write(value.credentialId, into: &buf) + FfiConverterData.write(value.authenticatorData, into: &buf) + FfiConverterData.write(value.signature, into: &buf) + FfiConverterData.write(value.userHandle, into: &buf) + FfiConverterTypeSelectedCredential.write(value.selectedCredential, into: &buf) + } +} + + +public func FfiConverterTypeGetAssertionResult_lift(_ buf: RustBuffer) throws -> GetAssertionResult { + return try FfiConverterTypeGetAssertionResult.lift(buf) +} + +public func FfiConverterTypeGetAssertionResult_lower(_ value: GetAssertionResult) -> RustBuffer { + return FfiConverterTypeGetAssertionResult.lower(value) +} + + public struct Identity { public let title: EncString? public let firstName: EncString? @@ -2586,25 +3039,7 @@ public struct Identity { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - title: EncString?, - firstName: EncString?, - middleName: EncString?, - lastName: EncString?, - address1: EncString?, - address2: EncString?, - address3: EncString?, - city: EncString?, - state: EncString?, - postalCode: EncString?, - country: EncString?, - company: EncString?, - email: EncString?, - phone: EncString?, - ssn: EncString?, - username: EncString?, - passportNumber: EncString?, - licenseNumber: EncString?) { + public init(title: EncString?, firstName: EncString?, middleName: EncString?, lastName: EncString?, address1: EncString?, address2: EncString?, address3: EncString?, city: EncString?, state: EncString?, postalCode: EncString?, country: EncString?, company: EncString?, email: EncString?, phone: EncString?, ssn: EncString?, username: EncString?, passportNumber: EncString?, licenseNumber: EncString?) { self.title = title self.firstName = firstName self.middleName = middleName @@ -2627,6 +3062,7 @@ public struct Identity { } + extension Identity: Equatable, Hashable { public static func ==(lhs: Identity, rhs: Identity) -> Bool { if lhs.title != rhs.title { @@ -2767,46 +3203,28 @@ public func FfiConverterTypeIdentity_lower(_ value: Identity) -> RustBuffer { public struct IdentityView { - public let title: String? - public let firstName: String? - public let middleName: String? - public let lastName: String? - public let address1: String? - public let address2: String? - public let address3: String? - public let city: String? - public let state: String? - public let postalCode: String? - public let country: String? - public let company: String? - public let email: String? - public let phone: String? - public let ssn: String? - public let username: String? - public let passportNumber: String? - public let licenseNumber: String? + public let title: SensitiveString? + public let firstName: SensitiveString? + public let middleName: SensitiveString? + public let lastName: SensitiveString? + public let address1: SensitiveString? + public let address2: SensitiveString? + public let address3: SensitiveString? + public let city: SensitiveString? + public let state: SensitiveString? + public let postalCode: SensitiveString? + public let country: SensitiveString? + public let company: SensitiveString? + public let email: SensitiveString? + public let phone: SensitiveString? + public let ssn: SensitiveString? + public let username: SensitiveString? + public let passportNumber: SensitiveString? + public let licenseNumber: SensitiveString? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - title: String?, - firstName: String?, - middleName: String?, - lastName: String?, - address1: String?, - address2: String?, - address3: String?, - city: String?, - state: String?, - postalCode: String?, - country: String?, - company: String?, - email: String?, - phone: String?, - ssn: String?, - username: String?, - passportNumber: String?, - licenseNumber: String?) { + public init(title: SensitiveString?, firstName: SensitiveString?, middleName: SensitiveString?, lastName: SensitiveString?, address1: SensitiveString?, address2: SensitiveString?, address3: SensitiveString?, city: SensitiveString?, state: SensitiveString?, postalCode: SensitiveString?, country: SensitiveString?, company: SensitiveString?, email: SensitiveString?, phone: SensitiveString?, ssn: SensitiveString?, username: SensitiveString?, passportNumber: SensitiveString?, licenseNumber: SensitiveString?) { self.title = title self.firstName = firstName self.middleName = middleName @@ -2829,6 +3247,7 @@ public struct IdentityView { } + extension IdentityView: Equatable, Hashable { public static func ==(lhs: IdentityView, rhs: IdentityView) -> Bool { if lhs.title != rhs.title { @@ -2915,46 +3334,46 @@ public struct FfiConverterTypeIdentityView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IdentityView { return try IdentityView( - title: FfiConverterOptionString.read(from: &buf), - firstName: FfiConverterOptionString.read(from: &buf), - middleName: FfiConverterOptionString.read(from: &buf), - lastName: FfiConverterOptionString.read(from: &buf), - address1: FfiConverterOptionString.read(from: &buf), - address2: FfiConverterOptionString.read(from: &buf), - address3: FfiConverterOptionString.read(from: &buf), - city: FfiConverterOptionString.read(from: &buf), - state: FfiConverterOptionString.read(from: &buf), - postalCode: FfiConverterOptionString.read(from: &buf), - country: FfiConverterOptionString.read(from: &buf), - company: FfiConverterOptionString.read(from: &buf), - email: FfiConverterOptionString.read(from: &buf), - phone: FfiConverterOptionString.read(from: &buf), - ssn: FfiConverterOptionString.read(from: &buf), - username: FfiConverterOptionString.read(from: &buf), - passportNumber: FfiConverterOptionString.read(from: &buf), - licenseNumber: FfiConverterOptionString.read(from: &buf) + title: FfiConverterOptionTypeSensitiveString.read(from: &buf), + firstName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + middleName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + lastName: FfiConverterOptionTypeSensitiveString.read(from: &buf), + address1: FfiConverterOptionTypeSensitiveString.read(from: &buf), + address2: FfiConverterOptionTypeSensitiveString.read(from: &buf), + address3: FfiConverterOptionTypeSensitiveString.read(from: &buf), + city: FfiConverterOptionTypeSensitiveString.read(from: &buf), + state: FfiConverterOptionTypeSensitiveString.read(from: &buf), + postalCode: FfiConverterOptionTypeSensitiveString.read(from: &buf), + country: FfiConverterOptionTypeSensitiveString.read(from: &buf), + company: FfiConverterOptionTypeSensitiveString.read(from: &buf), + email: FfiConverterOptionTypeSensitiveString.read(from: &buf), + phone: FfiConverterOptionTypeSensitiveString.read(from: &buf), + ssn: FfiConverterOptionTypeSensitiveString.read(from: &buf), + username: FfiConverterOptionTypeSensitiveString.read(from: &buf), + passportNumber: FfiConverterOptionTypeSensitiveString.read(from: &buf), + licenseNumber: FfiConverterOptionTypeSensitiveString.read(from: &buf) ) } public static func write(_ value: IdentityView, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.title, into: &buf) - FfiConverterOptionString.write(value.firstName, into: &buf) - FfiConverterOptionString.write(value.middleName, into: &buf) - FfiConverterOptionString.write(value.lastName, into: &buf) - FfiConverterOptionString.write(value.address1, into: &buf) - FfiConverterOptionString.write(value.address2, into: &buf) - FfiConverterOptionString.write(value.address3, into: &buf) - FfiConverterOptionString.write(value.city, into: &buf) - FfiConverterOptionString.write(value.state, into: &buf) - FfiConverterOptionString.write(value.postalCode, into: &buf) - FfiConverterOptionString.write(value.country, into: &buf) - FfiConverterOptionString.write(value.company, into: &buf) - FfiConverterOptionString.write(value.email, into: &buf) - FfiConverterOptionString.write(value.phone, into: &buf) - FfiConverterOptionString.write(value.ssn, into: &buf) - FfiConverterOptionString.write(value.username, into: &buf) - FfiConverterOptionString.write(value.passportNumber, into: &buf) - FfiConverterOptionString.write(value.licenseNumber, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.title, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.firstName, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.middleName, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.lastName, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.address1, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.address2, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.address3, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.city, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.state, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.postalCode, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.country, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.company, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.email, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.phone, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.ssn, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.username, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.passportNumber, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.licenseNumber, into: &buf) } } @@ -2979,13 +3398,13 @@ public struct InitOrgCryptoRequest { public init( /** * The encryption keys for all the organizations the user is a part of - */ - organizationKeys: [Uuid: AsymmetricEncString]) { + */organizationKeys: [Uuid: AsymmetricEncString]) { self.organizationKeys = organizationKeys } } + extension InitOrgCryptoRequest: Equatable, Hashable { public static func ==(lhs: InitOrgCryptoRequest, rhs: InitOrgCryptoRequest) -> Bool { if lhs.organizationKeys != rhs.organizationKeys { @@ -3046,20 +3465,16 @@ public struct InitUserCryptoRequest { public init( /** * The user's KDF parameters, as received from the prelogin request - */ - kdfParams: Kdf, + */kdfParams: Kdf, /** * The user's email address - */ - email: String, + */email: String, /** * The user's encrypted private key - */ - privateKey: String, + */privateKey: String, /** * The initialization method to use - */ - method: InitUserCryptoMethod) { + */method: InitUserCryptoMethod) { self.kdfParams = kdfParams self.email = email self.privateKey = privateKey @@ -3068,6 +3483,7 @@ public struct InitUserCryptoRequest { } + extension InitUserCryptoRequest: Equatable, Hashable { public static func ==(lhs: InitUserCryptoRequest, rhs: InitUserCryptoRequest) -> Bool { if lhs.kdfParams != rhs.kdfParams { @@ -3129,15 +3545,14 @@ public struct LocalData { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - lastUsedDate: UInt32?, - lastLaunched: UInt32?) { + public init(lastUsedDate: UInt32?, lastLaunched: UInt32?) { self.lastUsedDate = lastUsedDate self.lastLaunched = lastLaunched } } + extension LocalData: Equatable, Hashable { public static func ==(lhs: LocalData, rhs: LocalData) -> Bool { if lhs.lastUsedDate != rhs.lastUsedDate { @@ -3187,15 +3602,14 @@ public struct LocalDataView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - lastUsedDate: UInt32?, - lastLaunched: UInt32?) { + public init(lastUsedDate: UInt32?, lastLaunched: UInt32?) { self.lastUsedDate = lastUsedDate self.lastLaunched = lastLaunched } } + extension LocalDataView: Equatable, Hashable { public static func ==(lhs: LocalDataView, rhs: LocalDataView) -> Bool { if lhs.lastUsedDate != rhs.lastUsedDate { @@ -3250,14 +3664,7 @@ public struct Login { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - username: EncString?, - password: EncString?, - passwordRevisionDate: DateTime?, - uris: [LoginUri]?, - totp: EncString?, - autofillOnPageLoad: Bool?, - fido2Credentials: [Fido2Credential]?) { + public init(username: EncString?, password: EncString?, passwordRevisionDate: DateTime?, uris: [LoginUri]?, totp: EncString?, autofillOnPageLoad: Bool?, fido2Credentials: [Fido2Credential]?) { self.username = username self.password = password self.passwordRevisionDate = passwordRevisionDate @@ -3269,6 +3676,7 @@ public struct Login { } + extension Login: Equatable, Hashable { public static func ==(lhs: Login, rhs: Login) -> Bool { if lhs.username != rhs.username { @@ -3349,10 +3757,7 @@ public struct LoginUri { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - uri: EncString?, - match: UriMatchType?, - uriChecksum: EncString?) { + public init(uri: EncString?, match: UriMatchType?, uriChecksum: EncString?) { self.uri = uri self.match = match self.uriChecksum = uriChecksum @@ -3360,6 +3765,7 @@ public struct LoginUri { } + extension LoginUri: Equatable, Hashable { public static func ==(lhs: LoginUri, rhs: LoginUri) -> Bool { if lhs.uri != rhs.uri { @@ -3410,16 +3816,13 @@ public func FfiConverterTypeLoginUri_lower(_ value: LoginUri) -> RustBuffer { public struct LoginUriView { - public let uri: String? + public let uri: SensitiveString? public let match: UriMatchType? - public let uriChecksum: String? + public let uriChecksum: SensitiveString? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - uri: String?, - match: UriMatchType?, - uriChecksum: String?) { + public init(uri: SensitiveString?, match: UriMatchType?, uriChecksum: SensitiveString?) { self.uri = uri self.match = match self.uriChecksum = uriChecksum @@ -3427,6 +3830,7 @@ public struct LoginUriView { } + extension LoginUriView: Equatable, Hashable { public static func ==(lhs: LoginUriView, rhs: LoginUriView) -> Bool { if lhs.uri != rhs.uri { @@ -3453,16 +3857,16 @@ public struct FfiConverterTypeLoginUriView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LoginUriView { return try LoginUriView( - uri: FfiConverterOptionString.read(from: &buf), + uri: FfiConverterOptionTypeSensitiveString.read(from: &buf), match: FfiConverterOptionTypeUriMatchType.read(from: &buf), - uriChecksum: FfiConverterOptionString.read(from: &buf) + uriChecksum: FfiConverterOptionTypeSensitiveString.read(from: &buf) ) } public static func write(_ value: LoginUriView, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.uri, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.uri, into: &buf) FfiConverterOptionTypeUriMatchType.write(value.match, into: &buf) - FfiConverterOptionString.write(value.uriChecksum, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.uriChecksum, into: &buf) } } @@ -3477,24 +3881,17 @@ public func FfiConverterTypeLoginUriView_lower(_ value: LoginUriView) -> RustBuf public struct LoginView { - public let username: String? - public let password: String? + public let username: SensitiveString? + public let password: SensitiveString? public let passwordRevisionDate: DateTime? public let uris: [LoginUriView]? - public let totp: String? + public let totp: SensitiveString? public let autofillOnPageLoad: Bool? public let fido2Credentials: [Fido2Credential]? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - username: String?, - password: String?, - passwordRevisionDate: DateTime?, - uris: [LoginUriView]?, - totp: String?, - autofillOnPageLoad: Bool?, - fido2Credentials: [Fido2Credential]?) { + public init(username: SensitiveString?, password: SensitiveString?, passwordRevisionDate: DateTime?, uris: [LoginUriView]?, totp: SensitiveString?, autofillOnPageLoad: Bool?, fido2Credentials: [Fido2Credential]?) { self.username = username self.password = password self.passwordRevisionDate = passwordRevisionDate @@ -3506,6 +3903,7 @@ public struct LoginView { } + extension LoginView: Equatable, Hashable { public static func ==(lhs: LoginView, rhs: LoginView) -> Bool { if lhs.username != rhs.username { @@ -3548,22 +3946,22 @@ public struct FfiConverterTypeLoginView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LoginView { return try LoginView( - username: FfiConverterOptionString.read(from: &buf), - password: FfiConverterOptionString.read(from: &buf), + username: FfiConverterOptionTypeSensitiveString.read(from: &buf), + password: FfiConverterOptionTypeSensitiveString.read(from: &buf), passwordRevisionDate: FfiConverterOptionTypeDateTime.read(from: &buf), uris: FfiConverterOptionSequenceTypeLoginUriView.read(from: &buf), - totp: FfiConverterOptionString.read(from: &buf), + totp: FfiConverterOptionTypeSensitiveString.read(from: &buf), autofillOnPageLoad: FfiConverterOptionBool.read(from: &buf), fido2Credentials: FfiConverterOptionSequenceTypeFido2Credential.read(from: &buf) ) } public static func write(_ value: LoginView, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.username, into: &buf) - FfiConverterOptionString.write(value.password, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.username, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.password, into: &buf) FfiConverterOptionTypeDateTime.write(value.passwordRevisionDate, into: &buf) FfiConverterOptionSequenceTypeLoginUriView.write(value.uris, into: &buf) - FfiConverterOptionString.write(value.totp, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.totp, into: &buf) FfiConverterOptionBool.write(value.autofillOnPageLoad, into: &buf) FfiConverterOptionSequenceTypeFido2Credential.write(value.fido2Credentials, into: &buf) } @@ -3579,6 +3977,152 @@ public func FfiConverterTypeLoginView_lower(_ value: LoginView) -> RustBuffer { } +public struct MakeCredentialRequest { + public let clientDataHash: Data + public let rp: PublicKeyCredentialRpEntity + public let user: PublicKeyCredentialUserEntity + public let pubKeyCredParams: [PublicKeyCredentialParameters] + public let excludeList: [PublicKeyCredentialDescriptor]? + public let requireResidentKey: Bool + public let extensions: [String: String]? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(clientDataHash: Data, rp: PublicKeyCredentialRpEntity, user: PublicKeyCredentialUserEntity, pubKeyCredParams: [PublicKeyCredentialParameters], excludeList: [PublicKeyCredentialDescriptor]?, requireResidentKey: Bool, extensions: [String: String]?) { + self.clientDataHash = clientDataHash + self.rp = rp + self.user = user + self.pubKeyCredParams = pubKeyCredParams + self.excludeList = excludeList + self.requireResidentKey = requireResidentKey + self.extensions = extensions + } +} + + + +extension MakeCredentialRequest: Equatable, Hashable { + public static func ==(lhs: MakeCredentialRequest, rhs: MakeCredentialRequest) -> Bool { + if lhs.clientDataHash != rhs.clientDataHash { + return false + } + if lhs.rp != rhs.rp { + return false + } + if lhs.user != rhs.user { + return false + } + if lhs.pubKeyCredParams != rhs.pubKeyCredParams { + return false + } + if lhs.excludeList != rhs.excludeList { + return false + } + if lhs.requireResidentKey != rhs.requireResidentKey { + return false + } + if lhs.extensions != rhs.extensions { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(clientDataHash) + hasher.combine(rp) + hasher.combine(user) + hasher.combine(pubKeyCredParams) + hasher.combine(excludeList) + hasher.combine(requireResidentKey) + hasher.combine(extensions) + } +} + + +public struct FfiConverterTypeMakeCredentialRequest: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MakeCredentialRequest { + return + try MakeCredentialRequest( + clientDataHash: FfiConverterData.read(from: &buf), + rp: FfiConverterTypePublicKeyCredentialRpEntity.read(from: &buf), + user: FfiConverterTypePublicKeyCredentialUserEntity.read(from: &buf), + pubKeyCredParams: FfiConverterSequenceTypePublicKeyCredentialParameters.read(from: &buf), + excludeList: FfiConverterOptionSequenceTypePublicKeyCredentialDescriptor.read(from: &buf), + requireResidentKey: FfiConverterBool.read(from: &buf), + extensions: FfiConverterOptionDictionaryStringString.read(from: &buf) + ) + } + + public static func write(_ value: MakeCredentialRequest, into buf: inout [UInt8]) { + FfiConverterData.write(value.clientDataHash, into: &buf) + FfiConverterTypePublicKeyCredentialRpEntity.write(value.rp, into: &buf) + FfiConverterTypePublicKeyCredentialUserEntity.write(value.user, into: &buf) + FfiConverterSequenceTypePublicKeyCredentialParameters.write(value.pubKeyCredParams, into: &buf) + FfiConverterOptionSequenceTypePublicKeyCredentialDescriptor.write(value.excludeList, into: &buf) + FfiConverterBool.write(value.requireResidentKey, into: &buf) + FfiConverterOptionDictionaryStringString.write(value.extensions, into: &buf) + } +} + + +public func FfiConverterTypeMakeCredentialRequest_lift(_ buf: RustBuffer) throws -> MakeCredentialRequest { + return try FfiConverterTypeMakeCredentialRequest.lift(buf) +} + +public func FfiConverterTypeMakeCredentialRequest_lower(_ value: MakeCredentialRequest) -> RustBuffer { + return FfiConverterTypeMakeCredentialRequest.lower(value) +} + + +public struct MakeCredentialResult { + public let credentialId: Data + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(credentialId: Data) { + self.credentialId = credentialId + } +} + + + +extension MakeCredentialResult: Equatable, Hashable { + public static func ==(lhs: MakeCredentialResult, rhs: MakeCredentialResult) -> Bool { + if lhs.credentialId != rhs.credentialId { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(credentialId) + } +} + + +public struct FfiConverterTypeMakeCredentialResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MakeCredentialResult { + return + try MakeCredentialResult( + credentialId: FfiConverterData.read(from: &buf) + ) + } + + public static func write(_ value: MakeCredentialResult, into buf: inout [UInt8]) { + FfiConverterData.write(value.credentialId, into: &buf) + } +} + + +public func FfiConverterTypeMakeCredentialResult_lift(_ buf: RustBuffer) throws -> MakeCredentialResult { + return try FfiConverterTypeMakeCredentialResult.lift(buf) +} + +public func FfiConverterTypeMakeCredentialResult_lower(_ value: MakeCredentialResult) -> RustBuffer { + return FfiConverterTypeMakeCredentialResult.lower(value) +} + + public struct MasterPasswordPolicyOptions { public let minComplexity: UInt8 public let minLength: UInt8 @@ -3595,19 +4139,12 @@ public struct MasterPasswordPolicyOptions { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - minComplexity: UInt8, - minLength: UInt8, - requireUpper: Bool, - requireLower: Bool, - requireNumbers: Bool, - requireSpecial: Bool, + public init(minComplexity: UInt8, minLength: UInt8, requireUpper: Bool, requireLower: Bool, requireNumbers: Bool, requireSpecial: Bool, /** * Flag to indicate if the policy should be enforced on login. * If true, and the user's password does not meet the policy requirements, * the user will be forced to update their password. - */ - enforceOnLogin: Bool) { + */enforceOnLogin: Bool) { self.minComplexity = minComplexity self.minLength = minLength self.requireUpper = requireUpper @@ -3619,6 +4156,7 @@ public struct MasterPasswordPolicyOptions { } + extension MasterPasswordPolicyOptions: Equatable, Hashable { public static func ==(lhs: MasterPasswordPolicyOptions, rhs: MasterPasswordPolicyOptions) -> Bool { if lhs.minComplexity != rhs.minComplexity { @@ -3692,21 +4230,77 @@ public func FfiConverterTypeMasterPasswordPolicyOptions_lower(_ value: MasterPas } +public struct Options { + public let rk: Bool + public let uv: Uv + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(rk: Bool, uv: Uv) { + self.rk = rk + self.uv = uv + } +} + + + +extension Options: Equatable, Hashable { + public static func ==(lhs: Options, rhs: Options) -> Bool { + if lhs.rk != rhs.rk { + return false + } + if lhs.uv != rhs.uv { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(rk) + hasher.combine(uv) + } +} + + +public struct FfiConverterTypeOptions: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Options { + return + try Options( + rk: FfiConverterBool.read(from: &buf), + uv: FfiConverterTypeUV.read(from: &buf) + ) + } + + public static func write(_ value: Options, into buf: inout [UInt8]) { + FfiConverterBool.write(value.rk, into: &buf) + FfiConverterTypeUV.write(value.uv, into: &buf) + } +} + + +public func FfiConverterTypeOptions_lift(_ buf: RustBuffer) throws -> Options { + return try FfiConverterTypeOptions.lift(buf) +} + +public func FfiConverterTypeOptions_lower(_ value: Options) -> RustBuffer { + return FfiConverterTypeOptions.lower(value) +} + + public struct PasswordHistory { public let password: EncString public let lastUsedDate: DateTime // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - password: EncString, - lastUsedDate: DateTime) { + public init(password: EncString, lastUsedDate: DateTime) { self.password = password self.lastUsedDate = lastUsedDate } } + extension PasswordHistory: Equatable, Hashable { public static func ==(lhs: PasswordHistory, rhs: PasswordHistory) -> Bool { if lhs.password != rhs.password { @@ -3751,20 +4345,19 @@ public func FfiConverterTypePasswordHistory_lower(_ value: PasswordHistory) -> R public struct PasswordHistoryView { - public let password: String + public let password: SensitiveString public let lastUsedDate: DateTime // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - password: String, - lastUsedDate: DateTime) { + public init(password: SensitiveString, lastUsedDate: DateTime) { self.password = password self.lastUsedDate = lastUsedDate } } + extension PasswordHistoryView: Equatable, Hashable { public static func ==(lhs: PasswordHistoryView, rhs: PasswordHistoryView) -> Bool { if lhs.password != rhs.password { @@ -3787,13 +4380,13 @@ public struct FfiConverterTypePasswordHistoryView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PasswordHistoryView { return try PasswordHistoryView( - password: FfiConverterString.read(from: &buf), + password: FfiConverterTypeSensitiveString.read(from: &buf), lastUsedDate: FfiConverterTypeDateTime.read(from: &buf) ) } public static func write(_ value: PasswordHistoryView, into buf: inout [UInt8]) { - FfiConverterString.write(value.password, into: &buf) + FfiConverterTypeSensitiveString.write(value.password, into: &buf) FfiConverterTypeDateTime.write(value.lastUsedDate, into: &buf) } } @@ -3808,40 +4401,468 @@ public func FfiConverterTypePasswordHistoryView_lower(_ value: PasswordHistoryVi } -public struct RegisterKeyResponse { - public let masterPasswordHash: String - public let encryptedUserKey: String - public let keys: RsaKeyPair +public struct PublicKeyCredentialAuthenticatorAssertionResponse { + public let id: String + public let rawId: Data + public let ty: String + public let authenticatorAttachment: String + public let clientExtensionResults: [String: Bool] + public let response: AuthenticatorAssertionResponse + public let selectedCredential: SelectedCredential // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - masterPasswordHash: String, - encryptedUserKey: String, - keys: RsaKeyPair) { - self.masterPasswordHash = masterPasswordHash - self.encryptedUserKey = encryptedUserKey - self.keys = keys + public init(id: String, rawId: Data, ty: String, authenticatorAttachment: String, clientExtensionResults: [String: Bool], response: AuthenticatorAssertionResponse, selectedCredential: SelectedCredential) { + self.id = id + self.rawId = rawId + self.ty = ty + self.authenticatorAttachment = authenticatorAttachment + self.clientExtensionResults = clientExtensionResults + self.response = response + self.selectedCredential = selectedCredential } } -extension RegisterKeyResponse: Equatable, Hashable { - public static func ==(lhs: RegisterKeyResponse, rhs: RegisterKeyResponse) -> Bool { - if lhs.masterPasswordHash != rhs.masterPasswordHash { + +extension PublicKeyCredentialAuthenticatorAssertionResponse: Equatable, Hashable { + public static func ==(lhs: PublicKeyCredentialAuthenticatorAssertionResponse, rhs: PublicKeyCredentialAuthenticatorAssertionResponse) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.encryptedUserKey != rhs.encryptedUserKey { + if lhs.rawId != rhs.rawId { return false } - if lhs.keys != rhs.keys { + if lhs.ty != rhs.ty { + return false + } + if lhs.authenticatorAttachment != rhs.authenticatorAttachment { + return false + } + if lhs.clientExtensionResults != rhs.clientExtensionResults { + return false + } + if lhs.response != rhs.response { + return false + } + if lhs.selectedCredential != rhs.selectedCredential { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(masterPasswordHash) + hasher.combine(id) + hasher.combine(rawId) + hasher.combine(ty) + hasher.combine(authenticatorAttachment) + hasher.combine(clientExtensionResults) + hasher.combine(response) + hasher.combine(selectedCredential) + } +} + + +public struct FfiConverterTypePublicKeyCredentialAuthenticatorAssertionResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyCredentialAuthenticatorAssertionResponse { + return + try PublicKeyCredentialAuthenticatorAssertionResponse( + id: FfiConverterString.read(from: &buf), + rawId: FfiConverterData.read(from: &buf), + ty: FfiConverterString.read(from: &buf), + authenticatorAttachment: FfiConverterString.read(from: &buf), + clientExtensionResults: FfiConverterDictionaryStringBool.read(from: &buf), + response: FfiConverterTypeAuthenticatorAssertionResponse.read(from: &buf), + selectedCredential: FfiConverterTypeSelectedCredential.read(from: &buf) + ) + } + + public static func write(_ value: PublicKeyCredentialAuthenticatorAssertionResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterData.write(value.rawId, into: &buf) + FfiConverterString.write(value.ty, into: &buf) + FfiConverterString.write(value.authenticatorAttachment, into: &buf) + FfiConverterDictionaryStringBool.write(value.clientExtensionResults, into: &buf) + FfiConverterTypeAuthenticatorAssertionResponse.write(value.response, into: &buf) + FfiConverterTypeSelectedCredential.write(value.selectedCredential, into: &buf) + } +} + + +public func FfiConverterTypePublicKeyCredentialAuthenticatorAssertionResponse_lift(_ buf: RustBuffer) throws -> PublicKeyCredentialAuthenticatorAssertionResponse { + return try FfiConverterTypePublicKeyCredentialAuthenticatorAssertionResponse.lift(buf) +} + +public func FfiConverterTypePublicKeyCredentialAuthenticatorAssertionResponse_lower(_ value: PublicKeyCredentialAuthenticatorAssertionResponse) -> RustBuffer { + return FfiConverterTypePublicKeyCredentialAuthenticatorAssertionResponse.lower(value) +} + + +public struct PublicKeyCredentialAuthenticatorAttestationResponse { + public let id: String + public let rawId: Data + public let ty: String + public let authenticatorAttachment: String + public let clientExtensionResults: [String: Bool] + public let response: AuthenticatorAttestationResponse + public let selectedCredential: SelectedCredential + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, rawId: Data, ty: String, authenticatorAttachment: String, clientExtensionResults: [String: Bool], response: AuthenticatorAttestationResponse, selectedCredential: SelectedCredential) { + self.id = id + self.rawId = rawId + self.ty = ty + self.authenticatorAttachment = authenticatorAttachment + self.clientExtensionResults = clientExtensionResults + self.response = response + self.selectedCredential = selectedCredential + } +} + + + +extension PublicKeyCredentialAuthenticatorAttestationResponse: Equatable, Hashable { + public static func ==(lhs: PublicKeyCredentialAuthenticatorAttestationResponse, rhs: PublicKeyCredentialAuthenticatorAttestationResponse) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.rawId != rhs.rawId { + return false + } + if lhs.ty != rhs.ty { + return false + } + if lhs.authenticatorAttachment != rhs.authenticatorAttachment { + return false + } + if lhs.clientExtensionResults != rhs.clientExtensionResults { + return false + } + if lhs.response != rhs.response { + return false + } + if lhs.selectedCredential != rhs.selectedCredential { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(rawId) + hasher.combine(ty) + hasher.combine(authenticatorAttachment) + hasher.combine(clientExtensionResults) + hasher.combine(response) + hasher.combine(selectedCredential) + } +} + + +public struct FfiConverterTypePublicKeyCredentialAuthenticatorAttestationResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyCredentialAuthenticatorAttestationResponse { + return + try PublicKeyCredentialAuthenticatorAttestationResponse( + id: FfiConverterString.read(from: &buf), + rawId: FfiConverterData.read(from: &buf), + ty: FfiConverterString.read(from: &buf), + authenticatorAttachment: FfiConverterString.read(from: &buf), + clientExtensionResults: FfiConverterDictionaryStringBool.read(from: &buf), + response: FfiConverterTypeAuthenticatorAttestationResponse.read(from: &buf), + selectedCredential: FfiConverterTypeSelectedCredential.read(from: &buf) + ) + } + + public static func write(_ value: PublicKeyCredentialAuthenticatorAttestationResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterData.write(value.rawId, into: &buf) + FfiConverterString.write(value.ty, into: &buf) + FfiConverterString.write(value.authenticatorAttachment, into: &buf) + FfiConverterDictionaryStringBool.write(value.clientExtensionResults, into: &buf) + FfiConverterTypeAuthenticatorAttestationResponse.write(value.response, into: &buf) + FfiConverterTypeSelectedCredential.write(value.selectedCredential, into: &buf) + } +} + + +public func FfiConverterTypePublicKeyCredentialAuthenticatorAttestationResponse_lift(_ buf: RustBuffer) throws -> PublicKeyCredentialAuthenticatorAttestationResponse { + return try FfiConverterTypePublicKeyCredentialAuthenticatorAttestationResponse.lift(buf) +} + +public func FfiConverterTypePublicKeyCredentialAuthenticatorAttestationResponse_lower(_ value: PublicKeyCredentialAuthenticatorAttestationResponse) -> RustBuffer { + return FfiConverterTypePublicKeyCredentialAuthenticatorAttestationResponse.lower(value) +} + + +public struct PublicKeyCredentialDescriptor { + public let ty: Int64 + public let id: Data + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(ty: Int64, id: Data) { + self.ty = ty + self.id = id + } +} + + + +extension PublicKeyCredentialDescriptor: Equatable, Hashable { + public static func ==(lhs: PublicKeyCredentialDescriptor, rhs: PublicKeyCredentialDescriptor) -> Bool { + if lhs.ty != rhs.ty { + return false + } + if lhs.id != rhs.id { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(ty) + hasher.combine(id) + } +} + + +public struct FfiConverterTypePublicKeyCredentialDescriptor: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyCredentialDescriptor { + return + try PublicKeyCredentialDescriptor( + ty: FfiConverterInt64.read(from: &buf), + id: FfiConverterData.read(from: &buf) + ) + } + + public static func write(_ value: PublicKeyCredentialDescriptor, into buf: inout [UInt8]) { + FfiConverterInt64.write(value.ty, into: &buf) + FfiConverterData.write(value.id, into: &buf) + } +} + + +public func FfiConverterTypePublicKeyCredentialDescriptor_lift(_ buf: RustBuffer) throws -> PublicKeyCredentialDescriptor { + return try FfiConverterTypePublicKeyCredentialDescriptor.lift(buf) +} + +public func FfiConverterTypePublicKeyCredentialDescriptor_lower(_ value: PublicKeyCredentialDescriptor) -> RustBuffer { + return FfiConverterTypePublicKeyCredentialDescriptor.lower(value) +} + + +public struct PublicKeyCredentialParameters { + public let ty: String + public let alg: Int64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(ty: String, alg: Int64) { + self.ty = ty + self.alg = alg + } +} + + + +extension PublicKeyCredentialParameters: Equatable, Hashable { + public static func ==(lhs: PublicKeyCredentialParameters, rhs: PublicKeyCredentialParameters) -> Bool { + if lhs.ty != rhs.ty { + return false + } + if lhs.alg != rhs.alg { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(ty) + hasher.combine(alg) + } +} + + +public struct FfiConverterTypePublicKeyCredentialParameters: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyCredentialParameters { + return + try PublicKeyCredentialParameters( + ty: FfiConverterString.read(from: &buf), + alg: FfiConverterInt64.read(from: &buf) + ) + } + + public static func write(_ value: PublicKeyCredentialParameters, into buf: inout [UInt8]) { + FfiConverterString.write(value.ty, into: &buf) + FfiConverterInt64.write(value.alg, into: &buf) + } +} + + +public func FfiConverterTypePublicKeyCredentialParameters_lift(_ buf: RustBuffer) throws -> PublicKeyCredentialParameters { + return try FfiConverterTypePublicKeyCredentialParameters.lift(buf) +} + +public func FfiConverterTypePublicKeyCredentialParameters_lower(_ value: PublicKeyCredentialParameters) -> RustBuffer { + return FfiConverterTypePublicKeyCredentialParameters.lower(value) +} + + +public struct PublicKeyCredentialRpEntity { + public let id: String + public let name: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: String, name: String?) { + self.id = id + self.name = name + } +} + + + +extension PublicKeyCredentialRpEntity: Equatable, Hashable { + public static func ==(lhs: PublicKeyCredentialRpEntity, rhs: PublicKeyCredentialRpEntity) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.name != rhs.name { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(name) + } +} + + +public struct FfiConverterTypePublicKeyCredentialRpEntity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyCredentialRpEntity { + return + try PublicKeyCredentialRpEntity( + id: FfiConverterString.read(from: &buf), + name: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PublicKeyCredentialRpEntity, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterOptionString.write(value.name, into: &buf) + } +} + + +public func FfiConverterTypePublicKeyCredentialRpEntity_lift(_ buf: RustBuffer) throws -> PublicKeyCredentialRpEntity { + return try FfiConverterTypePublicKeyCredentialRpEntity.lift(buf) +} + +public func FfiConverterTypePublicKeyCredentialRpEntity_lower(_ value: PublicKeyCredentialRpEntity) -> RustBuffer { + return FfiConverterTypePublicKeyCredentialRpEntity.lower(value) +} + + +public struct PublicKeyCredentialUserEntity { + public let id: Data + public let displayName: String + public let name: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(id: Data, displayName: String, name: String) { + self.id = id + self.displayName = displayName + self.name = name + } +} + + + +extension PublicKeyCredentialUserEntity: Equatable, Hashable { + public static func ==(lhs: PublicKeyCredentialUserEntity, rhs: PublicKeyCredentialUserEntity) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.displayName != rhs.displayName { + return false + } + if lhs.name != rhs.name { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(displayName) + hasher.combine(name) + } +} + + +public struct FfiConverterTypePublicKeyCredentialUserEntity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PublicKeyCredentialUserEntity { + return + try PublicKeyCredentialUserEntity( + id: FfiConverterData.read(from: &buf), + displayName: FfiConverterString.read(from: &buf), + name: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: PublicKeyCredentialUserEntity, into buf: inout [UInt8]) { + FfiConverterData.write(value.id, into: &buf) + FfiConverterString.write(value.displayName, into: &buf) + FfiConverterString.write(value.name, into: &buf) + } +} + + +public func FfiConverterTypePublicKeyCredentialUserEntity_lift(_ buf: RustBuffer) throws -> PublicKeyCredentialUserEntity { + return try FfiConverterTypePublicKeyCredentialUserEntity.lift(buf) +} + +public func FfiConverterTypePublicKeyCredentialUserEntity_lower(_ value: PublicKeyCredentialUserEntity) -> RustBuffer { + return FfiConverterTypePublicKeyCredentialUserEntity.lower(value) +} + + +public struct RegisterKeyResponse { + public let masterPasswordHash: SensitiveString + public let encryptedUserKey: String + public let keys: RsaKeyPair + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(masterPasswordHash: SensitiveString, encryptedUserKey: String, keys: RsaKeyPair) { + self.masterPasswordHash = masterPasswordHash + self.encryptedUserKey = encryptedUserKey + self.keys = keys + } +} + + + +extension RegisterKeyResponse: Equatable, Hashable { + public static func ==(lhs: RegisterKeyResponse, rhs: RegisterKeyResponse) -> Bool { + if lhs.masterPasswordHash != rhs.masterPasswordHash { + return false + } + if lhs.encryptedUserKey != rhs.encryptedUserKey { + return false + } + if lhs.keys != rhs.keys { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(masterPasswordHash) hasher.combine(encryptedUserKey) hasher.combine(keys) } @@ -3852,14 +4873,14 @@ public struct FfiConverterTypeRegisterKeyResponse: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RegisterKeyResponse { return try RegisterKeyResponse( - masterPasswordHash: FfiConverterString.read(from: &buf), + masterPasswordHash: FfiConverterTypeSensitiveString.read(from: &buf), encryptedUserKey: FfiConverterString.read(from: &buf), keys: FfiConverterTypeRsaKeyPair.read(from: &buf) ) } public static func write(_ value: RegisterKeyResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.masterPasswordHash, into: &buf) + FfiConverterTypeSensitiveString.write(value.masterPasswordHash, into: &buf) FfiConverterString.write(value.encryptedUserKey, into: &buf) FfiConverterTypeRsaKeyPair.write(value.keys, into: &buf) } @@ -3883,11 +4904,7 @@ public struct RegisterTdeKeyResponse { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - privateKey: EncString, - publicKey: String, - adminReset: AsymmetricEncString, - deviceKey: TrustDeviceResponse?) { + public init(privateKey: EncString, publicKey: String, adminReset: AsymmetricEncString, deviceKey: TrustDeviceResponse?) { self.privateKey = privateKey self.publicKey = publicKey self.adminReset = adminReset @@ -3896,6 +4913,7 @@ public struct RegisterTdeKeyResponse { } + extension RegisterTdeKeyResponse: Equatable, Hashable { public static func ==(lhs: RegisterTdeKeyResponse, rhs: RegisterTdeKeyResponse) -> Bool { if lhs.privateKey != rhs.privateKey { @@ -3956,13 +4974,13 @@ public struct SecureNote { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - type: SecureNoteType) { + public init(type: SecureNoteType) { self.type = type } } + extension SecureNote: Equatable, Hashable { public static func ==(lhs: SecureNote, rhs: SecureNote) -> Bool { if lhs.type != rhs.type { @@ -4005,13 +5023,13 @@ public struct SecureNoteView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - type: SecureNoteType) { + public init(type: SecureNoteType) { self.type = type } } + extension SecureNoteView: Equatable, Hashable { public static func ==(lhs: SecureNoteView, rhs: SecureNoteView) -> Bool { if lhs.type != rhs.type { @@ -4049,13 +5067,70 @@ public func FfiConverterTypeSecureNoteView_lower(_ value: SecureNoteView) -> Rus } +public struct SelectedCredential { + public let cipher: CipherView + public let credential: Fido2Credential + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(cipher: CipherView, credential: Fido2Credential) { + self.cipher = cipher + self.credential = credential + } +} + + + +extension SelectedCredential: Equatable, Hashable { + public static func ==(lhs: SelectedCredential, rhs: SelectedCredential) -> Bool { + if lhs.cipher != rhs.cipher { + return false + } + if lhs.credential != rhs.credential { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(cipher) + hasher.combine(credential) + } +} + + +public struct FfiConverterTypeSelectedCredential: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SelectedCredential { + return + try SelectedCredential( + cipher: FfiConverterTypeCipherView.read(from: &buf), + credential: FfiConverterTypeFido2Credential.read(from: &buf) + ) + } + + public static func write(_ value: SelectedCredential, into buf: inout [UInt8]) { + FfiConverterTypeCipherView.write(value.cipher, into: &buf) + FfiConverterTypeFido2Credential.write(value.credential, into: &buf) + } +} + + +public func FfiConverterTypeSelectedCredential_lift(_ buf: RustBuffer) throws -> SelectedCredential { + return try FfiConverterTypeSelectedCredential.lift(buf) +} + +public func FfiConverterTypeSelectedCredential_lower(_ value: SelectedCredential) -> RustBuffer { + return FfiConverterTypeSelectedCredential.lower(value) +} + + public struct Send { public let id: Uuid? public let accessId: String? public let name: EncString public let notes: EncString? public let key: EncString - public let password: String? + public let password: SensitiveString? public let type: SendType public let file: SendFile? public let text: SendText? @@ -4069,23 +5144,7 @@ public struct Send { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - accessId: String?, - name: EncString, - notes: EncString?, - key: EncString, - password: String?, - type: SendType, - file: SendFile?, - text: SendText?, - maxAccessCount: UInt32?, - accessCount: UInt32, - disabled: Bool, - hideEmail: Bool, - revisionDate: DateTime, - deletionDate: DateTime, - expirationDate: DateTime?) { + public init(id: Uuid?, accessId: String?, name: EncString, notes: EncString?, key: EncString, password: SensitiveString?, type: SendType, file: SendFile?, text: SendText?, maxAccessCount: UInt32?, accessCount: UInt32, disabled: Bool, hideEmail: Bool, revisionDate: DateTime, deletionDate: DateTime, expirationDate: DateTime?) { self.id = id self.accessId = accessId self.name = name @@ -4106,6 +5165,7 @@ public struct Send { } + extension Send: Equatable, Hashable { public static func ==(lhs: Send, rhs: Send) -> Bool { if lhs.id != rhs.id { @@ -4189,7 +5249,7 @@ public struct FfiConverterTypeSend: FfiConverterRustBuffer { name: FfiConverterTypeEncString.read(from: &buf), notes: FfiConverterOptionTypeEncString.read(from: &buf), key: FfiConverterTypeEncString.read(from: &buf), - password: FfiConverterOptionString.read(from: &buf), + password: FfiConverterOptionTypeSensitiveString.read(from: &buf), type: FfiConverterTypeSendType.read(from: &buf), file: FfiConverterOptionTypeSendFile.read(from: &buf), text: FfiConverterOptionTypeSendText.read(from: &buf), @@ -4209,7 +5269,7 @@ public struct FfiConverterTypeSend: FfiConverterRustBuffer { FfiConverterTypeEncString.write(value.name, into: &buf) FfiConverterOptionTypeEncString.write(value.notes, into: &buf) FfiConverterTypeEncString.write(value.key, into: &buf) - FfiConverterOptionString.write(value.password, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.password, into: &buf) FfiConverterTypeSendType.write(value.type, into: &buf) FfiConverterOptionTypeSendFile.write(value.file, into: &buf) FfiConverterOptionTypeSendText.write(value.text, into: &buf) @@ -4244,14 +5304,10 @@ public struct SendFile { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: String?, - fileName: EncString, - size: String?, + public init(id: String?, fileName: EncString, size: String?, /** * Readable size, ex: "4.2 KB" or "1.43 GB" - */ - sizeName: String?) { + */sizeName: String?) { self.id = id self.fileName = fileName self.size = size @@ -4260,6 +5316,7 @@ public struct SendFile { } + extension SendFile: Equatable, Hashable { public static func ==(lhs: SendFile, rhs: SendFile) -> Bool { if lhs.id != rhs.id { @@ -4317,7 +5374,7 @@ public func FfiConverterTypeSendFile_lower(_ value: SendFile) -> RustBuffer { public struct SendFileView { public let id: String? - public let fileName: String + public let fileName: SensitiveString public let size: String? /** * Readable size, ex: "4.2 KB" or "1.43 GB" @@ -4326,14 +5383,10 @@ public struct SendFileView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: String?, - fileName: String, - size: String?, + public init(id: String?, fileName: SensitiveString, size: String?, /** * Readable size, ex: "4.2 KB" or "1.43 GB" - */ - sizeName: String?) { + */sizeName: String?) { self.id = id self.fileName = fileName self.size = size @@ -4342,6 +5395,7 @@ public struct SendFileView { } + extension SendFileView: Equatable, Hashable { public static func ==(lhs: SendFileView, rhs: SendFileView) -> Bool { if lhs.id != rhs.id { @@ -4373,7 +5427,7 @@ public struct FfiConverterTypeSendFileView: FfiConverterRustBuffer { return try SendFileView( id: FfiConverterOptionString.read(from: &buf), - fileName: FfiConverterString.read(from: &buf), + fileName: FfiConverterTypeSensitiveString.read(from: &buf), size: FfiConverterOptionString.read(from: &buf), sizeName: FfiConverterOptionString.read(from: &buf) ) @@ -4381,7 +5435,7 @@ public struct FfiConverterTypeSendFileView: FfiConverterRustBuffer { public static func write(_ value: SendFileView, into buf: inout [UInt8]) { FfiConverterOptionString.write(value.id, into: &buf) - FfiConverterString.write(value.fileName, into: &buf) + FfiConverterTypeSensitiveString.write(value.fileName, into: &buf) FfiConverterOptionString.write(value.size, into: &buf) FfiConverterOptionString.write(value.sizeName, into: &buf) } @@ -4400,7 +5454,7 @@ public func FfiConverterTypeSendFileView_lower(_ value: SendFileView) -> RustBuf public struct SendListView { public let id: Uuid? public let accessId: String? - public let name: String + public let name: SensitiveString public let type: SendType public let disabled: Bool public let revisionDate: DateTime @@ -4409,15 +5463,7 @@ public struct SendListView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - accessId: String?, - name: String, - type: SendType, - disabled: Bool, - revisionDate: DateTime, - deletionDate: DateTime, - expirationDate: DateTime?) { + public init(id: Uuid?, accessId: String?, name: SensitiveString, type: SendType, disabled: Bool, revisionDate: DateTime, deletionDate: DateTime, expirationDate: DateTime?) { self.id = id self.accessId = accessId self.name = name @@ -4430,6 +5476,7 @@ public struct SendListView { } + extension SendListView: Equatable, Hashable { public static func ==(lhs: SendListView, rhs: SendListView) -> Bool { if lhs.id != rhs.id { @@ -4478,7 +5525,7 @@ public struct FfiConverterTypeSendListView: FfiConverterRustBuffer { try SendListView( id: FfiConverterOptionTypeUuid.read(from: &buf), accessId: FfiConverterOptionString.read(from: &buf), - name: FfiConverterString.read(from: &buf), + name: FfiConverterTypeSensitiveString.read(from: &buf), type: FfiConverterTypeSendType.read(from: &buf), disabled: FfiConverterBool.read(from: &buf), revisionDate: FfiConverterTypeDateTime.read(from: &buf), @@ -4490,7 +5537,7 @@ public struct FfiConverterTypeSendListView: FfiConverterRustBuffer { public static func write(_ value: SendListView, into buf: inout [UInt8]) { FfiConverterOptionTypeUuid.write(value.id, into: &buf) FfiConverterOptionString.write(value.accessId, into: &buf) - FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeSensitiveString.write(value.name, into: &buf) FfiConverterTypeSendType.write(value.type, into: &buf) FfiConverterBool.write(value.disabled, into: &buf) FfiConverterTypeDateTime.write(value.revisionDate, into: &buf) @@ -4515,15 +5562,14 @@ public struct SendText { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - text: EncString?, - hidden: Bool) { + public init(text: EncString?, hidden: Bool) { self.text = text self.hidden = hidden } } + extension SendText: Equatable, Hashable { public static func ==(lhs: SendText, rhs: SendText) -> Bool { if lhs.text != rhs.text { @@ -4568,20 +5614,19 @@ public func FfiConverterTypeSendText_lower(_ value: SendText) -> RustBuffer { public struct SendTextView { - public let text: String? + public let text: SensitiveString? public let hidden: Bool // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - text: String?, - hidden: Bool) { + public init(text: SensitiveString?, hidden: Bool) { self.text = text self.hidden = hidden } } + extension SendTextView: Equatable, Hashable { public static func ==(lhs: SendTextView, rhs: SendTextView) -> Bool { if lhs.text != rhs.text { @@ -4604,13 +5649,13 @@ public struct FfiConverterTypeSendTextView: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SendTextView { return try SendTextView( - text: FfiConverterOptionString.read(from: &buf), + text: FfiConverterOptionTypeSensitiveString.read(from: &buf), hidden: FfiConverterBool.read(from: &buf) ) } public static func write(_ value: SendTextView, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.text, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.text, into: &buf) FfiConverterBool.write(value.hidden, into: &buf) } } @@ -4628,12 +5673,12 @@ public func FfiConverterTypeSendTextView_lower(_ value: SendTextView) -> RustBuf public struct SendView { public let id: Uuid? public let accessId: String? - public let name: String - public let notes: String? + public let name: SensitiveString + public let notes: SensitiveString? /** * Base64 encoded key */ - public let key: String? + public let key: SensitiveString? /** * Replace or add a password to an existing send. The SDK will always return None when * decrypting a [Send] @@ -4658,36 +5703,19 @@ public struct SendView { // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - id: Uuid?, - accessId: String?, - name: String, - notes: String?, + public init(id: Uuid?, accessId: String?, name: SensitiveString, notes: SensitiveString?, /** * Base64 encoded key - */ - key: String?, + */key: SensitiveString?, /** * Replace or add a password to an existing send. The SDK will always return None when * decrypting a [Send] * TODO: We should revisit this, one variant is to have `[Create, Update]SendView` DTOs. - */ - newPassword: String?, + */newPassword: String?, /** * Denote if an existing send has a password. The SDK will ignore this value when creating or * updating sends. - */ - hasPassword: Bool, - type: SendType, - file: SendFileView?, - text: SendTextView?, - maxAccessCount: UInt32?, - accessCount: UInt32, - disabled: Bool, - hideEmail: Bool, - revisionDate: DateTime, - deletionDate: DateTime, - expirationDate: DateTime?) { + */hasPassword: Bool, type: SendType, file: SendFileView?, text: SendTextView?, maxAccessCount: UInt32?, accessCount: UInt32, disabled: Bool, hideEmail: Bool, revisionDate: DateTime, deletionDate: DateTime, expirationDate: DateTime?) { self.id = id self.accessId = accessId self.name = name @@ -4709,6 +5737,7 @@ public struct SendView { } + extension SendView: Equatable, Hashable { public static func ==(lhs: SendView, rhs: SendView) -> Bool { if lhs.id != rhs.id { @@ -4793,9 +5822,9 @@ public struct FfiConverterTypeSendView: FfiConverterRustBuffer { try SendView( id: FfiConverterOptionTypeUuid.read(from: &buf), accessId: FfiConverterOptionString.read(from: &buf), - name: FfiConverterString.read(from: &buf), - notes: FfiConverterOptionString.read(from: &buf), - key: FfiConverterOptionString.read(from: &buf), + name: FfiConverterTypeSensitiveString.read(from: &buf), + notes: FfiConverterOptionTypeSensitiveString.read(from: &buf), + key: FfiConverterOptionTypeSensitiveString.read(from: &buf), newPassword: FfiConverterOptionString.read(from: &buf), hasPassword: FfiConverterBool.read(from: &buf), type: FfiConverterTypeSendType.read(from: &buf), @@ -4814,9 +5843,9 @@ public struct FfiConverterTypeSendView: FfiConverterRustBuffer { public static func write(_ value: SendView, into buf: inout [UInt8]) { FfiConverterOptionTypeUuid.write(value.id, into: &buf) FfiConverterOptionString.write(value.accessId, into: &buf) - FfiConverterString.write(value.name, into: &buf) - FfiConverterOptionString.write(value.notes, into: &buf) - FfiConverterOptionString.write(value.key, into: &buf) + FfiConverterTypeSensitiveString.write(value.name, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.notes, into: &buf) + FfiConverterOptionTypeSensitiveString.write(value.key, into: &buf) FfiConverterOptionString.write(value.newPassword, into: &buf) FfiConverterBool.write(value.hasPassword, into: &buf) FfiConverterTypeSendType.write(value.type, into: &buf) @@ -4857,18 +5886,17 @@ public struct TotpResponse { public init( /** * Generated TOTP code - */ - code: String, + */code: String, /** * Time period - */ - period: UInt32) { + */period: UInt32) { self.code = code self.period = period } } + extension TotpResponse: Equatable, Hashable { public static func ==(lhs: TotpResponse, rhs: TotpResponse) -> Bool { if lhs.code != rhs.code { @@ -4916,7 +5944,7 @@ public struct UpdatePasswordResponse { /** * Hash of the new password */ - public let passwordHash: String + public let passwordHash: SensitiveString /** * User key, encrypted with the new password */ @@ -4927,18 +5955,17 @@ public struct UpdatePasswordResponse { public init( /** * Hash of the new password - */ - passwordHash: String, + */passwordHash: SensitiveString, /** * User key, encrypted with the new password - */ - newKey: EncString) { + */newKey: EncString) { self.passwordHash = passwordHash self.newKey = newKey } } + extension UpdatePasswordResponse: Equatable, Hashable { public static func ==(lhs: UpdatePasswordResponse, rhs: UpdatePasswordResponse) -> Bool { if lhs.passwordHash != rhs.passwordHash { @@ -4961,13 +5988,13 @@ public struct FfiConverterTypeUpdatePasswordResponse: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UpdatePasswordResponse { return try UpdatePasswordResponse( - passwordHash: FfiConverterString.read(from: &buf), + passwordHash: FfiConverterTypeSensitiveString.read(from: &buf), newKey: FfiConverterTypeEncString.read(from: &buf) ) } public static func write(_ value: UpdatePasswordResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.passwordHash, into: &buf) + FfiConverterTypeSensitiveString.write(value.passwordHash, into: &buf) FfiConverterTypeEncString.write(value.newKey, into: &buf) } } @@ -4983,26 +6010,25 @@ public func FfiConverterTypeUpdatePasswordResponse_lower(_ value: UpdatePassword // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + public enum AuthRequestMethod { case userKey( /** * User Key protected by the private key provided in `AuthRequestResponse`. - */ - protectedUserKey: AsymmetricEncString + */protectedUserKey: AsymmetricEncString ) case masterKey( /** * Master Key protected by the private key provided in `AuthRequestResponse`. - */ - protectedMasterKey: AsymmetricEncString, + */protectedMasterKey: AsymmetricEncString, /** * User Key protected by the MasterKey, provided by the auth response. - */ - authRequestKey: EncString + */authRequestKey: EncString ) } + public struct FfiConverterTypeAuthRequestMethod: FfiConverterRustBuffer { typealias SwiftType = AuthRequestMethod @@ -5010,13 +6036,10 @@ public struct FfiConverterTypeAuthRequestMethod: FfiConverterRustBuffer { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .userKey( - protectedUserKey: try FfiConverterTypeAsymmetricEncString.read(from: &buf) + case 1: return .userKey(protectedUserKey: try FfiConverterTypeAsymmetricEncString.read(from: &buf) ) - case 2: return .masterKey( - protectedMasterKey: try FfiConverterTypeAsymmetricEncString.read(from: &buf), - authRequestKey: try FfiConverterTypeEncString.read(from: &buf) + case 2: return .masterKey(protectedMasterKey: try FfiConverterTypeAsymmetricEncString.read(from: &buf), authRequestKey: try FfiConverterTypeEncString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -5051,18 +6074,82 @@ public func FfiConverterTypeAuthRequestMethod_lower(_ value: AuthRequestMethod) } + extension AuthRequestMethod: 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 CipherRepromptType { + +public enum CheckUserOptions { + + case requirePresence(Bool + ) + case requireVerification(Verification + ) +} + + +public struct FfiConverterTypeCheckUserOptions: FfiConverterRustBuffer { + typealias SwiftType = CheckUserOptions + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CheckUserOptions { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .requirePresence(try FfiConverterBool.read(from: &buf) + ) + + case 2: return .requireVerification(try FfiConverterTypeVerification.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: CheckUserOptions, into buf: inout [UInt8]) { + switch value { + + + case let .requirePresence(v1): + writeInt(&buf, Int32(1)) + FfiConverterBool.write(v1, into: &buf) + + + case let .requireVerification(v1): + writeInt(&buf, Int32(2)) + FfiConverterTypeVerification.write(v1, into: &buf) + + } + } +} + + +public func FfiConverterTypeCheckUserOptions_lift(_ buf: RustBuffer) throws -> CheckUserOptions { + return try FfiConverterTypeCheckUserOptions.lift(buf) +} + +public func FfiConverterTypeCheckUserOptions_lower(_ value: CheckUserOptions) -> RustBuffer { + return FfiConverterTypeCheckUserOptions.lower(value) +} + + + +extension CheckUserOptions: 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 CipherRepromptType : UInt8 { - case none - case password + case none = 0 + case password = 1 } + public struct FfiConverterTypeCipherRepromptType: FfiConverterRustBuffer { typealias SwiftType = CipherRepromptType @@ -5103,20 +6190,23 @@ public func FfiConverterTypeCipherRepromptType_lower(_ value: CipherRepromptType } + extension CipherRepromptType: 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 CipherType { + +public enum CipherType : UInt8 { - case login - case secureNote - case card - case identity + case login = 1 + case secureNote = 2 + case card = 3 + case identity = 4 } + public struct FfiConverterTypeCipherType: FfiConverterRustBuffer { typealias SwiftType = CipherType @@ -5169,12 +6259,75 @@ public func FfiConverterTypeCipherType_lower(_ value: CipherType) -> RustBuffer } + extension CipherType: 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 ClientData { + + case defaultWithExtraData(androidPackageName: String + ) + case defaultWithCustomHash(hash: Data + ) +} + + +public struct FfiConverterTypeClientData: FfiConverterRustBuffer { + typealias SwiftType = ClientData + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientData { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .defaultWithExtraData(androidPackageName: try FfiConverterString.read(from: &buf) + ) + + case 2: return .defaultWithCustomHash(hash: try FfiConverterData.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ClientData, into buf: inout [UInt8]) { + switch value { + + + case let .defaultWithExtraData(androidPackageName): + writeInt(&buf, Int32(1)) + FfiConverterString.write(androidPackageName, into: &buf) + + + case let .defaultWithCustomHash(hash): + writeInt(&buf, Int32(2)) + FfiConverterData.write(hash, into: &buf) + + } + } +} + + +public func FfiConverterTypeClientData_lift(_ buf: RustBuffer) throws -> ClientData { + return try FfiConverterTypeClientData.lift(buf) +} + +public func FfiConverterTypeClientData_lower(_ value: ClientData) -> RustBuffer { + return FfiConverterTypeClientData.lower(value) +} + + + +extension ClientData: 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 DeviceType { case android @@ -5201,6 +6354,7 @@ public enum DeviceType { case sdk } + public struct FfiConverterTypeDeviceType: FfiConverterRustBuffer { typealias SwiftType = DeviceType @@ -5361,21 +6515,23 @@ public func FfiConverterTypeDeviceType_lower(_ value: DeviceType) -> RustBuffer } + extension DeviceType: 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 ExportFormat { case csv case json - case encryptedJson( - password: String + case encryptedJson(password: SensitiveString ) } + public struct FfiConverterTypeExportFormat: FfiConverterRustBuffer { typealias SwiftType = ExportFormat @@ -5387,8 +6543,7 @@ public struct FfiConverterTypeExportFormat: FfiConverterRustBuffer { case 2: return .json - case 3: return .encryptedJson( - password: try FfiConverterString.read(from: &buf) + case 3: return .encryptedJson(password: try FfiConverterTypeSensitiveString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -5409,7 +6564,7 @@ public struct FfiConverterTypeExportFormat: FfiConverterRustBuffer { case let .encryptedJson(password): writeInt(&buf, Int32(3)) - FfiConverterString.write(password, into: &buf) + FfiConverterTypeSensitiveString.write(password, into: &buf) } } @@ -5425,20 +6580,23 @@ public func FfiConverterTypeExportFormat_lower(_ value: ExportFormat) -> RustBuf } + extension ExportFormat: 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 FieldType { + +public enum FieldType : UInt8 { - case text - case hidden - case boolean - case linked + case text = 0 + case hidden = 1 + case boolean = 2 + case linked = 3 } + public struct FfiConverterTypeFieldType: FfiConverterRustBuffer { typealias SwiftType = FieldType @@ -5491,64 +6649,57 @@ public func FfiConverterTypeFieldType_lower(_ value: FieldType) -> RustBuffer { } + extension FieldType: 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 InitUserCryptoMethod { case password( /** * The user's master password - */ - password: String, + */password: SensitiveString, /** * The user's encrypted symmetric crypto key - */ - userKey: String + */userKey: String ) case decryptedKey( /** * The user's decrypted encryption key, obtained using `get_user_encryption_key` - */ - decryptedUserKey: String + */decryptedUserKey: SensitiveString ) case pin( /** * The user's PIN - */ - pin: String, + */pin: SensitiveString, /** * The user's symmetric crypto key, encrypted with the PIN. Use `derive_pin_key` to obtain * this. - */ - pinProtectedUserKey: EncString + */pinProtectedUserKey: EncString ) case authRequest( /** * Private Key generated by the `crate::auth::new_auth_request`. - */ - requestPrivateKey: String, - method: AuthRequestMethod + */requestPrivateKey: SensitiveString, method: AuthRequestMethod ) case deviceKey( /** * The device's DeviceKey - */ - deviceKey: String, + */deviceKey: SensitiveString, /** * The Device Private Key - */ - protectedDevicePrivateKey: EncString, + */protectedDevicePrivateKey: EncString, /** * The user's symmetric crypto key, encrypted with the Device Key. - */ - deviceProtectedUserKey: AsymmetricEncString + */deviceProtectedUserKey: AsymmetricEncString ) } + public struct FfiConverterTypeInitUserCryptoMethod: FfiConverterRustBuffer { typealias SwiftType = InitUserCryptoMethod @@ -5556,29 +6707,19 @@ public struct FfiConverterTypeInitUserCryptoMethod: FfiConverterRustBuffer { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .password( - password: try FfiConverterString.read(from: &buf), - userKey: try FfiConverterString.read(from: &buf) + case 1: return .password(password: try FfiConverterTypeSensitiveString.read(from: &buf), userKey: try FfiConverterString.read(from: &buf) ) - case 2: return .decryptedKey( - decryptedUserKey: try FfiConverterString.read(from: &buf) + case 2: return .decryptedKey(decryptedUserKey: try FfiConverterTypeSensitiveString.read(from: &buf) ) - case 3: return .pin( - pin: try FfiConverterString.read(from: &buf), - pinProtectedUserKey: try FfiConverterTypeEncString.read(from: &buf) + case 3: return .pin(pin: try FfiConverterTypeSensitiveString.read(from: &buf), pinProtectedUserKey: try FfiConverterTypeEncString.read(from: &buf) ) - case 4: return .authRequest( - requestPrivateKey: try FfiConverterString.read(from: &buf), - method: try FfiConverterTypeAuthRequestMethod.read(from: &buf) + case 4: return .authRequest(requestPrivateKey: try FfiConverterTypeSensitiveString.read(from: &buf), method: try FfiConverterTypeAuthRequestMethod.read(from: &buf) ) - case 5: return .deviceKey( - deviceKey: try FfiConverterString.read(from: &buf), - protectedDevicePrivateKey: try FfiConverterTypeEncString.read(from: &buf), - deviceProtectedUserKey: try FfiConverterTypeAsymmetricEncString.read(from: &buf) + case 5: return .deviceKey(deviceKey: try FfiConverterTypeSensitiveString.read(from: &buf), protectedDevicePrivateKey: try FfiConverterTypeEncString.read(from: &buf), deviceProtectedUserKey: try FfiConverterTypeAsymmetricEncString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -5591,30 +6732,30 @@ public struct FfiConverterTypeInitUserCryptoMethod: FfiConverterRustBuffer { case let .password(password,userKey): writeInt(&buf, Int32(1)) - FfiConverterString.write(password, into: &buf) + FfiConverterTypeSensitiveString.write(password, into: &buf) FfiConverterString.write(userKey, into: &buf) case let .decryptedKey(decryptedUserKey): writeInt(&buf, Int32(2)) - FfiConverterString.write(decryptedUserKey, into: &buf) + FfiConverterTypeSensitiveString.write(decryptedUserKey, into: &buf) case let .pin(pin,pinProtectedUserKey): writeInt(&buf, Int32(3)) - FfiConverterString.write(pin, into: &buf) + FfiConverterTypeSensitiveString.write(pin, into: &buf) FfiConverterTypeEncString.write(pinProtectedUserKey, into: &buf) case let .authRequest(requestPrivateKey,method): writeInt(&buf, Int32(4)) - FfiConverterString.write(requestPrivateKey, into: &buf) + FfiConverterTypeSensitiveString.write(requestPrivateKey, into: &buf) FfiConverterTypeAuthRequestMethod.write(method, into: &buf) case let .deviceKey(deviceKey,protectedDevicePrivateKey,deviceProtectedUserKey): writeInt(&buf, Int32(5)) - FfiConverterString.write(deviceKey, into: &buf) + FfiConverterTypeSensitiveString.write(deviceKey, into: &buf) FfiConverterTypeEncString.write(protectedDevicePrivateKey, into: &buf) FfiConverterTypeAsymmetricEncString.write(deviceProtectedUserKey, into: &buf) @@ -5632,119 +6773,190 @@ public func FfiConverterTypeInitUserCryptoMethod_lower(_ value: InitUserCryptoMe } + extension InitUserCryptoMethod: 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 SecureNoteType { + +public enum SecureNoteType : UInt8 { - case generic + case generic = 0 } + public struct FfiConverterTypeSecureNoteType: FfiConverterRustBuffer { typealias SwiftType = SecureNoteType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SecureNoteType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SecureNoteType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .generic + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: SecureNoteType, into buf: inout [UInt8]) { + switch value { + + + case .generic: + writeInt(&buf, Int32(1)) + + } + } +} + + +public func FfiConverterTypeSecureNoteType_lift(_ buf: RustBuffer) throws -> SecureNoteType { + return try FfiConverterTypeSecureNoteType.lift(buf) +} + +public func FfiConverterTypeSecureNoteType_lower(_ value: SecureNoteType) -> RustBuffer { + return FfiConverterTypeSecureNoteType.lower(value) +} + + + +extension SecureNoteType: 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 SendType : UInt8 { + + case text = 0 + case file = 1 +} + + +public struct FfiConverterTypeSendType: FfiConverterRustBuffer { + typealias SwiftType = SendType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SendType { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .generic + case 1: return .text + + case 2: return .file default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: SecureNoteType, into buf: inout [UInt8]) { + public static func write(_ value: SendType, into buf: inout [UInt8]) { switch value { - case .generic: + case .text: writeInt(&buf, Int32(1)) + + case .file: + writeInt(&buf, Int32(2)) + } } } -public func FfiConverterTypeSecureNoteType_lift(_ buf: RustBuffer) throws -> SecureNoteType { - return try FfiConverterTypeSecureNoteType.lift(buf) +public func FfiConverterTypeSendType_lift(_ buf: RustBuffer) throws -> SendType { + return try FfiConverterTypeSendType.lift(buf) } -public func FfiConverterTypeSecureNoteType_lower(_ value: SecureNoteType) -> RustBuffer { - return FfiConverterTypeSecureNoteType.lower(value) +public func FfiConverterTypeSendType_lower(_ value: SendType) -> RustBuffer { + return FfiConverterTypeSendType.lower(value) } -extension SecureNoteType: Equatable, Hashable {} + +extension SendType: 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 SendType { + +public enum Uv { - case text - case file + case discouraged + case preferred + case required } -public struct FfiConverterTypeSendType: FfiConverterRustBuffer { - typealias SwiftType = SendType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SendType { +public struct FfiConverterTypeUV: FfiConverterRustBuffer { + typealias SwiftType = Uv + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Uv { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .text + case 1: return .discouraged - case 2: return .file + case 2: return .preferred + + case 3: return .required default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: SendType, into buf: inout [UInt8]) { + public static func write(_ value: Uv, into buf: inout [UInt8]) { switch value { - case .text: + case .discouraged: writeInt(&buf, Int32(1)) - case .file: + case .preferred: writeInt(&buf, Int32(2)) + + case .required: + writeInt(&buf, Int32(3)) + } } } -public func FfiConverterTypeSendType_lift(_ buf: RustBuffer) throws -> SendType { - return try FfiConverterTypeSendType.lift(buf) +public func FfiConverterTypeUV_lift(_ buf: RustBuffer) throws -> Uv { + return try FfiConverterTypeUV.lift(buf) } -public func FfiConverterTypeSendType_lower(_ value: SendType) -> RustBuffer { - return FfiConverterTypeSendType.lower(value) +public func FfiConverterTypeUV_lower(_ value: Uv) -> RustBuffer { + return FfiConverterTypeUV.lower(value) } -extension SendType: Equatable, Hashable {} + +extension Uv: 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 UriMatchType { + +public enum UriMatchType : UInt8 { - case domain - case host - case startsWith - case exact - case regularExpression - case never + case domain = 0 + case host = 1 + case startsWith = 2 + case exact = 3 + case regularExpression = 4 + case never = 5 } + public struct FfiConverterTypeUriMatchType: FfiConverterRustBuffer { typealias SwiftType = UriMatchType @@ -5809,10 +7021,73 @@ public func FfiConverterTypeUriMatchType_lower(_ value: UriMatchType) -> RustBuf } + extension UriMatchType: 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 Verification { + + case discouraged + case preferred + case required +} + + +public struct FfiConverterTypeVerification: FfiConverterRustBuffer { + typealias SwiftType = Verification + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Verification { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .discouraged + + case 2: return .preferred + + case 3: return .required + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Verification, into buf: inout [UInt8]) { + switch value { + + + case .discouraged: + writeInt(&buf, Int32(1)) + + + case .preferred: + writeInt(&buf, Int32(2)) + + + case .required: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeVerification_lift(_ buf: RustBuffer) throws -> Verification { + return try FfiConverterTypeVerification.lift(buf) +} + +public func FfiConverterTypeVerification_lower(_ value: Verification) -> RustBuffer { + return FfiConverterTypeVerification.lower(value) +} + + + +extension Verification: Equatable, Hashable {} + + + fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { typealias SwiftType = UInt32? @@ -5876,6 +7151,27 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { } } +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 + } + } +} + fileprivate struct FfiConverterOptionTypeCard: FfiConverterRustBuffer { typealias SwiftType = Card? @@ -6191,6 +7487,27 @@ fileprivate struct FfiConverterOptionTypeUriMatchType: FfiConverterRustBuffer { } } +fileprivate struct FfiConverterOptionSequenceString: 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)) + FfiConverterSequenceString.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 FfiConverterSequenceString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + fileprivate struct FfiConverterOptionSequenceTypeAttachment: FfiConverterRustBuffer { typealias SwiftType = [Attachment]? @@ -6380,6 +7697,48 @@ fileprivate struct FfiConverterOptionSequenceTypePasswordHistoryView: FfiConvert } } +fileprivate struct FfiConverterOptionSequenceTypePublicKeyCredentialDescriptor: FfiConverterRustBuffer { + typealias SwiftType = [PublicKeyCredentialDescriptor]? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterSequenceTypePublicKeyCredentialDescriptor.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 FfiConverterSequenceTypePublicKeyCredentialDescriptor.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionDictionaryStringString: FfiConverterRustBuffer { + typealias SwiftType = [String: 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)) + FfiConverterDictionaryStringString.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 FfiConverterDictionaryStringString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + fileprivate struct FfiConverterOptionTypeEncString: FfiConverterRustBuffer { typealias SwiftType = EncString? @@ -6401,6 +7760,27 @@ fileprivate struct FfiConverterOptionTypeEncString: FfiConverterRustBuffer { } } +fileprivate struct FfiConverterOptionTypeSensitiveString: FfiConverterRustBuffer { + typealias SwiftType = SensitiveString? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeSensitiveString.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 FfiConverterTypeSensitiveString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + fileprivate struct FfiConverterOptionTypeTrustDeviceResponse: FfiConverterRustBuffer { typealias SwiftType = TrustDeviceResponse? @@ -6485,6 +7865,28 @@ fileprivate struct FfiConverterOptionTypeUuid: FfiConverterRustBuffer { } } +fileprivate 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 { + seq.append(try FfiConverterString.read(from: &buf)) + } + return seq + } +} + fileprivate struct FfiConverterSequenceTypeAttachment: FfiConverterRustBuffer { typealias SwiftType = [Attachment] @@ -6683,6 +8085,50 @@ fileprivate struct FfiConverterSequenceTypePasswordHistoryView: FfiConverterRust } } +fileprivate struct FfiConverterSequenceTypePublicKeyCredentialDescriptor: FfiConverterRustBuffer { + typealias SwiftType = [PublicKeyCredentialDescriptor] + + public static func write(_ value: [PublicKeyCredentialDescriptor], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypePublicKeyCredentialDescriptor.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PublicKeyCredentialDescriptor] { + let len: Int32 = try readInt(&buf) + var seq = [PublicKeyCredentialDescriptor]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypePublicKeyCredentialDescriptor.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypePublicKeyCredentialParameters: FfiConverterRustBuffer { + typealias SwiftType = [PublicKeyCredentialParameters] + + public static func write(_ value: [PublicKeyCredentialParameters], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypePublicKeyCredentialParameters.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PublicKeyCredentialParameters] { + let len: Int32 = try readInt(&buf) + var seq = [PublicKeyCredentialParameters]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypePublicKeyCredentialParameters.read(from: &buf)) + } + return seq + } +} + fileprivate struct FfiConverterSequenceTypeUuid: FfiConverterRustBuffer { typealias SwiftType = [Uuid] @@ -6705,6 +8151,52 @@ fileprivate struct FfiConverterSequenceTypeUuid: FfiConverterRustBuffer { } } +fileprivate struct FfiConverterDictionaryStringBool: FfiConverterRustBuffer { + public static func write(_ value: [String: Bool], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for (key, value) in value { + FfiConverterString.write(key, into: &buf) + FfiConverterBool.write(value, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: Bool] { + let len: Int32 = try readInt(&buf) + var dict = [String: Bool]() + dict.reserveCapacity(Int(len)) + for _ in 0.. [String: String] { + let len: Int32 = try readInt(&buf) + var dict = [String: String]() + dict.reserveCapacity(Int(len)) + for _ in 0.. RustBuffer { + RustBuffer(capacity: 0, len:0, data: nil) + } + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { try! rustCall { ffi_bitwarden_crypto_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } } @@ -220,9 +226,17 @@ fileprivate enum UniffiInternalError: LocalizedError { } } +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_PANIC: Int8 = 2 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 fileprivate let CALL_CANCELLED: Int8 = 3 fileprivate extension RustCallStatus { @@ -275,7 +289,7 @@ private func uniffiCheckCallStatus( throw UniffiInternalError.unexpectedRustCallError } - case CALL_PANIC: + 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. @@ -294,6 +308,76 @@ private func uniffiCheckCallStatus( } } +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)) + } +} +fileprivate class UniffiHandleMap { + private var map: [UInt64: T] = [:] + private let lock = NSLock() + private var currentHandle: UInt64 = 1 + + func insert(obj: T) -> UInt64 { + lock.withLock { + let handle = currentHandle + currentHandle += 1 + 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 + } + } + + @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. @@ -369,18 +453,17 @@ public struct RsaKeyPair { public init( /** * Base64 encoded DER representation of the public key - */ - `public`: String, + */`public`: String, /** * Encrypted PKCS8 private key - */ - `private`: EncString) { + */`private`: EncString) { self.`public` = `public` self.`private` = `private` } } + extension RsaKeyPair: Equatable, Hashable { public static func ==(lhs: RsaKeyPair, rhs: RsaKeyPair) -> Bool { if lhs.`public` != rhs.`public` { @@ -424,59 +507,6 @@ public func FfiConverterTypeRsaKeyPair_lower(_ value: RsaKeyPair) -> RustBuffer } -/** - * Uniffi doesn't seem to be generating the SensitiveString unless it's being used by - * a record somewhere. This is a workaround to make sure the type is generated. - */ -public struct SupportSensitiveString { - public let sensitiveString: SensitiveString - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - sensitiveString: SensitiveString) { - self.sensitiveString = sensitiveString - } -} - - -extension SupportSensitiveString: Equatable, Hashable { - public static func ==(lhs: SupportSensitiveString, rhs: SupportSensitiveString) -> Bool { - if lhs.sensitiveString != rhs.sensitiveString { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(sensitiveString) - } -} - - -public struct FfiConverterTypeSupportSensitiveString: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SupportSensitiveString { - return - try SupportSensitiveString( - sensitiveString: FfiConverterTypeSensitiveString.read(from: &buf) - ) - } - - public static func write(_ value: SupportSensitiveString, into buf: inout [UInt8]) { - FfiConverterTypeSensitiveString.write(value.sensitiveString, into: &buf) - } -} - - -public func FfiConverterTypeSupportSensitiveString_lift(_ buf: RustBuffer) throws -> SupportSensitiveString { - return try FfiConverterTypeSupportSensitiveString.lift(buf) -} - -public func FfiConverterTypeSupportSensitiveString_lower(_ value: SupportSensitiveString) -> RustBuffer { - return FfiConverterTypeSupportSensitiveString.lower(value) -} - - public struct TrustDeviceResponse { /** * Base64 encoded device key @@ -500,20 +530,16 @@ public struct TrustDeviceResponse { public init( /** * Base64 encoded device key - */ - deviceKey: SensitiveString, + */deviceKey: SensitiveString, /** * UserKey encrypted with DevicePublicKey - */ - protectedUserKey: AsymmetricEncString, + */protectedUserKey: AsymmetricEncString, /** * DevicePrivateKey encrypted with [DeviceKey] - */ - protectedDevicePrivateKey: EncString, + */protectedDevicePrivateKey: EncString, /** * DevicePublicKey encrypted with [UserKey](super::UserKey) - */ - protectedDevicePublicKey: EncString) { + */protectedDevicePublicKey: EncString) { self.deviceKey = deviceKey self.protectedUserKey = protectedUserKey self.protectedDevicePrivateKey = protectedDevicePrivateKey @@ -522,6 +548,7 @@ public struct TrustDeviceResponse { } + extension TrustDeviceResponse: Equatable, Hashable { public static func ==(lhs: TrustDeviceResponse, rhs: TrustDeviceResponse) -> Bool { if lhs.deviceKey != rhs.deviceKey { @@ -578,12 +605,14 @@ public func FfiConverterTypeTrustDeviceResponse_lower(_ value: TrustDeviceRespon // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + public enum HashPurpose { case serverAuthorization case localAuthorization } + public struct FfiConverterTypeHashPurpose: FfiConverterRustBuffer { typealias SwiftType = HashPurpose @@ -624,24 +653,29 @@ public func FfiConverterTypeHashPurpose_lower(_ value: HashPurpose) -> RustBuffe } + extension HashPurpose: Equatable, Hashable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Key Derivation Function for Bitwarden Account + * + * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This + * Enum represents all the possible KDFs. + */ + public enum Kdf { - case pbkdf2( - iterations: NonZeroU32 + case pbkdf2(iterations: NonZeroU32 ) - case argon2id( - iterations: NonZeroU32, - memory: NonZeroU32, - parallelism: NonZeroU32 + case argon2id(iterations: NonZeroU32, memory: NonZeroU32, parallelism: NonZeroU32 ) } + public struct FfiConverterTypeKdf: FfiConverterRustBuffer { typealias SwiftType = Kdf @@ -649,14 +683,10 @@ public struct FfiConverterTypeKdf: FfiConverterRustBuffer { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .pbkdf2( - iterations: try FfiConverterTypeNonZeroU32.read(from: &buf) + case 1: return .pbkdf2(iterations: try FfiConverterTypeNonZeroU32.read(from: &buf) ) - case 2: return .argon2id( - iterations: try FfiConverterTypeNonZeroU32.read(from: &buf), - memory: try FfiConverterTypeNonZeroU32.read(from: &buf), - parallelism: try FfiConverterTypeNonZeroU32.read(from: &buf) + case 2: return .argon2id(iterations: try FfiConverterTypeNonZeroU32.read(from: &buf), memory: try FfiConverterTypeNonZeroU32.read(from: &buf), parallelism: try FfiConverterTypeNonZeroU32.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -692,6 +722,7 @@ public func FfiConverterTypeKdf_lower(_ value: Kdf) -> RustBuffer { } + extension Kdf: Equatable, Hashable {} @@ -841,7 +872,7 @@ private enum InitializationResult { // the code inside is only computed once. private var initializationResult: InitializationResult { // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 25 + let bindings_contract_version = 26 // Get the scaffolding contract version by calling the into the dylib let scaffolding_contract_version = ffi_bitwarden_crypto_uniffi_contract_version() if bindings_contract_version != scaffolding_contract_version { @@ -860,4 +891,6 @@ private func uniffiEnsureInitialized() { case .apiChecksumMismatch: fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } -} \ No newline at end of file +} + +// swiftlint:enable all \ No newline at end of file diff --git a/Sources/BitwardenSdk/BitwardenGenerators.swift b/Sources/BitwardenSdk/BitwardenGenerators.swift index 4763e74..11035ef 100644 --- a/Sources/BitwardenSdk/BitwardenGenerators.swift +++ b/Sources/BitwardenSdk/BitwardenGenerators.swift @@ -1,5 +1,7 @@ // 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 @@ -18,6 +20,10 @@ fileprivate extension RustBuffer { 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_bitwarden_generators_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } } @@ -220,9 +226,17 @@ fileprivate enum UniffiInternalError: LocalizedError { } } +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_PANIC: Int8 = 2 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 fileprivate let CALL_CANCELLED: Int8 = 3 fileprivate extension RustCallStatus { @@ -275,7 +289,7 @@ private func uniffiCheckCallStatus( throw UniffiInternalError.unexpectedRustCallError } - case CALL_PANIC: + 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. @@ -294,6 +308,76 @@ private func uniffiCheckCallStatus( } } +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)) + } +} +fileprivate class UniffiHandleMap { + private var map: [UInt64: T] = [:] + private let lock = NSLock() + private var currentHandle: UInt64 = 1 + + func insert(obj: T) -> UInt64 { + lock.withLock { + let handle = currentHandle + currentHandle += 1 + 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 + } + } + + @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. @@ -399,21 +483,17 @@ public struct PassphraseGeneratorRequest { /** * Number of words in the generated passphrase. * This value must be between 3 and 20. - */ - numWords: UInt8, + */numWords: UInt8, /** * Character separator between words in the generated passphrase. The value cannot be empty. - */ - wordSeparator: String, + */wordSeparator: String, /** * When set to true, capitalize the first letter of each word in the generated passphrase. - */ - capitalize: Bool, + */capitalize: Bool, /** * When set to true, include a number at the end of one of the words in the generated * passphrase. - */ - includeNumber: Bool) { + */includeNumber: Bool) { self.numWords = numWords self.wordSeparator = wordSeparator self.capitalize = capitalize @@ -422,6 +502,7 @@ public struct PassphraseGeneratorRequest { } + extension PassphraseGeneratorRequest: Equatable, Hashable { public static func ==(lhs: PassphraseGeneratorRequest, rhs: PassphraseGeneratorRequest) -> Bool { if lhs.numWords != rhs.numWords { @@ -533,50 +614,40 @@ public struct PasswordGeneratorRequest { public init( /** * Include lowercase characters (a-z). - */ - lowercase: Bool, + */lowercase: Bool, /** * Include uppercase characters (A-Z). - */ - uppercase: Bool, + */uppercase: Bool, /** * Include numbers (0-9). - */ - numbers: Bool, + */numbers: Bool, /** * Include special characters: ! @ # $ % ^ & * - */ - special: Bool, + */special: Bool, /** * The length of the generated password. * Note that the password length must be greater than the sum of all the minimums. - */ - length: UInt8, + */length: UInt8, /** * When set to true, the generated password will not contain ambiguous characters. * The ambiguous characters are: I, O, l, 0, 1 - */ - avoidAmbiguous: Bool, + */avoidAmbiguous: Bool, /** * The minimum number of lowercase characters in the generated password. * When set, the value must be between 1 and 9. This value is ignored is lowercase is false - */ - minLowercase: UInt8?, + */minLowercase: UInt8?, /** * The minimum number of uppercase characters in the generated password. * When set, the value must be between 1 and 9. This value is ignored is uppercase is false - */ - minUppercase: UInt8?, + */minUppercase: UInt8?, /** * The minimum number of numbers in the generated password. * When set, the value must be between 1 and 9. This value is ignored is numbers is false - */ - minNumber: UInt8?, + */minNumber: UInt8?, /** * The minimum number of special characters in the generated password. * When set, the value must be between 1 and 9. This value is ignored is special is false - */ - minSpecial: UInt8?) { + */minSpecial: UInt8?) { self.lowercase = lowercase self.uppercase = uppercase self.numbers = numbers @@ -591,6 +662,7 @@ public struct PasswordGeneratorRequest { } + extension PasswordGeneratorRequest: Equatable, Hashable { public static func ==(lhs: PasswordGeneratorRequest, rhs: PasswordGeneratorRequest) -> Bool { if lhs.lowercase != rhs.lowercase { @@ -683,6 +755,7 @@ public func FfiConverterTypePasswordGeneratorRequest_lower(_ value: PasswordGene // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + public enum AppendType { /** @@ -692,11 +765,11 @@ public enum AppendType { /** * Uses the websitename as part of your username */ - case websiteName( - website: String + case websiteName(website: String ) } + public struct FfiConverterTypeAppendType: FfiConverterRustBuffer { typealias SwiftType = AppendType @@ -706,8 +779,7 @@ public struct FfiConverterTypeAppendType: FfiConverterRustBuffer { case 1: return .random - case 2: return .websiteName( - website: try FfiConverterString.read(from: &buf) + case 2: return .websiteName(website: try FfiConverterString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -740,6 +812,7 @@ public func FfiConverterTypeAppendType_lower(_ value: AppendType) -> RustBuffer } + extension AppendType: Equatable, Hashable {} @@ -751,34 +824,27 @@ extension AppendType: Equatable, Hashable {} * For instructions on how to configure each service, see the documentation: * */ + public enum ForwarderServiceType { /** * Previously known as "AnonAddy" */ - case addyIo( - apiToken: String, - domain: String, - baseUrl: String + case addyIo(apiToken: String, domain: String, baseUrl: String ) - case duckDuckGo( - token: String + case duckDuckGo(token: String ) - case firefox( - apiToken: String + case firefox(apiToken: String ) - case fastmail( - apiToken: String + case fastmail(apiToken: String ) - case forwardEmail( - apiToken: String, - domain: String + case forwardEmail(apiToken: String, domain: String ) - case simpleLogin( - apiKey: String + case simpleLogin(apiKey: String ) } + public struct FfiConverterTypeForwarderServiceType: FfiConverterRustBuffer { typealias SwiftType = ForwarderServiceType @@ -786,31 +852,22 @@ public struct FfiConverterTypeForwarderServiceType: FfiConverterRustBuffer { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .addyIo( - apiToken: try FfiConverterString.read(from: &buf), - domain: try FfiConverterString.read(from: &buf), - baseUrl: try FfiConverterString.read(from: &buf) + case 1: return .addyIo(apiToken: try FfiConverterString.read(from: &buf), domain: try FfiConverterString.read(from: &buf), baseUrl: try FfiConverterString.read(from: &buf) ) - case 2: return .duckDuckGo( - token: try FfiConverterString.read(from: &buf) + case 2: return .duckDuckGo(token: try FfiConverterString.read(from: &buf) ) - case 3: return .firefox( - apiToken: try FfiConverterString.read(from: &buf) + case 3: return .firefox(apiToken: try FfiConverterString.read(from: &buf) ) - case 4: return .fastmail( - apiToken: try FfiConverterString.read(from: &buf) + case 4: return .fastmail(apiToken: try FfiConverterString.read(from: &buf) ) - case 5: return .forwardEmail( - apiToken: try FfiConverterString.read(from: &buf), - domain: try FfiConverterString.read(from: &buf) + case 5: return .forwardEmail(apiToken: try FfiConverterString.read(from: &buf), domain: try FfiConverterString.read(from: &buf) ) - case 6: return .simpleLogin( - apiKey: try FfiConverterString.read(from: &buf) + case 6: return .simpleLogin(apiKey: try FfiConverterString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -867,12 +924,14 @@ public func FfiConverterTypeForwarderServiceType_lower(_ value: ForwarderService } + extension ForwarderServiceType: 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 UsernameGeneratorRequest { /** @@ -881,12 +940,10 @@ public enum UsernameGeneratorRequest { case word( /** * Capitalize the first letter of the word - */ - capitalize: Bool, + */capitalize: Bool, /** * Include a 4 digit number at the end of the word - */ - includeNumber: Bool + */includeNumber: Bool ) /** * Generates an email using your provider's subaddressing capabilities. @@ -896,37 +953,32 @@ public enum UsernameGeneratorRequest { case subaddress( /** * The type of subaddress to add to the base email - */ - type: AppendType, + */type: AppendType, /** * The full email address to use as the base for the subaddress - */ - email: String + */email: String ) case catchall( /** * The type of username to use with the catchall email domain - */ - type: AppendType, + */type: AppendType, /** * The domain to use for the catchall email address - */ - domain: String + */domain: String ) case forwarded( /** * The email forwarding service to use, see [ForwarderServiceType] * for instructions on how to configure each - */ - service: ForwarderServiceType, + */service: ForwarderServiceType, /** * The website for which the email address is being generated * This is not used in all services, and is only used for display purposes - */ - website: String? + */website: String? ) } + public struct FfiConverterTypeUsernameGeneratorRequest: FfiConverterRustBuffer { typealias SwiftType = UsernameGeneratorRequest @@ -934,24 +986,16 @@ public struct FfiConverterTypeUsernameGeneratorRequest: FfiConverterRustBuffer { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .word( - capitalize: try FfiConverterBool.read(from: &buf), - includeNumber: try FfiConverterBool.read(from: &buf) + case 1: return .word(capitalize: try FfiConverterBool.read(from: &buf), includeNumber: try FfiConverterBool.read(from: &buf) ) - case 2: return .subaddress( - type: try FfiConverterTypeAppendType.read(from: &buf), - email: try FfiConverterString.read(from: &buf) + case 2: return .subaddress(type: try FfiConverterTypeAppendType.read(from: &buf), email: try FfiConverterString.read(from: &buf) ) - case 3: return .catchall( - type: try FfiConverterTypeAppendType.read(from: &buf), - domain: try FfiConverterString.read(from: &buf) + case 3: return .catchall(type: try FfiConverterTypeAppendType.read(from: &buf), domain: try FfiConverterString.read(from: &buf) ) - case 4: return .forwarded( - service: try FfiConverterTypeForwarderServiceType.read(from: &buf), - website: try FfiConverterOptionString.read(from: &buf) + case 4: return .forwarded(service: try FfiConverterTypeForwarderServiceType.read(from: &buf), website: try FfiConverterOptionString.read(from: &buf) ) default: throw UniffiInternalError.unexpectedEnumCase @@ -999,6 +1043,7 @@ public func FfiConverterTypeUsernameGeneratorRequest_lower(_ value: UsernameGene } + extension UsernameGeneratorRequest: Equatable, Hashable {} @@ -1054,7 +1099,7 @@ private enum InitializationResult { // the code inside is only computed once. private var initializationResult: InitializationResult { // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 25 + let bindings_contract_version = 26 // Get the scaffolding contract version by calling the into the dylib let scaffolding_contract_version = ffi_bitwarden_generators_uniffi_contract_version() if bindings_contract_version != scaffolding_contract_version { @@ -1073,4 +1118,6 @@ private func uniffiEnsureInitialized() { case .apiChecksumMismatch: fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } -} \ No newline at end of file +} + +// swiftlint:enable all \ No newline at end of file diff --git a/Sources/BitwardenSdk/BitwardenSDK.swift b/Sources/BitwardenSdk/BitwardenSDK.swift index 4e5a0ae..12091d2 100644 --- a/Sources/BitwardenSdk/BitwardenSDK.swift +++ b/Sources/BitwardenSdk/BitwardenSDK.swift @@ -1,5 +1,7 @@ // 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 @@ -18,6 +20,10 @@ fileprivate extension RustBuffer { 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_bitwarden_uniffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } } @@ -220,9 +226,17 @@ fileprivate enum UniffiInternalError: LocalizedError { } } +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_PANIC: Int8 = 2 +fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2 fileprivate let CALL_CANCELLED: Int8 = 3 fileprivate extension RustCallStatus { @@ -275,7 +289,7 @@ private func uniffiCheckCallStatus( throw UniffiInternalError.unexpectedRustCallError } - case CALL_PANIC: + 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. @@ -294,6 +308,76 @@ private func uniffiCheckCallStatus( } } +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)) + } +} +fileprivate class UniffiHandleMap { + private var map: [UInt64: T] = [:] + private let lock = NSLock() + private var currentHandle: UInt64 = 1 + + func insert(obj: T) -> UInt64 { + lock.withLock { + let handle = currentHandle + currentHandle += 1 + 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 + } + } + + @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. @@ -423,127 +507,126 @@ public protocol ClientProtocol : AnyObject { } -public class Client: +open class Client: ClientProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_client(self.pointer, $0) } } /** * Initialize a new instance of the SDK client */ - public convenience init(settings: ClientSettings?) { - self.init(unsafeFromRawPointer: try! rustCall() { +public convenience init(settings: ClientSettings?) { + let pointer = + try! rustCall() { uniffi_bitwarden_uniffi_fn_constructor_client_new( - FfiConverterOptionTypeClientSettings.lower(settings),$0) -}) - } + FfiConverterOptionTypeClientSettings.lower(settings),$0 + ) +} + self.init(unsafeFromRawPointer: pointer) +} deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_client(pointer, $0) } } - /** * Auth operations */ - public func auth() -> ClientAuth { - return try! FfiConverterTypeClientAuth.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_client_auth(self.uniffiClonePointer(), $0 +open func auth() -> ClientAuth { + return try! FfiConverterTypeClientAuth.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_auth(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Crypto operations */ - public func crypto() -> ClientCrypto { - return try! FfiConverterTypeClientCrypto.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_client_crypto(self.uniffiClonePointer(), $0 +open func crypto() -> ClientCrypto { + return try! FfiConverterTypeClientCrypto.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_crypto(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Test method, echoes back the input */ - public func echo(msg: String) -> String { - return try! FfiConverterString.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_client_echo(self.uniffiClonePointer(), +open func echo(msg: String) -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_echo(self.uniffiClonePointer(), FfiConverterString.lower(msg),$0 ) +}) } - ) - } + /** * Exporters */ - public func exporters() -> ClientExporters { - return try! FfiConverterTypeClientExporters.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_client_exporters(self.uniffiClonePointer(), $0 +open func exporters() -> ClientExporters { + return try! FfiConverterTypeClientExporters.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_exporters(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Generator operations */ - public func generators() -> ClientGenerators { - return try! FfiConverterTypeClientGenerators.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_client_generators(self.uniffiClonePointer(), $0 +open func generators() -> ClientGenerators { + return try! FfiConverterTypeClientGenerators.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_generators(self.uniffiClonePointer(),$0 ) +}) } - ) - } - public func platform() -> ClientPlatform { - return try! FfiConverterTypeClientPlatform.lift( - try! - rustCall() { - uniffi_bitwarden_uniffi_fn_method_client_platform(self.uniffiClonePointer(), $0 +open func platform() -> ClientPlatform { + return try! FfiConverterTypeClientPlatform.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_platform(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Vault item operations */ - public func vault() -> ClientVault { - return try! FfiConverterTypeClientVault.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_client_vault(self.uniffiClonePointer(), $0 +open func vault() -> ClientVault { + return try! FfiConverterTypeClientVault.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_client_vault(self.uniffiClonePointer(),$0 ) +}) } - ) - } + } @@ -579,6 +662,8 @@ public struct FfiConverterTypeClient: FfiConverter { } + + public func FfiConverterTypeClient_lift(_ pointer: UnsafeMutableRawPointer) throws -> Client { return try FfiConverterTypeClient.lift(pointer) } @@ -614,40 +699,57 @@ public protocol ClientAttachmentsProtocol : AnyObject { } -public class ClientAttachments: +open class ClientAttachments: ClientAttachmentsProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientattachments(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientattachments(pointer, $0) } } - /** * Decrypt an attachment file in memory */ - public func decryptBuffer(cipher: Cipher, attachment: Attachment, buffer: Data) async throws -> Data { - return try await uniffiRustCallAsync( +open func decryptBuffer(cipher: Cipher, attachment: Attachment, buffer: Data)async throws -> Data { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientattachments_decrypt_buffer( self.uniffiClonePointer(), - FfiConverterTypeCipher_lower(cipher), - FfiConverterTypeAttachment_lower(attachment), - FfiConverterData.lower(buffer) + FfiConverterTypeCipher_lower(cipher),FfiConverterTypeAttachment_lower(attachment),FfiConverterData.lower(buffer) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -656,21 +758,18 @@ public class ClientAttachments: liftFunc: FfiConverterData.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Decrypt an attachment file located in the file system */ - public func decryptFile(cipher: Cipher, attachment: Attachment, encryptedFilePath: String, decryptedFilePath: String) async throws { - return try await uniffiRustCallAsync( +open func decryptFile(cipher: Cipher, attachment: Attachment, encryptedFilePath: String, decryptedFilePath: String)async throws { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientattachments_decrypt_file( self.uniffiClonePointer(), - FfiConverterTypeCipher_lower(cipher), - FfiConverterTypeAttachment_lower(attachment), - FfiConverterString.lower(encryptedFilePath), - FfiConverterString.lower(decryptedFilePath) + FfiConverterTypeCipher_lower(cipher),FfiConverterTypeAttachment_lower(attachment),FfiConverterString.lower(encryptedFilePath),FfiConverterString.lower(decryptedFilePath) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_void, @@ -679,20 +778,18 @@ public class ClientAttachments: liftFunc: { $0 }, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Encrypt an attachment file in memory */ - public func encryptBuffer(cipher: Cipher, attachment: AttachmentView, buffer: Data) async throws -> AttachmentEncryptResult { - return try await uniffiRustCallAsync( +open func encryptBuffer(cipher: Cipher, attachment: AttachmentView, buffer: Data)async throws -> AttachmentEncryptResult { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientattachments_encrypt_buffer( self.uniffiClonePointer(), - FfiConverterTypeCipher_lower(cipher), - FfiConverterTypeAttachmentView_lower(attachment), - FfiConverterData.lower(buffer) + FfiConverterTypeCipher_lower(cipher),FfiConverterTypeAttachmentView_lower(attachment),FfiConverterData.lower(buffer) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -701,21 +798,18 @@ public class ClientAttachments: liftFunc: FfiConverterTypeAttachmentEncryptResult_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Encrypt an attachment file located in the file system */ - public func encryptFile(cipher: Cipher, attachment: AttachmentView, decryptedFilePath: String, encryptedFilePath: String) async throws -> Attachment { - return try await uniffiRustCallAsync( +open func encryptFile(cipher: Cipher, attachment: AttachmentView, decryptedFilePath: String, encryptedFilePath: String)async throws -> Attachment { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientattachments_encrypt_file( self.uniffiClonePointer(), - FfiConverterTypeCipher_lower(cipher), - FfiConverterTypeAttachmentView_lower(attachment), - FfiConverterString.lower(decryptedFilePath), - FfiConverterString.lower(encryptedFilePath) + FfiConverterTypeCipher_lower(cipher),FfiConverterTypeAttachmentView_lower(attachment),FfiConverterString.lower(decryptedFilePath),FfiConverterString.lower(encryptedFilePath) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -724,8 +818,7 @@ public class ClientAttachments: liftFunc: FfiConverterTypeAttachment_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -762,6 +855,8 @@ public struct FfiConverterTypeClientAttachments: FfiConverter { } + + public func FfiConverterTypeClientAttachments_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientAttachments { return try FfiConverterTypeClientAttachments.lift(pointer) } @@ -783,12 +878,12 @@ public protocol ClientAuthProtocol : AnyObject { /** * Hash the user password */ - func hashPassword(email: String, password: String, kdfParams: Kdf, purpose: HashPurpose) async throws -> String + func hashPassword(email: String, password: SensitiveString, kdfParams: Kdf, purpose: HashPurpose) async throws -> SensitiveString /** * Generate keys needed for registration process */ - func makeRegisterKeys(email: String, password: String, kdf: Kdf) async throws -> RegisterKeyResponse + func makeRegisterKeys(email: String, password: SensitiveString, kdf: Kdf) async throws -> RegisterKeyResponse /** * Generate keys needed for TDE process @@ -803,12 +898,12 @@ public protocol ClientAuthProtocol : AnyObject { /** * **API Draft:** Calculate Password Strength */ - func passwordStrength(password: String, email: String, additionalInputs: [String]) async -> UInt8 + func passwordStrength(password: SensitiveString, email: String, additionalInputs: [String]) async -> UInt8 /** * Evaluate if the provided password satisfies the provided policy */ - func satisfiesPolicy(password: String, strength: UInt8, policy: MasterPasswordPolicyOptions) async -> Bool + func satisfiesPolicy(password: SensitiveString, strength: UInt8, policy: MasterPasswordPolicyOptions) async -> Bool /** * Trust the current device @@ -822,7 +917,7 @@ public protocol ClientAuthProtocol : AnyObject { * `HashPurpose::LocalAuthentication` during login and persist it. If the login method has no * password, use the email OTP. */ - func validatePassword(password: String, passwordHash: String) async throws -> Bool + func validatePassword(password: SensitiveString, passwordHash: SensitiveString) async throws -> Bool /** * Validate the user password without knowing the password hash @@ -832,38 +927,57 @@ public protocol ClientAuthProtocol : AnyObject { * * This works by comparing the provided password against the encrypted user key. */ - func validatePasswordUserKey(password: String, encryptedUserKey: String) async throws -> String + func validatePasswordUserKey(password: SensitiveString, encryptedUserKey: String) async throws -> SensitiveString } -public class ClientAuth: +open class ClientAuth: ClientAuthProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientauth(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientauth(pointer, $0) } } - /** * Approve an auth request */ - public func approveAuthRequest(publicKey: String) async throws -> AsymmetricEncString { - return try await uniffiRustCallAsync( +open func approveAuthRequest(publicKey: String)async throws -> AsymmetricEncString { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_approve_auth_request( self.uniffiClonePointer(), @@ -876,43 +990,38 @@ public class ClientAuth: liftFunc: FfiConverterTypeAsymmetricEncString_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Hash the user password */ - public func hashPassword(email: String, password: String, kdfParams: Kdf, purpose: HashPurpose) async throws -> String { - return try await uniffiRustCallAsync( +open func hashPassword(email: String, password: SensitiveString, kdfParams: Kdf, purpose: HashPurpose)async throws -> SensitiveString { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_hash_password( self.uniffiClonePointer(), - FfiConverterString.lower(email), - FfiConverterString.lower(password), - FfiConverterTypeKdf_lower(kdfParams), - FfiConverterTypeHashPurpose_lower(purpose) + FfiConverterString.lower(email),FfiConverterTypeSensitiveString_lower(password),FfiConverterTypeKdf_lower(kdfParams),FfiConverterTypeHashPurpose_lower(purpose) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterTypeSensitiveString_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Generate keys needed for registration process */ - public func makeRegisterKeys(email: String, password: String, kdf: Kdf) async throws -> RegisterKeyResponse { - return try await uniffiRustCallAsync( +open func makeRegisterKeys(email: String, password: SensitiveString, kdf: Kdf)async throws -> RegisterKeyResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_make_register_keys( self.uniffiClonePointer(), - FfiConverterString.lower(email), - FfiConverterString.lower(password), - FfiConverterTypeKdf_lower(kdf) + FfiConverterString.lower(email),FfiConverterTypeSensitiveString_lower(password),FfiConverterTypeKdf_lower(kdf) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -921,20 +1030,18 @@ public class ClientAuth: liftFunc: FfiConverterTypeRegisterKeyResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Generate keys needed for TDE process */ - public func makeRegisterTdeKeys(email: String, orgPublicKey: String, rememberDevice: Bool) async throws -> RegisterTdeKeyResponse { - return try await uniffiRustCallAsync( +open func makeRegisterTdeKeys(email: String, orgPublicKey: String, rememberDevice: Bool)async throws -> RegisterTdeKeyResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_make_register_tde_keys( self.uniffiClonePointer(), - FfiConverterString.lower(email), - FfiConverterString.lower(orgPublicKey), - FfiConverterBool.lower(rememberDevice) + FfiConverterString.lower(email),FfiConverterString.lower(orgPublicKey),FfiConverterBool.lower(rememberDevice) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -943,14 +1050,14 @@ public class ClientAuth: liftFunc: FfiConverterTypeRegisterTdeKeyResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Initialize a new auth request */ - public func newAuthRequest(email: String) async throws -> AuthRequestResponse { - return try await uniffiRustCallAsync( +open func newAuthRequest(email: String)async throws -> AuthRequestResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_new_auth_request( self.uniffiClonePointer(), @@ -963,20 +1070,18 @@ public class ClientAuth: liftFunc: FfiConverterTypeAuthRequestResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * **API Draft:** Calculate Password Strength */ - public func passwordStrength(password: String, email: String, additionalInputs: [String]) async -> UInt8 { - return try! await uniffiRustCallAsync( +open func passwordStrength(password: SensitiveString, email: String, additionalInputs: [String])async -> UInt8 { + return + try! await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_password_strength( self.uniffiClonePointer(), - FfiConverterString.lower(password), - FfiConverterString.lower(email), - FfiConverterSequenceString.lower(additionalInputs) + FfiConverterTypeSensitiveString_lower(password),FfiConverterString.lower(email),FfiConverterSequenceString.lower(additionalInputs) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_u8, @@ -986,20 +1091,18 @@ public class ClientAuth: errorHandler: nil ) - } - +} /** * Evaluate if the provided password satisfies the provided policy */ - public func satisfiesPolicy(password: String, strength: UInt8, policy: MasterPasswordPolicyOptions) async -> Bool { - return try! await uniffiRustCallAsync( +open func satisfiesPolicy(password: SensitiveString, strength: UInt8, policy: MasterPasswordPolicyOptions)async -> Bool { + return + try! await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_satisfies_policy( self.uniffiClonePointer(), - FfiConverterString.lower(password), - FfiConverterUInt8.lower(strength), - FfiConverterTypeMasterPasswordPolicyOptions_lower(policy) + FfiConverterTypeSensitiveString_lower(password),FfiConverterUInt8.lower(strength),FfiConverterTypeMasterPasswordPolicyOptions_lower(policy) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_i8, @@ -1009,17 +1112,18 @@ public class ClientAuth: errorHandler: nil ) - } - +} /** * Trust the current device */ - public func trustDevice() async throws -> TrustDeviceResponse { - return try await uniffiRustCallAsync( +open func trustDevice()async throws -> TrustDeviceResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_trust_device( self.uniffiClonePointer() + ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1028,8 +1132,7 @@ public class ClientAuth: liftFunc: FfiConverterTypeTrustDeviceResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Validate the user password @@ -1038,13 +1141,13 @@ public class ClientAuth: * `HashPurpose::LocalAuthentication` during login and persist it. If the login method has no * password, use the email OTP. */ - public func validatePassword(password: String, passwordHash: String) async throws -> Bool { - return try await uniffiRustCallAsync( +open func validatePassword(password: SensitiveString, passwordHash: SensitiveString)async throws -> Bool { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_validate_password( self.uniffiClonePointer(), - FfiConverterString.lower(password), - FfiConverterString.lower(passwordHash) + FfiConverterTypeSensitiveString_lower(password),FfiConverterTypeSensitiveString_lower(passwordHash) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_i8, @@ -1053,8 +1156,7 @@ public class ClientAuth: liftFunc: FfiConverterBool.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Validate the user password without knowing the password hash @@ -1064,23 +1166,22 @@ public class ClientAuth: * * This works by comparing the provided password against the encrypted user key. */ - public func validatePasswordUserKey(password: String, encryptedUserKey: String) async throws -> String { - return try await uniffiRustCallAsync( +open func validatePasswordUserKey(password: SensitiveString, encryptedUserKey: String)async throws -> SensitiveString { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientauth_validate_password_user_key( self.uniffiClonePointer(), - FfiConverterString.lower(password), - FfiConverterString.lower(encryptedUserKey) + FfiConverterTypeSensitiveString_lower(password),FfiConverterString.lower(encryptedUserKey) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterTypeSensitiveString_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -1117,6 +1218,8 @@ public struct FfiConverterTypeClientAuth: FfiConverter { } + + public func FfiConverterTypeClientAuth_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientAuth { return try FfiConverterTypeClientAuth.lift(pointer) } @@ -1152,34 +1255,53 @@ public protocol ClientCiphersProtocol : AnyObject { } -public class ClientCiphers: +open class ClientCiphers: ClientCiphersProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientciphers(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientciphers(pointer, $0) } } - /** * Decrypt cipher */ - public func decrypt(cipher: Cipher) async throws -> CipherView { - return try await uniffiRustCallAsync( +open func decrypt(cipher: Cipher)async throws -> CipherView { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientciphers_decrypt( self.uniffiClonePointer(), @@ -1192,14 +1314,14 @@ public class ClientCiphers: liftFunc: FfiConverterTypeCipherView_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Decrypt cipher list */ - public func decryptList(ciphers: [Cipher]) async throws -> [CipherListView] { - return try await uniffiRustCallAsync( +open func decryptList(ciphers: [Cipher])async throws -> [CipherListView] { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientciphers_decrypt_list( self.uniffiClonePointer(), @@ -1212,14 +1334,14 @@ public class ClientCiphers: liftFunc: FfiConverterSequenceTypeCipherListView.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Encrypt cipher */ - public func encrypt(cipherView: CipherView) async throws -> Cipher { - return try await uniffiRustCallAsync( +open func encrypt(cipherView: CipherView)async throws -> Cipher { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientciphers_encrypt( self.uniffiClonePointer(), @@ -1232,19 +1354,18 @@ public class ClientCiphers: liftFunc: FfiConverterTypeCipher_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Move a cipher to an organization, reencrypting the cipher key if necessary */ - public func moveToOrganization(cipher: CipherView, organizationId: Uuid) async throws -> CipherView { - return try await uniffiRustCallAsync( +open func moveToOrganization(cipher: CipherView, organizationId: Uuid)async throws -> CipherView { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientciphers_move_to_organization( self.uniffiClonePointer(), - FfiConverterTypeCipherView_lower(cipher), - FfiConverterTypeUuid_lower(organizationId) + FfiConverterTypeCipherView_lower(cipher),FfiConverterTypeUuid_lower(organizationId) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1253,8 +1374,7 @@ public class ClientCiphers: liftFunc: FfiConverterTypeCipherView_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -1291,6 +1411,8 @@ public struct FfiConverterTypeClientCiphers: FfiConverter { } + + public func FfiConverterTypeClientCiphers_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientCiphers { return try FfiConverterTypeClientCiphers.lift(pointer) } @@ -1316,34 +1438,53 @@ public protocol ClientCollectionsProtocol : AnyObject { } -public class ClientCollections: +open class ClientCollections: ClientCollectionsProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientcollections(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientcollections(pointer, $0) } } - /** * Decrypt collection */ - public func decrypt(collection: Collection) async throws -> CollectionView { - return try await uniffiRustCallAsync( +open func decrypt(collection: Collection)async throws -> CollectionView { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcollections_decrypt( self.uniffiClonePointer(), @@ -1356,14 +1497,14 @@ public class ClientCollections: liftFunc: FfiConverterTypeCollectionView_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Decrypt collection list */ - public func decryptList(collections: [Collection]) async throws -> [CollectionView] { - return try await uniffiRustCallAsync( +open func decryptList(collections: [Collection])async throws -> [CollectionView] { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcollections_decrypt_list( self.uniffiClonePointer(), @@ -1376,8 +1517,7 @@ public class ClientCollections: liftFunc: FfiConverterSequenceTypeCollectionView.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -1414,6 +1554,8 @@ public struct FfiConverterTypeClientCollections: FfiConverter { } + + public func FfiConverterTypeClientCollections_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientCollections { return try FfiConverterTypeClientCollections.lift(pointer) } @@ -1432,7 +1574,7 @@ public protocol ClientCryptoProtocol : AnyObject { * used to initialize another client instance by using the PIN and the PIN key with * `initialize_user_crypto`. */ - func derivePinKey(pin: String) async throws -> DerivePinKeyResponse + func derivePinKey(pin: SensitiveString) async throws -> DerivePinKeyResponse /** * Derives the pin protected user key from encrypted pin. Used when pin requires master @@ -1464,44 +1606,63 @@ public protocol ClientCryptoProtocol : AnyObject { * Update the user's password, which will re-encrypt the user's encryption key with the new * password. This returns the new encrypted user key and the new password hash. */ - func updatePassword(newPassword: String) async throws -> UpdatePasswordResponse + func updatePassword(newPassword: SensitiveString) async throws -> UpdatePasswordResponse } -public class ClientCrypto: +open class ClientCrypto: ClientCryptoProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientcrypto(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientcrypto(pointer, $0) } } - /** * Generates a PIN protected user key from the provided PIN. The result can be stored and later * used to initialize another client instance by using the PIN and the PIN key with * `initialize_user_crypto`. */ - public func derivePinKey(pin: String) async throws -> DerivePinKeyResponse { - return try await uniffiRustCallAsync( +open func derivePinKey(pin: SensitiveString)async throws -> DerivePinKeyResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_derive_pin_key( self.uniffiClonePointer(), - FfiConverterString.lower(pin) + FfiConverterTypeSensitiveString_lower(pin) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1510,15 +1671,15 @@ public class ClientCrypto: liftFunc: FfiConverterTypeDerivePinKeyResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Derives the pin protected user key from encrypted pin. Used when pin requires master * password on first unlock. */ - public func derivePinUserKey(encryptedPin: EncString) async throws -> EncString { - return try await uniffiRustCallAsync( +open func derivePinUserKey(encryptedPin: EncString)async throws -> EncString { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_derive_pin_user_key( self.uniffiClonePointer(), @@ -1531,11 +1692,11 @@ public class ClientCrypto: liftFunc: FfiConverterTypeEncString_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} - public func enrollAdminPasswordReset(publicKey: String) async throws -> AsymmetricEncString { - return try await uniffiRustCallAsync( +open func enrollAdminPasswordReset(publicKey: String)async throws -> AsymmetricEncString { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_enroll_admin_password_reset( self.uniffiClonePointer(), @@ -1548,18 +1709,19 @@ public class ClientCrypto: liftFunc: FfiConverterTypeAsymmetricEncString_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Get the uses's decrypted encryption key. Note: It's very important * to keep this key safe, as it can be used to decrypt all of the user's data */ - public func getUserEncryptionKey() async throws -> SensitiveString { - return try await uniffiRustCallAsync( +open func getUserEncryptionKey()async throws -> SensitiveString { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_get_user_encryption_key( self.uniffiClonePointer() + ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1568,15 +1730,15 @@ public class ClientCrypto: liftFunc: FfiConverterTypeSensitiveString_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Initialization method for the organization crypto. Needs to be called after * `initialize_user_crypto` but before any other crypto operations. */ - public func initializeOrgCrypto(req: InitOrgCryptoRequest) async throws { - return try await uniffiRustCallAsync( +open func initializeOrgCrypto(req: InitOrgCryptoRequest)async throws { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_initialize_org_crypto( self.uniffiClonePointer(), @@ -1589,15 +1751,15 @@ public class ClientCrypto: liftFunc: { $0 }, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Initialization method for the user crypto. Needs to be called before any other crypto * operations. */ - public func initializeUserCrypto(req: InitUserCryptoRequest) async throws { - return try await uniffiRustCallAsync( +open func initializeUserCrypto(req: InitUserCryptoRequest)async throws { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_initialize_user_crypto( self.uniffiClonePointer(), @@ -1610,19 +1772,19 @@ public class ClientCrypto: liftFunc: { $0 }, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Update the user's password, which will re-encrypt the user's encryption key with the new * password. This returns the new encrypted user key and the new password hash. */ - public func updatePassword(newPassword: String) async throws -> UpdatePasswordResponse { - return try await uniffiRustCallAsync( +open func updatePassword(newPassword: SensitiveString)async throws -> UpdatePasswordResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientcrypto_update_password( self.uniffiClonePointer(), - FfiConverterString.lower(newPassword) + FfiConverterTypeSensitiveString_lower(newPassword) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1631,8 +1793,7 @@ public class ClientCrypto: liftFunc: FfiConverterTypeUpdatePasswordResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -1669,6 +1830,8 @@ public struct FfiConverterTypeClientCrypto: FfiConverter { } + + public func FfiConverterTypeClientCrypto_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientCrypto { return try FfiConverterTypeClientCrypto.lift(pointer) } @@ -1694,40 +1857,57 @@ public protocol ClientExportersProtocol : AnyObject { } -public class ClientExporters: +open class ClientExporters: ClientExportersProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientexporters(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientexporters(pointer, $0) } } - /** * **API Draft:** Export organization vault */ - public func exportOrganizationVault(collections: [Collection], ciphers: [Cipher], format: ExportFormat) async throws -> String { - return try await uniffiRustCallAsync( +open func exportOrganizationVault(collections: [Collection], ciphers: [Cipher], format: ExportFormat)async throws -> String { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientexporters_export_organization_vault( self.uniffiClonePointer(), - FfiConverterSequenceTypeCollection.lower(collections), - FfiConverterSequenceTypeCipher.lower(ciphers), - FfiConverterTypeExportFormat_lower(format) + FfiConverterSequenceTypeCollection.lower(collections),FfiConverterSequenceTypeCipher.lower(ciphers),FfiConverterTypeExportFormat_lower(format) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1736,20 +1916,18 @@ public class ClientExporters: liftFunc: FfiConverterString.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * **API Draft:** Export user vault */ - public func exportVault(folders: [Folder], ciphers: [Cipher], format: ExportFormat) async throws -> String { - return try await uniffiRustCallAsync( +open func exportVault(folders: [Folder], ciphers: [Cipher], format: ExportFormat)async throws -> String { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientexporters_export_vault( self.uniffiClonePointer(), - FfiConverterSequenceTypeFolder.lower(folders), - FfiConverterSequenceTypeCipher.lower(ciphers), - FfiConverterTypeExportFormat_lower(format) + FfiConverterSequenceTypeFolder.lower(folders),FfiConverterSequenceTypeCipher.lower(ciphers),FfiConverterTypeExportFormat_lower(format) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -1758,8 +1936,7 @@ public class ClientExporters: liftFunc: FfiConverterString.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -1796,6 +1973,8 @@ public struct FfiConverterTypeClientExporters: FfiConverter { } + + public func FfiConverterTypeClientExporters_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientExporters { return try FfiConverterTypeClientExporters.lift(pointer) } @@ -1807,125 +1986,98 @@ public func FfiConverterTypeClientExporters_lower(_ value: ClientExporters) -> U -public protocol ClientFoldersProtocol : AnyObject { - - /** - * Decrypt folder - */ - func decrypt(folder: Folder) async throws -> FolderView +/** + * At the moment this is just a stub implementation that doesn't do anything. It's here to make + * it possible to check the usability API on the native clients. + */ +public protocol ClientFido2Protocol : AnyObject { - /** - * Decrypt folder list - */ - func decryptList(folders: [Folder]) async throws -> [FolderView] + func authenticator(userInterface: UserInterface, credentialStore: CredentialStore) -> ClientFido2Authenticator - /** - * Encrypt folder - */ - func encrypt(folder: FolderView) async throws -> Folder + func client(userInterface: UserInterface, credentialStore: CredentialStore) -> ClientFido2Client } -public class ClientFolders: - ClientFoldersProtocol { - fileprivate let pointer: UnsafeMutableRawPointer +/** + * At the moment this is just a stub implementation that doesn't do anything. It's here to make + * it possible to check the usability API on the native clients. + */ +open class ClientFido2: + ClientFido2Protocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientfolders(self.pointer, $0) } + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientfido2(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { - try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientfolders(pointer, $0) } + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientfido2(pointer, $0) } } +open func authenticator(userInterface: UserInterface, credentialStore: CredentialStore) -> ClientFido2Authenticator { + return try! FfiConverterTypeClientFido2Authenticator.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientfido2_authenticator(self.uniffiClonePointer(), + FfiConverterTypeUserInterface.lower(userInterface), + FfiConverterTypeCredentialStore.lower(credentialStore),$0 + ) +}) +} - /** - * Decrypt folder - */ - public func decrypt(folder: Folder) async throws -> FolderView { - return try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientfolders_decrypt( - self.uniffiClonePointer(), - FfiConverterTypeFolder_lower(folder) - ) - }, - pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, - completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, - freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeFolderView_lift, - errorHandler: FfiConverterTypeBitwardenError.lift - ) - } - - - /** - * Decrypt folder list - */ - public func decryptList(folders: [Folder]) async throws -> [FolderView] { - return try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientfolders_decrypt_list( - self.uniffiClonePointer(), - FfiConverterSequenceTypeFolder.lower(folders) - ) - }, - pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, - completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, - freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeFolderView.lift, - errorHandler: FfiConverterTypeBitwardenError.lift - ) - } - - - /** - * Encrypt folder - */ - public func encrypt(folder: FolderView) async throws -> Folder { - return try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientfolders_encrypt( - self.uniffiClonePointer(), - FfiConverterTypeFolderView_lower(folder) - ) - }, - pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, - completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, - freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeFolder_lift, - errorHandler: FfiConverterTypeBitwardenError.lift - ) - } - +open func client(userInterface: UserInterface, credentialStore: CredentialStore) -> ClientFido2Client { + return try! FfiConverterTypeClientFido2Client.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientfido2_client(self.uniffiClonePointer(), + FfiConverterTypeUserInterface.lower(userInterface), + FfiConverterTypeCredentialStore.lower(credentialStore),$0 + ) +}) +} } -public struct FfiConverterTypeClientFolders: FfiConverter { +public struct FfiConverterTypeClientFido2: FfiConverter { typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ClientFolders + typealias SwiftType = ClientFido2 - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFolders { - return ClientFolders(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFido2 { + return ClientFido2(unsafeFromRawPointer: pointer) } - public static func lower(_ value: ClientFolders) -> UnsafeMutableRawPointer { + public static func lower(_ value: ClientFido2) -> UnsafeMutableRawPointer { return value.uniffiClonePointer() } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientFolders { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientFido2 { 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. @@ -1936,7 +2088,7 @@ public struct FfiConverterTypeClientFolders: FfiConverter { return try lift(ptr!) } - public static func write(_ value: ClientFolders, into buf: inout [UInt8]) { + public static func write(_ value: ClientFido2, 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))))) @@ -1944,136 +2096,138 @@ public struct FfiConverterTypeClientFolders: FfiConverter { } -public func FfiConverterTypeClientFolders_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFolders { - return try FfiConverterTypeClientFolders.lift(pointer) + + +public func FfiConverterTypeClientFido2_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFido2 { + return try FfiConverterTypeClientFido2.lift(pointer) } -public func FfiConverterTypeClientFolders_lower(_ value: ClientFolders) -> UnsafeMutableRawPointer { - return FfiConverterTypeClientFolders.lower(value) +public func FfiConverterTypeClientFido2_lower(_ value: ClientFido2) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientFido2.lower(value) } -public protocol ClientGeneratorsProtocol : AnyObject { +public protocol ClientFido2AuthenticatorProtocol : AnyObject { - /** - * **API Draft:** Generate Passphrase - */ - func passphrase(settings: PassphraseGeneratorRequest) async throws -> String + func getAssertion(request: GetAssertionRequest) async throws -> GetAssertionResult - /** - * **API Draft:** Generate Password - */ - func password(settings: PasswordGeneratorRequest) async throws -> String + func makeCredential(request: MakeCredentialRequest) async throws -> MakeCredentialResult - /** - * **API Draft:** Generate Username - */ - func username(settings: UsernameGeneratorRequest) async throws -> String + func silentlyDiscoverCredentials(rpId: String) async throws -> [Fido2CredentialView] } -public class ClientGenerators: - ClientGeneratorsProtocol { - fileprivate let pointer: UnsafeMutableRawPointer +open class ClientFido2Authenticator: + ClientFido2AuthenticatorProtocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientgenerators(self.pointer, $0) } + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientfido2authenticator(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { - try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientgenerators(pointer, $0) } + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientfido2authenticator(pointer, $0) } } - - /** - * **API Draft:** Generate Passphrase - */ - public func passphrase(settings: PassphraseGeneratorRequest) async throws -> String { - return try await uniffiRustCallAsync( +open func getAssertion(request: GetAssertionRequest)async throws -> GetAssertionResult { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientgenerators_passphrase( + uniffi_bitwarden_uniffi_fn_method_clientfido2authenticator_get_assertion( self.uniffiClonePointer(), - FfiConverterTypePassphraseGeneratorRequest_lower(settings) + FfiConverterTypeGetAssertionRequest_lower(request) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterTypeGetAssertionResult_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} - /** - * **API Draft:** Generate Password - */ - public func password(settings: PasswordGeneratorRequest) async throws -> String { - return try await uniffiRustCallAsync( +open func makeCredential(request: MakeCredentialRequest)async throws -> MakeCredentialResult { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientgenerators_password( + uniffi_bitwarden_uniffi_fn_method_clientfido2authenticator_make_credential( self.uniffiClonePointer(), - FfiConverterTypePasswordGeneratorRequest_lower(settings) + FfiConverterTypeMakeCredentialRequest_lower(request) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterTypeMakeCredentialResult_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} - /** - * **API Draft:** Generate Username - */ - public func username(settings: UsernameGeneratorRequest) async throws -> String { - return try await uniffiRustCallAsync( +open func silentlyDiscoverCredentials(rpId: String)async throws -> [Fido2CredentialView] { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientgenerators_username( + uniffi_bitwarden_uniffi_fn_method_clientfido2authenticator_silently_discover_credentials( self.uniffiClonePointer(), - FfiConverterTypeUsernameGeneratorRequest_lower(settings) + FfiConverterString.lower(rpId) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterSequenceTypeFido2CredentialView.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } -public struct FfiConverterTypeClientGenerators: FfiConverter { +public struct FfiConverterTypeClientFido2Authenticator: FfiConverter { typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ClientGenerators + typealias SwiftType = ClientFido2Authenticator - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientGenerators { - return ClientGenerators(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFido2Authenticator { + return ClientFido2Authenticator(unsafeFromRawPointer: pointer) } - public static func lower(_ value: ClientGenerators) -> UnsafeMutableRawPointer { + public static func lower(_ value: ClientFido2Authenticator) -> UnsafeMutableRawPointer { return value.uniffiClonePointer() } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientGenerators { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientFido2Authenticator { 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. @@ -2084,7 +2238,7 @@ public struct FfiConverterTypeClientGenerators: FfiConverter { return try lift(ptr!) } - public static func write(_ value: ClientGenerators, into buf: inout [UInt8]) { + public static func write(_ value: ClientFido2Authenticator, 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))))) @@ -2092,111 +2246,119 @@ public struct FfiConverterTypeClientGenerators: FfiConverter { } -public func FfiConverterTypeClientGenerators_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientGenerators { - return try FfiConverterTypeClientGenerators.lift(pointer) + + +public func FfiConverterTypeClientFido2Authenticator_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFido2Authenticator { + return try FfiConverterTypeClientFido2Authenticator.lift(pointer) } -public func FfiConverterTypeClientGenerators_lower(_ value: ClientGenerators) -> UnsafeMutableRawPointer { - return FfiConverterTypeClientGenerators.lower(value) +public func FfiConverterTypeClientFido2Authenticator_lower(_ value: ClientFido2Authenticator) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientFido2Authenticator.lower(value) } -public protocol ClientPasswordHistoryProtocol : AnyObject { +public protocol ClientFido2ClientProtocol : AnyObject { - /** - * Decrypt password history - */ - func decryptList(list: [PasswordHistory]) async throws -> [PasswordHistoryView] + func authenticate(origin: String, request: String, clientData: ClientData) async throws -> PublicKeyCredentialAuthenticatorAssertionResponse - /** - * Encrypt password history - */ - func encrypt(passwordHistory: PasswordHistoryView) async throws -> PasswordHistory + func register(origin: String, request: String, clientData: ClientData) async throws -> PublicKeyCredentialAuthenticatorAttestationResponse } -public class ClientPasswordHistory: - ClientPasswordHistoryProtocol { - fileprivate let pointer: UnsafeMutableRawPointer +open class ClientFido2Client: + ClientFido2ClientProtocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientpasswordhistory(self.pointer, $0) } + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientfido2client(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { - try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientpasswordhistory(pointer, $0) } + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientfido2client(pointer, $0) } } - - /** - * Decrypt password history - */ - public func decryptList(list: [PasswordHistory]) async throws -> [PasswordHistoryView] { - return try await uniffiRustCallAsync( +open func authenticate(origin: String, request: String, clientData: ClientData)async throws -> PublicKeyCredentialAuthenticatorAssertionResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientpasswordhistory_decrypt_list( + uniffi_bitwarden_uniffi_fn_method_clientfido2client_authenticate( self.uniffiClonePointer(), - FfiConverterSequenceTypePasswordHistory.lower(list) + FfiConverterString.lower(origin),FfiConverterString.lower(request),FfiConverterTypeClientData_lower(clientData) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypePasswordHistoryView.lift, + liftFunc: FfiConverterTypePublicKeyCredentialAuthenticatorAssertionResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} - /** - * Encrypt password history - */ - public func encrypt(passwordHistory: PasswordHistoryView) async throws -> PasswordHistory { - return try await uniffiRustCallAsync( +open func register(origin: String, request: String, clientData: ClientData)async throws -> PublicKeyCredentialAuthenticatorAttestationResponse { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientpasswordhistory_encrypt( + uniffi_bitwarden_uniffi_fn_method_clientfido2client_register( self.uniffiClonePointer(), - FfiConverterTypePasswordHistoryView_lower(passwordHistory) + FfiConverterString.lower(origin),FfiConverterString.lower(request),FfiConverterTypeClientData_lower(clientData) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypePasswordHistory_lift, + liftFunc: FfiConverterTypePublicKeyCredentialAuthenticatorAttestationResponse_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } -public struct FfiConverterTypeClientPasswordHistory: FfiConverter { +public struct FfiConverterTypeClientFido2Client: FfiConverter { typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ClientPasswordHistory + typealias SwiftType = ClientFido2Client - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPasswordHistory { - return ClientPasswordHistory(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFido2Client { + return ClientFido2Client(unsafeFromRawPointer: pointer) } - public static func lower(_ value: ClientPasswordHistory) -> UnsafeMutableRawPointer { + public static func lower(_ value: ClientFido2Client) -> UnsafeMutableRawPointer { return value.uniffiClonePointer() } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientPasswordHistory { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientFido2Client { 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. @@ -2207,7 +2369,7 @@ public struct FfiConverterTypeClientPasswordHistory: FfiConverter { return try lift(ptr!) } - public static func write(_ value: ClientPasswordHistory, into buf: inout [UInt8]) { + public static func write(_ value: ClientFido2Client, 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))))) @@ -2215,129 +2377,643 @@ public struct FfiConverterTypeClientPasswordHistory: FfiConverter { } -public func FfiConverterTypeClientPasswordHistory_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPasswordHistory { - return try FfiConverterTypeClientPasswordHistory.lift(pointer) + + +public func FfiConverterTypeClientFido2Client_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFido2Client { + return try FfiConverterTypeClientFido2Client.lift(pointer) } -public func FfiConverterTypeClientPasswordHistory_lower(_ value: ClientPasswordHistory) -> UnsafeMutableRawPointer { - return FfiConverterTypeClientPasswordHistory.lower(value) +public func FfiConverterTypeClientFido2Client_lower(_ value: ClientFido2Client) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientFido2Client.lower(value) } -public protocol ClientPlatformProtocol : AnyObject { +public protocol ClientFoldersProtocol : AnyObject { /** - * Fingerprint (public key) + * Decrypt folder */ - func fingerprint(req: FingerprintRequest) async throws -> String + func decrypt(folder: Folder) async throws -> FolderView /** - * Load feature flags into the client + * Decrypt folder list */ - func loadFlags(flags: [String: Bool]) async throws + func decryptList(folders: [Folder]) async throws -> [FolderView] /** - * Fingerprint using logged in user's public key + * Encrypt folder */ - func userFingerprint(fingerprintMaterial: String) async throws -> String + func encrypt(folder: FolderView) async throws -> Folder } -public class ClientPlatform: - ClientPlatformProtocol { - fileprivate let pointer: UnsafeMutableRawPointer +open class ClientFolders: + ClientFoldersProtocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientplatform(self.pointer, $0) } + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientfolders(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { - try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientplatform(pointer, $0) } + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientfolders(pointer, $0) } } - /** - * Fingerprint (public key) + * Decrypt folder */ - public func fingerprint(req: FingerprintRequest) async throws -> String { - return try await uniffiRustCallAsync( +open func decrypt(folder: Folder)async throws -> FolderView { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientplatform_fingerprint( + uniffi_bitwarden_uniffi_fn_method_clientfolders_decrypt( self.uniffiClonePointer(), - FfiConverterTypeFingerprintRequest_lower(req) + FfiConverterTypeFolder_lower(folder) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterTypeFolderView_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** - * Load feature flags into the client + * Decrypt folder list */ - public func loadFlags(flags: [String: Bool]) async throws { - return try await uniffiRustCallAsync( +open func decryptList(folders: [Folder])async throws -> [FolderView] { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientplatform_load_flags( + uniffi_bitwarden_uniffi_fn_method_clientfolders_decrypt_list( self.uniffiClonePointer(), - FfiConverterDictionaryStringBool.lower(flags) + FfiConverterSequenceTypeFolder.lower(folders) ) }, - pollFunc: ffi_bitwarden_uniffi_rust_future_poll_void, - completeFunc: ffi_bitwarden_uniffi_rust_future_complete_void, - freeFunc: ffi_bitwarden_uniffi_rust_future_free_void, - liftFunc: { $0 }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeFolderView.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** - * Fingerprint using logged in user's public key + * Encrypt folder */ - public func userFingerprint(fingerprintMaterial: String) async throws -> String { - return try await uniffiRustCallAsync( +open func encrypt(folder: FolderView)async throws -> Folder { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientplatform_user_fingerprint( + uniffi_bitwarden_uniffi_fn_method_clientfolders_encrypt( self.uniffiClonePointer(), - FfiConverterString.lower(fingerprintMaterial) + FfiConverterTypeFolderView_lower(folder) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, + liftFunc: FfiConverterTypeFolder_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } -public struct FfiConverterTypeClientPlatform: FfiConverter { +public struct FfiConverterTypeClientFolders: FfiConverter { typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ClientPlatform + typealias SwiftType = ClientFolders - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPlatform { - return ClientPlatform(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFolders { + return ClientFolders(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: ClientFolders) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientFolders { + 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: ClientFolders, 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 func FfiConverterTypeClientFolders_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientFolders { + return try FfiConverterTypeClientFolders.lift(pointer) +} + +public func FfiConverterTypeClientFolders_lower(_ value: ClientFolders) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientFolders.lower(value) +} + + + + +public protocol ClientGeneratorsProtocol : AnyObject { + + /** + * **API Draft:** Generate Passphrase + */ + func passphrase(settings: PassphraseGeneratorRequest) async throws -> String + + /** + * **API Draft:** Generate Password + */ + func password(settings: PasswordGeneratorRequest) async throws -> String + + /** + * **API Draft:** Generate Username + */ + func username(settings: UsernameGeneratorRequest) async throws -> String + +} + +open class ClientGenerators: + ClientGeneratorsProtocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientgenerators(self.pointer, $0) } + } + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientgenerators(pointer, $0) } + } + + + + + /** + * **API Draft:** Generate Passphrase + */ +open func passphrase(settings: PassphraseGeneratorRequest)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientgenerators_passphrase( + self.uniffiClonePointer(), + FfiConverterTypePassphraseGeneratorRequest_lower(settings) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + /** + * **API Draft:** Generate Password + */ +open func password(settings: PasswordGeneratorRequest)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientgenerators_password( + self.uniffiClonePointer(), + FfiConverterTypePasswordGeneratorRequest_lower(settings) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + /** + * **API Draft:** Generate Username + */ +open func username(settings: UsernameGeneratorRequest)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientgenerators_username( + self.uniffiClonePointer(), + FfiConverterTypeUsernameGeneratorRequest_lower(settings) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + +} + +public struct FfiConverterTypeClientGenerators: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = ClientGenerators + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientGenerators { + return ClientGenerators(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: ClientGenerators) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientGenerators { + 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: ClientGenerators, 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 func FfiConverterTypeClientGenerators_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientGenerators { + return try FfiConverterTypeClientGenerators.lift(pointer) +} + +public func FfiConverterTypeClientGenerators_lower(_ value: ClientGenerators) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientGenerators.lower(value) +} + + + + +public protocol ClientPasswordHistoryProtocol : AnyObject { + + /** + * Decrypt password history + */ + func decryptList(list: [PasswordHistory]) async throws -> [PasswordHistoryView] + + /** + * Encrypt password history + */ + func encrypt(passwordHistory: PasswordHistoryView) async throws -> PasswordHistory + +} + +open class ClientPasswordHistory: + ClientPasswordHistoryProtocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientpasswordhistory(self.pointer, $0) } + } + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientpasswordhistory(pointer, $0) } + } + + + + + /** + * Decrypt password history + */ +open func decryptList(list: [PasswordHistory])async throws -> [PasswordHistoryView] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientpasswordhistory_decrypt_list( + self.uniffiClonePointer(), + FfiConverterSequenceTypePasswordHistory.lower(list) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypePasswordHistoryView.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + /** + * Encrypt password history + */ +open func encrypt(passwordHistory: PasswordHistoryView)async throws -> PasswordHistory { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientpasswordhistory_encrypt( + self.uniffiClonePointer(), + FfiConverterTypePasswordHistoryView_lower(passwordHistory) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypePasswordHistory_lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + +} + +public struct FfiConverterTypeClientPasswordHistory: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = ClientPasswordHistory + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPasswordHistory { + return ClientPasswordHistory(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: ClientPasswordHistory) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientPasswordHistory { + 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: ClientPasswordHistory, 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 func FfiConverterTypeClientPasswordHistory_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPasswordHistory { + return try FfiConverterTypeClientPasswordHistory.lift(pointer) +} + +public func FfiConverterTypeClientPasswordHistory_lower(_ value: ClientPasswordHistory) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientPasswordHistory.lower(value) +} + + + + +public protocol ClientPlatformProtocol : AnyObject { + + /** + * FIDO2 operations + */ + func fido2() -> ClientFido2 + + /** + * Fingerprint (public key) + */ + func fingerprint(req: FingerprintRequest) async throws -> String + + /** + * Load feature flags into the client + */ + func loadFlags(flags: [String: Bool]) async throws + + /** + * Fingerprint using logged in user's public key + */ + func userFingerprint(fingerprintMaterial: String) async throws -> String + +} + +open class ClientPlatform: + ClientPlatformProtocol { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientplatform(self.pointer, $0) } + } + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientplatform(pointer, $0) } + } + + + + + /** + * FIDO2 operations + */ +open func fido2() -> ClientFido2 { + return try! FfiConverterTypeClientFido2.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientplatform_fido2(self.uniffiClonePointer(),$0 + ) +}) +} + + /** + * Fingerprint (public key) + */ +open func fingerprint(req: FingerprintRequest)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientplatform_fingerprint( + self.uniffiClonePointer(), + FfiConverterTypeFingerprintRequest_lower(req) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + /** + * Load feature flags into the client + */ +open func loadFlags(flags: [String: Bool])async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientplatform_load_flags( + self.uniffiClonePointer(), + FfiConverterDictionaryStringBool.lower(flags) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_void, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_void, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + /** + * Fingerprint using logged in user's public key + */ +open func userFingerprint(fingerprintMaterial: String)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientplatform_user_fingerprint( + self.uniffiClonePointer(), + FfiConverterString.lower(fingerprintMaterial) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + +} + +public struct FfiConverterTypeClientPlatform: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = ClientPlatform + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPlatform { + return ClientPlatform(unsafeFromRawPointer: pointer) } public static func lower(_ value: ClientPlatform) -> UnsafeMutableRawPointer { @@ -2363,6 +3039,8 @@ public struct FfiConverterTypeClientPlatform: FfiConverter { } + + public func FfiConverterTypeClientPlatform_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientPlatform { return try FfiConverterTypeClientPlatform.lift(pointer) } @@ -2413,34 +3091,53 @@ public protocol ClientSendsProtocol : AnyObject { } -public class ClientSends: +open class ClientSends: ClientSendsProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientsends(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientsends(pointer, $0) } } - /** * Decrypt send */ - public func decrypt(send: Send) async throws -> SendView { - return try await uniffiRustCallAsync( +open func decrypt(send: Send)async throws -> SendView { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_decrypt( self.uniffiClonePointer(), @@ -2453,19 +3150,18 @@ public class ClientSends: liftFunc: FfiConverterTypeSendView_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Decrypt a send file in memory */ - public func decryptBuffer(send: Send, buffer: Data) async throws -> Data { - return try await uniffiRustCallAsync( +open func decryptBuffer(send: Send, buffer: Data)async throws -> Data { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_decrypt_buffer( self.uniffiClonePointer(), - FfiConverterTypeSend_lower(send), - FfiConverterData.lower(buffer) + FfiConverterTypeSend_lower(send),FfiConverterData.lower(buffer) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -2474,20 +3170,18 @@ public class ClientSends: liftFunc: FfiConverterData.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Decrypt a send file located in the file system */ - public func decryptFile(send: Send, encryptedFilePath: String, decryptedFilePath: String) async throws { - return try await uniffiRustCallAsync( +open func decryptFile(send: Send, encryptedFilePath: String, decryptedFilePath: String)async throws { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_decrypt_file( self.uniffiClonePointer(), - FfiConverterTypeSend_lower(send), - FfiConverterString.lower(encryptedFilePath), - FfiConverterString.lower(decryptedFilePath) + FfiConverterTypeSend_lower(send),FfiConverterString.lower(encryptedFilePath),FfiConverterString.lower(decryptedFilePath) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_void, @@ -2496,14 +3190,14 @@ public class ClientSends: liftFunc: { $0 }, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Decrypt send list */ - public func decryptList(sends: [Send]) async throws -> [SendListView] { - return try await uniffiRustCallAsync( +open func decryptList(sends: [Send])async throws -> [SendListView] { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_decrypt_list( self.uniffiClonePointer(), @@ -2516,14 +3210,14 @@ public class ClientSends: liftFunc: FfiConverterSequenceTypeSendListView.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Encrypt send */ - public func encrypt(send: SendView) async throws -> Send { - return try await uniffiRustCallAsync( +open func encrypt(send: SendView)async throws -> Send { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_encrypt( self.uniffiClonePointer(), @@ -2536,19 +3230,18 @@ public class ClientSends: liftFunc: FfiConverterTypeSend_lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Encrypt a send file in memory */ - public func encryptBuffer(send: Send, buffer: Data) async throws -> Data { - return try await uniffiRustCallAsync( +open func encryptBuffer(send: Send, buffer: Data)async throws -> Data { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_encrypt_buffer( self.uniffiClonePointer(), - FfiConverterTypeSend_lower(send), - FfiConverterData.lower(buffer) + FfiConverterTypeSend_lower(send),FfiConverterData.lower(buffer) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, @@ -2557,20 +3250,18 @@ public class ClientSends: liftFunc: FfiConverterData.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} /** * Encrypt a send file located in the file system */ - public func encryptFile(send: Send, decryptedFilePath: String, encryptedFilePath: String) async throws { - return try await uniffiRustCallAsync( +open func encryptFile(send: Send, decryptedFilePath: String, encryptedFilePath: String)async throws { + return + try await uniffiRustCallAsync( rustFutureFunc: { uniffi_bitwarden_uniffi_fn_method_clientsends_encrypt_file( self.uniffiClonePointer(), - FfiConverterTypeSend_lower(send), - FfiConverterString.lower(decryptedFilePath), - FfiConverterString.lower(encryptedFilePath) + FfiConverterTypeSend_lower(send),FfiConverterString.lower(decryptedFilePath),FfiConverterString.lower(encryptedFilePath) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_void, @@ -2579,8 +3270,7 @@ public class ClientSends: liftFunc: { $0 }, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - +} } @@ -2617,6 +3307,8 @@ public struct FfiConverterTypeClientSends: FfiConverter { } + + public func FfiConverterTypeClientSends_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientSends { return try FfiConverterTypeClientSends.lift(pointer) } @@ -2672,81 +3364,87 @@ public protocol ClientVaultProtocol : AnyObject { } -public class ClientVault: +open class ClientVault: ClientVaultProtocol { - fileprivate let pointer: UnsafeMutableRawPointer + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { self.pointer = pointer } + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + public func uniffiClonePointer() -> UnsafeMutableRawPointer { return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_clientvault(self.pointer, $0) } } + // No primary constructor declared for this class. deinit { + guard let pointer = pointer else { + return + } + try! rustCall { uniffi_bitwarden_uniffi_fn_free_clientvault(pointer, $0) } } - /** * Attachment file operations */ - public func attachments() -> ClientAttachments { - return try! FfiConverterTypeClientAttachments.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_clientvault_attachments(self.uniffiClonePointer(), $0 +open func attachments() -> ClientAttachments { + return try! FfiConverterTypeClientAttachments.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientvault_attachments(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Ciphers operations */ - public func ciphers() -> ClientCiphers { - return try! FfiConverterTypeClientCiphers.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_clientvault_ciphers(self.uniffiClonePointer(), $0 +open func ciphers() -> ClientCiphers { + return try! FfiConverterTypeClientCiphers.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientvault_ciphers(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Collections operations */ - public func collections() -> ClientCollections { - return try! FfiConverterTypeClientCollections.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_clientvault_collections(self.uniffiClonePointer(), $0 +open func collections() -> ClientCollections { + return try! FfiConverterTypeClientCollections.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientvault_collections(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Folder operations */ - public func folders() -> ClientFolders { - return try! FfiConverterTypeClientFolders.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_clientvault_folders(self.uniffiClonePointer(), $0 +open func folders() -> ClientFolders { + return try! FfiConverterTypeClientFolders.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientvault_folders(self.uniffiClonePointer(),$0 ) +}) } - ) - } + /** * Generate a TOTP code from a provided key. * @@ -2755,67 +3453,614 @@ public class ClientVault: * - OTP Auth URI * - Steam URI */ - public func generateTotp(key: String, time: DateTime?) async throws -> TotpResponse { - return try await uniffiRustCallAsync( +open func generateTotp(key: String, time: DateTime?)async throws -> TotpResponse { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_clientvault_generate_totp( + self.uniffiClonePointer(), + FfiConverterString.lower(key),FfiConverterOptionTypeDateTime.lower(time) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeTotpResponse_lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + /** + * Password history operations + */ +open func passwordHistory() -> ClientPasswordHistory { + return try! FfiConverterTypeClientPasswordHistory.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientvault_password_history(self.uniffiClonePointer(),$0 + ) +}) +} + + /** + * Sends operations + */ +open func sends() -> ClientSends { + return try! FfiConverterTypeClientSends.lift(try! rustCall() { + uniffi_bitwarden_uniffi_fn_method_clientvault_sends(self.uniffiClonePointer(),$0 + ) +}) +} + + +} + +public struct FfiConverterTypeClientVault: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = ClientVault + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientVault { + return ClientVault(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: ClientVault) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientVault { + 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: ClientVault, 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 func FfiConverterTypeClientVault_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientVault { + return try FfiConverterTypeClientVault.lift(pointer) +} + +public func FfiConverterTypeClientVault_lower(_ value: ClientVault) -> UnsafeMutableRawPointer { + return FfiConverterTypeClientVault.lower(value) +} + + + + +public protocol CredentialStore : AnyObject { + + func findCredentials(ids: [Data]?, ripId: String) async throws -> [Cipher] + + func saveCredential(cred: Cipher) async throws + +} + +open class CredentialStoreImpl: + CredentialStore { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_credentialstore(self.pointer, $0) } + } + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_credentialstore(pointer, $0) } + } + + + + +open func findCredentials(ids: [Data]?, ripId: String)async throws -> [Cipher] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_credentialstore_find_credentials( + self.uniffiClonePointer(), + FfiConverterOptionSequenceData.lower(ids),FfiConverterString.lower(ripId) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeCipher.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + +open func saveCredential(cred: Cipher)async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_credentialstore_save_credential( + self.uniffiClonePointer(), + FfiConverterTypeCipher_lower(cred) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_void, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_void, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + + +} +// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +private let IDX_CALLBACK_FREE: Int32 = 0 +// Callback return codes +private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0 +private let UNIFFI_CALLBACK_ERROR: Int32 = 1 +private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2 + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceCredentialStore { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + static var vtable: UniffiVTableCallbackInterfaceCredentialStore = UniffiVTableCallbackInterfaceCredentialStore( + findCredentials: { ( + uniffiHandle: UInt64, + ids: RustBuffer, + ripId: RustBuffer, + uniffiFutureCallback: @escaping UniffiForeignFutureCompleteRustBuffer, + uniffiCallbackData: UInt64, + uniffiOutReturn: UnsafeMutablePointer + ) in + let makeCall = { + () async throws -> [Cipher] in + guard let uniffiObj = try? FfiConverterTypeCredentialStore.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return try await uniffiObj.findCredentials( + ids: try FfiConverterOptionSequenceData.lift(ids), + ripId: try FfiConverterString.lift(ripId) + ) + } + + let uniffiHandleSuccess = { (returnValue: [Cipher]) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: FfiConverterSequenceTypeCipher.lower(returnValue), + callStatus: RustCallStatus() + ) + ) + } + let uniffiHandleError = { (statusCode, errorBuf) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: RustBuffer.empty(), + callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) + ) + ) + } + let uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError( + makeCall: makeCall, + handleSuccess: uniffiHandleSuccess, + handleError: uniffiHandleError, + lowerError: FfiConverterTypeBitwardenError.lower + ) + uniffiOutReturn.pointee = uniffiForeignFuture + }, + saveCredential: { ( + uniffiHandle: UInt64, + cred: RustBuffer, + uniffiFutureCallback: @escaping UniffiForeignFutureCompleteVoid, + uniffiCallbackData: UInt64, + uniffiOutReturn: UnsafeMutablePointer + ) in + let makeCall = { + () async throws -> () in + guard let uniffiObj = try? FfiConverterTypeCredentialStore.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return try await uniffiObj.saveCredential( + cred: try FfiConverterTypeCipher_lift(cred) + ) + } + + let uniffiHandleSuccess = { (returnValue: ()) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructVoid( + callStatus: RustCallStatus() + ) + ) + } + let uniffiHandleError = { (statusCode, errorBuf) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructVoid( + callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) + ) + ) + } + let uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError( + makeCall: makeCall, + handleSuccess: uniffiHandleSuccess, + handleError: uniffiHandleError, + lowerError: FfiConverterTypeBitwardenError.lower + ) + uniffiOutReturn.pointee = uniffiForeignFuture + }, + uniffiFree: { (uniffiHandle: UInt64) -> () in + let result = try? FfiConverterTypeCredentialStore.handleMap.remove(handle: uniffiHandle) + if result == nil { + print("Uniffi callback interface CredentialStore: handle missing in uniffiFree") + } + } + ) +} + +private func uniffiCallbackInitCredentialStore() { + uniffi_bitwarden_uniffi_fn_init_callback_vtable_credentialstore(&UniffiCallbackInterfaceCredentialStore.vtable) +} + +public struct FfiConverterTypeCredentialStore: FfiConverter { + fileprivate static var handleMap = UniffiHandleMap() + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = CredentialStore + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> CredentialStore { + return CredentialStoreImpl(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: CredentialStore) -> UnsafeMutableRawPointer { + guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else { + fatalError("Cast to UnsafeMutableRawPointer failed") + } + return ptr + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CredentialStore { + 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: CredentialStore, 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 func FfiConverterTypeCredentialStore_lift(_ pointer: UnsafeMutableRawPointer) throws -> CredentialStore { + return try FfiConverterTypeCredentialStore.lift(pointer) +} + +public func FfiConverterTypeCredentialStore_lower(_ value: CredentialStore) -> UnsafeMutableRawPointer { + return FfiConverterTypeCredentialStore.lower(value) +} + + + + +public protocol UserInterface : AnyObject { + + func checkUser(options: CheckUserOptions, credential: CipherView?) async throws -> CheckUserResult + + func pickCredentialForAuthentication(availableCredentials: [Cipher]) async throws -> CipherViewWrapper + + func pickCredentialForCreation(availableCredentials: [Cipher], newCredential: Fido2Credential) async throws -> CipherViewWrapper + +} + +open class UserInterfaceImpl: + UserInterface { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. + public struct NoPointer { + 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`. + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + /// This constructor can be used to instantiate a fake object. + /// - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash. + public init(noPointer: NoPointer) { + self.pointer = nil + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitwarden_uniffi_fn_clone_userinterface(self.pointer, $0) } + } + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitwarden_uniffi_fn_free_userinterface(pointer, $0) } + } + + + + +open func checkUser(options: CheckUserOptions, credential: CipherView?)async throws -> CheckUserResult { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_userinterface_check_user( + self.uniffiClonePointer(), + FfiConverterTypeCheckUserOptions_lower(options),FfiConverterOptionTypeCipherView.lower(credential) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeCheckUserResult.lift, + errorHandler: FfiConverterTypeBitwardenError.lift + ) +} + +open func pickCredentialForAuthentication(availableCredentials: [Cipher])async throws -> CipherViewWrapper { + return + try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitwarden_uniffi_fn_method_clientvault_generate_totp( + uniffi_bitwarden_uniffi_fn_method_userinterface_pick_credential_for_authentication( self.uniffiClonePointer(), - FfiConverterString.lower(key), - FfiConverterOptionTypeDateTime.lower(time) + FfiConverterSequenceTypeCipher.lower(availableCredentials) ) }, pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeTotpResponse_lift, + liftFunc: FfiConverterTypeCipherViewWrapper.lift, errorHandler: FfiConverterTypeBitwardenError.lift ) - } - - - /** - * Password history operations - */ - public func passwordHistory() -> ClientPasswordHistory { - return try! FfiConverterTypeClientPasswordHistory.lift( - try! - rustCall() { - - uniffi_bitwarden_uniffi_fn_method_clientvault_password_history(self.uniffiClonePointer(), $0 - ) } + +open func pickCredentialForCreation(availableCredentials: [Cipher], newCredential: Fido2Credential)async throws -> CipherViewWrapper { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitwarden_uniffi_fn_method_userinterface_pick_credential_for_creation( + self.uniffiClonePointer(), + FfiConverterSequenceTypeCipher.lower(availableCredentials),FfiConverterTypeFido2Credential_lower(newCredential) + ) + }, + pollFunc: ffi_bitwarden_uniffi_rust_future_poll_rust_buffer, + completeFunc: ffi_bitwarden_uniffi_rust_future_complete_rust_buffer, + freeFunc: ffi_bitwarden_uniffi_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeCipherViewWrapper.lift, + errorHandler: FfiConverterTypeBitwardenError.lift ) - } - /** - * Sends operations - */ - public func sends() -> ClientSends { - return try! FfiConverterTypeClientSends.lift( - try! - rustCall() { +} - uniffi_bitwarden_uniffi_fn_method_clientvault_sends(self.uniffiClonePointer(), $0 + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceUserInterface { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + static var vtable: UniffiVTableCallbackInterfaceUserInterface = UniffiVTableCallbackInterfaceUserInterface( + checkUser: { ( + uniffiHandle: UInt64, + options: RustBuffer, + credential: RustBuffer, + uniffiFutureCallback: @escaping UniffiForeignFutureCompleteRustBuffer, + uniffiCallbackData: UInt64, + uniffiOutReturn: UnsafeMutablePointer + ) in + let makeCall = { + () async throws -> CheckUserResult in + guard let uniffiObj = try? FfiConverterTypeUserInterface.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return try await uniffiObj.checkUser( + options: try FfiConverterTypeCheckUserOptions_lift(options), + credential: try FfiConverterOptionTypeCipherView.lift(credential) + ) + } + + let uniffiHandleSuccess = { (returnValue: CheckUserResult) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: FfiConverterTypeCheckUserResult.lower(returnValue), + callStatus: RustCallStatus() + ) + ) + } + let uniffiHandleError = { (statusCode, errorBuf) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: RustBuffer.empty(), + callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) + ) + ) + } + let uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError( + makeCall: makeCall, + handleSuccess: uniffiHandleSuccess, + handleError: uniffiHandleError, + lowerError: FfiConverterTypeBitwardenError.lower + ) + uniffiOutReturn.pointee = uniffiForeignFuture + }, + pickCredentialForAuthentication: { ( + uniffiHandle: UInt64, + availableCredentials: RustBuffer, + uniffiFutureCallback: @escaping UniffiForeignFutureCompleteRustBuffer, + uniffiCallbackData: UInt64, + uniffiOutReturn: UnsafeMutablePointer + ) in + let makeCall = { + () async throws -> CipherViewWrapper in + guard let uniffiObj = try? FfiConverterTypeUserInterface.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return try await uniffiObj.pickCredentialForAuthentication( + availableCredentials: try FfiConverterSequenceTypeCipher.lift(availableCredentials) + ) + } + + let uniffiHandleSuccess = { (returnValue: CipherViewWrapper) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: FfiConverterTypeCipherViewWrapper.lower(returnValue), + callStatus: RustCallStatus() + ) + ) + } + let uniffiHandleError = { (statusCode, errorBuf) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: RustBuffer.empty(), + callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) + ) + ) + } + let uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError( + makeCall: makeCall, + handleSuccess: uniffiHandleSuccess, + handleError: uniffiHandleError, + lowerError: FfiConverterTypeBitwardenError.lower + ) + uniffiOutReturn.pointee = uniffiForeignFuture + }, + pickCredentialForCreation: { ( + uniffiHandle: UInt64, + availableCredentials: RustBuffer, + newCredential: RustBuffer, + uniffiFutureCallback: @escaping UniffiForeignFutureCompleteRustBuffer, + uniffiCallbackData: UInt64, + uniffiOutReturn: UnsafeMutablePointer + ) in + let makeCall = { + () async throws -> CipherViewWrapper in + guard let uniffiObj = try? FfiConverterTypeUserInterface.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return try await uniffiObj.pickCredentialForCreation( + availableCredentials: try FfiConverterSequenceTypeCipher.lift(availableCredentials), + newCredential: try FfiConverterTypeFido2Credential_lift(newCredential) + ) + } + + let uniffiHandleSuccess = { (returnValue: CipherViewWrapper) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: FfiConverterTypeCipherViewWrapper.lower(returnValue), + callStatus: RustCallStatus() + ) + ) + } + let uniffiHandleError = { (statusCode, errorBuf) in + uniffiFutureCallback( + uniffiCallbackData, + UniffiForeignFutureStructRustBuffer( + returnValue: RustBuffer.empty(), + callStatus: RustCallStatus(code: statusCode, errorBuf: errorBuf) + ) + ) + } + let uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError( + makeCall: makeCall, + handleSuccess: uniffiHandleSuccess, + handleError: uniffiHandleError, + lowerError: FfiConverterTypeBitwardenError.lower + ) + uniffiOutReturn.pointee = uniffiForeignFuture + }, + uniffiFree: { (uniffiHandle: UInt64) -> () in + let result = try? FfiConverterTypeUserInterface.handleMap.remove(handle: uniffiHandle) + if result == nil { + print("Uniffi callback interface UserInterface: handle missing in uniffiFree") + } + } ) } - ) - } +private func uniffiCallbackInitUserInterface() { + uniffi_bitwarden_uniffi_fn_init_callback_vtable_userinterface(&UniffiCallbackInterfaceUserInterface.vtable) } -public struct FfiConverterTypeClientVault: FfiConverter { +public struct FfiConverterTypeUserInterface: FfiConverter { + fileprivate static var handleMap = UniffiHandleMap() typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ClientVault + typealias SwiftType = UserInterface - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientVault { - return ClientVault(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> UserInterface { + return UserInterfaceImpl(unsafeFromRawPointer: pointer) } - public static func lower(_ value: ClientVault) -> UnsafeMutableRawPointer { - return value.uniffiClonePointer() + public static func lower(_ value: UserInterface) -> UnsafeMutableRawPointer { + guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else { + fatalError("Cast to UnsafeMutableRawPointer failed") + } + return ptr } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ClientVault { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserInterface { 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. @@ -2826,7 +4071,7 @@ public struct FfiConverterTypeClientVault: FfiConverter { return try lift(ptr!) } - public static func write(_ value: ClientVault, into buf: inout [UInt8]) { + public static func write(_ value: UserInterface, 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))))) @@ -2834,12 +4079,120 @@ public struct FfiConverterTypeClientVault: FfiConverter { } -public func FfiConverterTypeClientVault_lift(_ pointer: UnsafeMutableRawPointer) throws -> ClientVault { - return try FfiConverterTypeClientVault.lift(pointer) + + +public func FfiConverterTypeUserInterface_lift(_ pointer: UnsafeMutableRawPointer) throws -> UserInterface { + return try FfiConverterTypeUserInterface.lift(pointer) } -public func FfiConverterTypeClientVault_lower(_ value: ClientVault) -> UnsafeMutableRawPointer { - return FfiConverterTypeClientVault.lower(value) +public func FfiConverterTypeUserInterface_lower(_ value: UserInterface) -> UnsafeMutableRawPointer { + return FfiConverterTypeUserInterface.lower(value) +} + + +public struct CheckUserResult { + public let userPresent: Bool + public let userVerified: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(userPresent: Bool, userVerified: Bool) { + self.userPresent = userPresent + self.userVerified = userVerified + } +} + + + +extension CheckUserResult: Equatable, Hashable { + public static func ==(lhs: CheckUserResult, rhs: CheckUserResult) -> Bool { + if lhs.userPresent != rhs.userPresent { + return false + } + if lhs.userVerified != rhs.userVerified { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(userPresent) + hasher.combine(userVerified) + } +} + + +public struct FfiConverterTypeCheckUserResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CheckUserResult { + return + try CheckUserResult( + userPresent: FfiConverterBool.read(from: &buf), + userVerified: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: CheckUserResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.userPresent, into: &buf) + FfiConverterBool.write(value.userVerified, into: &buf) + } +} + + +public func FfiConverterTypeCheckUserResult_lift(_ buf: RustBuffer) throws -> CheckUserResult { + return try FfiConverterTypeCheckUserResult.lift(buf) +} + +public func FfiConverterTypeCheckUserResult_lower(_ value: CheckUserResult) -> RustBuffer { + return FfiConverterTypeCheckUserResult.lower(value) +} + + +public struct CipherViewWrapper { + public let cipher: CipherView + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(cipher: CipherView) { + self.cipher = cipher + } +} + + + +extension CipherViewWrapper: Equatable, Hashable { + public static func ==(lhs: CipherViewWrapper, rhs: CipherViewWrapper) -> Bool { + if lhs.cipher != rhs.cipher { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(cipher) + } +} + + +public struct FfiConverterTypeCipherViewWrapper: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CipherViewWrapper { + return + try CipherViewWrapper( + cipher: FfiConverterTypeCipherView.read(from: &buf) + ) + } + + public static func write(_ value: CipherViewWrapper, into buf: inout [UInt8]) { + FfiConverterTypeCipherView.write(value.cipher, into: &buf) + } +} + + +public func FfiConverterTypeCipherViewWrapper_lift(_ buf: RustBuffer) throws -> CipherViewWrapper { + return try FfiConverterTypeCipherViewWrapper.lift(buf) +} + +public func FfiConverterTypeCipherViewWrapper_lower(_ value: CipherViewWrapper) -> RustBuffer { + return FfiConverterTypeCipherViewWrapper.lower(value) } @@ -2849,10 +4202,6 @@ public enum BitwardenError { case E(message: String) - - fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { - return try FfiConverterTypeBitwardenError.lift(error) - } } @@ -2894,6 +4243,48 @@ extension BitwardenError: Equatable, Hashable {} extension BitwardenError: Error { } +fileprivate struct FfiConverterOptionSequenceData: 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)) + FfiConverterSequenceData.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 FfiConverterSequenceData.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeCipherView: FfiConverterRustBuffer { + typealias SwiftType = CipherView? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeCipherView.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 FfiConverterTypeCipherView.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + fileprivate struct FfiConverterOptionTypeClientSettings: FfiConverterRustBuffer { typealias SwiftType = ClientSettings? @@ -2958,6 +4349,28 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer { } } +fileprivate struct FfiConverterSequenceData: FfiConverterRustBuffer { + typealias SwiftType = [Data] + + public static func write(_ value: [Data], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterData.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Data] { + let len: Int32 = try readInt(&buf) + var seq = [Data]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterData.read(from: &buf)) + } + return seq + } +} + fileprivate struct FfiConverterSequenceTypeCipher: FfiConverterRustBuffer { typealias SwiftType = [Cipher] @@ -3046,6 +4459,28 @@ fileprivate struct FfiConverterSequenceTypeCollectionView: FfiConverterRustBuffe } } +fileprivate struct FfiConverterSequenceTypeFido2CredentialView: FfiConverterRustBuffer { + typealias SwiftType = [Fido2CredentialView] + + public static func write(_ value: [Fido2CredentialView], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeFido2CredentialView.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Fido2CredentialView] { + let len: Int32 = try readInt(&buf) + var seq = [Fido2CredentialView]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeFido2CredentialView.read(from: &buf)) + } + return seq + } +} + fileprivate struct FfiConverterSequenceTypeFolder: FfiConverterRustBuffer { typealias SwiftType = [Folder] @@ -3255,6 +4690,26 @@ fileprivate struct FfiConverterDictionaryStringBool: FfiConverterRustBuffer { + + + + + + + + + + + + + + + + + + + + @@ -3279,11 +4734,13 @@ fileprivate struct FfiConverterDictionaryStringBool: FfiConverterRustBuffer { private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0 private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1 +fileprivate let uniffiContinuationHandleMap = UniffiHandleMap>() + fileprivate func uniffiRustCallAsync( - rustFutureFunc: () -> UnsafeMutableRawPointer, - pollFunc: (UnsafeMutableRawPointer, @escaping UniFfiRustFutureContinuation, UnsafeMutableRawPointer) -> (), - completeFunc: (UnsafeMutableRawPointer, UnsafeMutablePointer) -> F, - freeFunc: (UnsafeMutableRawPointer) -> (), + rustFutureFunc: () -> UInt64, + pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (), + completeFunc: (UInt64, UnsafeMutablePointer) -> F, + freeFunc: (UInt64) -> (), liftFunc: (F) throws -> T, errorHandler: ((RustBuffer) throws -> Error)? ) async throws -> T { @@ -3297,7 +4754,11 @@ fileprivate func uniffiRustCallAsync( var pollResult: Int8; repeat { pollResult = await withUnsafeContinuation { - pollFunc(rustFuture, uniffiFutureContinuationCallback, ContinuationHolder($0).toOpaque()) + pollFunc( + rustFuture, + uniffiFutureContinuationCallback, + uniffiContinuationHandleMap.insert(obj: $0) + ) } } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY @@ -3309,32 +4770,80 @@ fileprivate func uniffiRustCallAsync( // Callback handlers for an async calls. These are invoked by Rust when the future is ready. They // lift the return value or error and resume the suspended function. -fileprivate func uniffiFutureContinuationCallback(ptr: UnsafeMutableRawPointer, pollResult: Int8) { - ContinuationHolder.fromOpaque(ptr).resume(pollResult) +fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: Int8) { + if let continuation = try? uniffiContinuationHandleMap.remove(handle: handle) { + continuation.resume(returning: pollResult) + } else { + print("uniffiFutureContinuationCallback invalid handle") + } } +private func uniffiTraitInterfaceCallAsync( + makeCall: @escaping () async throws -> T, + handleSuccess: @escaping (T) -> (), + handleError: @escaping (Int8, RustBuffer) -> () +) -> UniffiForeignFuture { + let task = Task { + do { + handleSuccess(try await makeCall()) + } catch { + handleError(CALL_UNEXPECTED_ERROR, FfiConverterString.lower(String(describing: error))) + } + } + let handle = UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.insert(obj: task) + return UniffiForeignFuture(handle: handle, free: uniffiForeignFutureFree) -// Wraps UnsafeContinuation in a class so that we can use reference counting when passing it across -// the FFI -fileprivate class ContinuationHolder { - let continuation: UnsafeContinuation +} - init(_ continuation: UnsafeContinuation) { - self.continuation = continuation +private func uniffiTraitInterfaceCallAsyncWithError( + makeCall: @escaping () async throws -> T, + handleSuccess: @escaping (T) -> (), + handleError: @escaping (Int8, RustBuffer) -> (), + lowerError: @escaping (E) -> RustBuffer +) -> UniffiForeignFuture { + let task = Task { + do { + handleSuccess(try await makeCall()) + } catch let error as E { + handleError(CALL_ERROR, lowerError(error)) + } catch { + handleError(CALL_UNEXPECTED_ERROR, FfiConverterString.lower(String(describing: error))) + } } + let handle = UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.insert(obj: task) + return UniffiForeignFuture(handle: handle, free: uniffiForeignFutureFree) +} - func resume(_ pollResult: Int8) { - self.continuation.resume(returning: pollResult) - } +// Borrow the callback handle map implementation to store foreign future handles +// TODO: consolidate the handle-map code (https://github.com/mozilla/uniffi-rs/pull/1823) +fileprivate var UNIFFI_FOREIGN_FUTURE_HANDLE_MAP = UniffiHandleMap() - func toOpaque() -> UnsafeMutableRawPointer { - return Unmanaged.passRetained(self).toOpaque() - } +// Protocol for tasks that handle foreign futures. +// +// Defining a protocol allows all tasks to be stored in the same handle map. This can't be done +// with the task object itself, since has generic parameters. +protocol UniffiForeignFutureTask { + func cancel() +} + +extension Task: UniffiForeignFutureTask {} - static func fromOpaque(_ ptr: UnsafeRawPointer) -> ContinuationHolder { - return Unmanaged.fromOpaque(ptr).takeRetainedValue() +private func uniffiForeignFutureFree(handle: UInt64) { + do { + let task = try UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.remove(handle: handle) + // Set the cancellation flag on the task. If it's still running, the code can check the + // cancellation flag or call `Task.checkCancellation()`. If the task has completed, this is + // a no-op. + task.cancel() + } catch { + print("uniffiForeignFutureFree: handle missing from handlemap") } } +// For testing +public func uniffiForeignFutureHandleCountBitwardenUniffi() -> Int { + UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.count +} + private enum InitializationResult { case ok case contractVersionMismatch @@ -3344,7 +4853,7 @@ private enum InitializationResult { // the code inside is only computed once. private var initializationResult: InitializationResult { // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 25 + let bindings_contract_version = 26 // Get the scaffolding contract version by calling the into the dylib let scaffolding_contract_version = ffi_bitwarden_uniffi_uniffi_contract_version() if bindings_contract_version != scaffolding_contract_version { @@ -3356,7 +4865,7 @@ private var initializationResult: InitializationResult { if (uniffi_bitwarden_uniffi_checksum_method_client_crypto() != 21064) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_client_echo() != 57048) { + if (uniffi_bitwarden_uniffi_checksum_method_client_echo() != 61009) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitwarden_uniffi_checksum_method_client_exporters() != 13095) { @@ -3371,145 +4880,169 @@ private var initializationResult: InitializationResult { if (uniffi_bitwarden_uniffi_checksum_method_client_vault() != 54396) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_decrypt_buffer() != 54549) { + if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_decrypt_buffer() != 9611) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_decrypt_file() != 34017) { + if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_decrypt_file() != 61374) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_encrypt_buffer() != 25357) { + if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_encrypt_buffer() != 21814) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_encrypt_file() != 25144) { + if (uniffi_bitwarden_uniffi_checksum_method_clientattachments_encrypt_file() != 19021) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_approve_auth_request() != 47791) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_approve_auth_request() != 38048) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_hash_password() != 59447) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_hash_password() != 32360) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_make_register_keys() != 41498) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_make_register_keys() != 40026) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_make_register_tde_keys() != 49812) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_make_register_tde_keys() != 28237) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_new_auth_request() != 22873) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_new_auth_request() != 52130) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_password_strength() != 48755) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_password_strength() != 50427) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_satisfies_policy() != 43941) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_satisfies_policy() != 19494) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitwarden_uniffi_checksum_method_clientauth_trust_device() != 57467) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_validate_password() != 44745) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_validate_password() != 54177) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientauth_validate_password_user_key() != 38366) { + if (uniffi_bitwarden_uniffi_checksum_method_clientauth_validate_password_user_key() != 37661) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_decrypt() != 17124) { + if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_decrypt() != 17376) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_decrypt_list() != 28799) { + if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_decrypt_list() != 19799) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_encrypt() != 12793) { + if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_encrypt() != 32685) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_move_to_organization() != 21012) { + if (uniffi_bitwarden_uniffi_checksum_method_clientciphers_move_to_organization() != 8717) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcollections_decrypt() != 43923) { + if (uniffi_bitwarden_uniffi_checksum_method_clientcollections_decrypt() != 32420) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcollections_decrypt_list() != 2482) { + if (uniffi_bitwarden_uniffi_checksum_method_clientcollections_decrypt_list() != 35235) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_derive_pin_key() != 28115) { + if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_derive_pin_key() != 19322) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_derive_pin_user_key() != 60758) { + if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_derive_pin_user_key() != 44837) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_enroll_admin_password_reset() != 37196) { + if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_enroll_admin_password_reset() != 29128) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_get_user_encryption_key() != 2002) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_initialize_org_crypto() != 35897) { + if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_initialize_org_crypto() != 51836) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_initialize_user_crypto() != 38745) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_update_password() != 43463) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientexporters_export_organization_vault() != 12046) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientexporters_export_vault() != 16305) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2_authenticator() != 25923) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2_client() != 60861) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_initialize_user_crypto() != 17931) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2authenticator_get_assertion() != 58461) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientcrypto_update_password() != 15722) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2authenticator_make_credential() != 40275) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientexporters_export_organization_vault() != 7348) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2authenticator_silently_discover_credentials() != 40587) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientexporters_export_vault() != 35076) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2client_authenticate() != 11152) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientfolders_decrypt() != 34328) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfido2client_register() != 29135) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientfolders_decrypt_list() != 15889) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfolders_decrypt() != 60012) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientfolders_encrypt() != 8773) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfolders_decrypt_list() != 54345) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientgenerators_passphrase() != 14313) { + if (uniffi_bitwarden_uniffi_checksum_method_clientfolders_encrypt() != 48151) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientgenerators_password() != 61103) { + if (uniffi_bitwarden_uniffi_checksum_method_clientgenerators_passphrase() != 5509) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientgenerators_username() != 8234) { + if (uniffi_bitwarden_uniffi_checksum_method_clientgenerators_password() != 43715) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientpasswordhistory_decrypt_list() != 2221) { + if (uniffi_bitwarden_uniffi_checksum_method_clientgenerators_username() != 58695) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientpasswordhistory_encrypt() != 64931) { + if (uniffi_bitwarden_uniffi_checksum_method_clientpasswordhistory_decrypt_list() != 21882) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_fingerprint() != 28196) { + if (uniffi_bitwarden_uniffi_checksum_method_clientpasswordhistory_encrypt() != 50585) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_load_flags() != 3837) { + if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_fido2() != 37766) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_user_fingerprint() != 15566) { + if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_fingerprint() != 55239) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt() != 33752) { + if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_load_flags() != 3443) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt_buffer() != 58830) { + if (uniffi_bitwarden_uniffi_checksum_method_clientplatform_user_fingerprint() != 2528) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt_file() != 47479) { + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt() != 11978) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt_list() != 39872) { + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt_buffer() != 31666) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_encrypt() != 56991) { + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt_file() != 46614) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_encrypt_buffer() != 55941) { + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_decrypt_list() != 10311) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientsends_encrypt_file() != 4738) { + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_encrypt() != 30271) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_encrypt_buffer() != 63272) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_clientsends_encrypt_file() != 13066) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitwarden_uniffi_checksum_method_clientvault_attachments() != 8984) { @@ -3524,7 +5057,7 @@ private var initializationResult: InitializationResult { if (uniffi_bitwarden_uniffi_checksum_method_clientvault_folders() != 44601) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_method_clientvault_generate_totp() != 20127) { + if (uniffi_bitwarden_uniffi_checksum_method_clientvault_generate_totp() != 28988) { return InitializationResult.apiChecksumMismatch } if (uniffi_bitwarden_uniffi_checksum_method_clientvault_password_history() != 59154) { @@ -3533,10 +5066,27 @@ private var initializationResult: InitializationResult { if (uniffi_bitwarden_uniffi_checksum_method_clientvault_sends() != 7895) { return InitializationResult.apiChecksumMismatch } - if (uniffi_bitwarden_uniffi_checksum_constructor_client_new() != 33125) { + if (uniffi_bitwarden_uniffi_checksum_method_credentialstore_find_credentials() != 26220) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_credentialstore_save_credential() != 39231) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_userinterface_check_user() != 42853) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_userinterface_pick_credential_for_authentication() != 47836) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_method_userinterface_pick_credential_for_creation() != 1195) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitwarden_uniffi_checksum_constructor_client_new() != 27271) { return InitializationResult.apiChecksumMismatch } + uniffiCallbackInitCredentialStore() + uniffiCallbackInitUserInterface() return InitializationResult.ok } @@ -3549,4 +5099,6 @@ private func uniffiEnsureInitialized() { case .apiChecksumMismatch: fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } -} \ No newline at end of file +} + +// swiftlint:enable all \ No newline at end of file