Skip to content

Commit

Permalink
Release 0d4c73c276c41c23603d89d93c7751aa13ed3a80 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton authored Aug 19, 2024
1 parent a6987cf commit 29c6c62
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let package = Package(
swiftSettings: [.unsafeFlags(["-suppress-warnings"])]),
.binaryTarget(
name: "BitwardenFFI",
url: "https://bwlivefronttest.blob.core.windows.net/sdk/dfdbf7d-BitwardenFFI.xcframework.zip",
checksum: "6ec71db8879e53f3a22cb68822d416e72f306b28bfda26c8c49777afd96334eb"),
url: "https://bwlivefronttest.blob.core.windows.net/sdk/0d4c73c-BitwardenFFI.xcframework.zip",
checksum: "e4a23c7a03b965a87b1e3fda6711ff9a6c974217f50dfc9a93177eff7300fe6f"),
.testTarget(
name: "BitwardenSdkTests",
dependencies: ["BitwardenSdk"])
Expand Down
20 changes: 20 additions & 0 deletions Sources/BitwardenSdk/BitwardenSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3074,6 +3074,11 @@ public protocol ClientVaultProtocol : AnyObject {
*/
func generateTotp(key: String, time: DateTime?) throws -> TotpResponse

/**
* Generate a TOTP code from a provided cipher list view.
*/
func generateTotpCipherView(view: CipherListView, time: DateTime?) throws -> TotpResponse

/**
* Password history operations
*/
Expand Down Expand Up @@ -3177,6 +3182,18 @@ open func generateTotp(key: String, time: DateTime?)throws -> TotpResponse {
FfiConverterOptionTypeDateTime.lower(time),$0
)
})
}

/**
* Generate a TOTP code from a provided cipher list view.
*/
open func generateTotpCipherView(view: CipherListView, time: DateTime?)throws -> TotpResponse {
return try FfiConverterTypeTotpResponse_lift(try rustCallWithError(FfiConverterTypeBitwardenError.lift) {
uniffi_bitwarden_uniffi_fn_method_clientvault_generate_totp_cipher_view(self.uniffiClonePointer(),
FfiConverterTypeCipherListView_lower(view),
FfiConverterOptionTypeDateTime.lower(time),$0
)
})
}

/**
Expand Down Expand Up @@ -5125,6 +5142,9 @@ private var initializationResult: InitializationResult = {
if (uniffi_bitwarden_uniffi_checksum_method_clientvault_generate_totp() != 46339) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_bitwarden_uniffi_checksum_method_clientvault_generate_totp_cipher_view() != 12034) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_bitwarden_uniffi_checksum_method_clientvault_password_history() != 59154) {
return InitializationResult.apiChecksumMismatch
}
Expand Down
103 changes: 98 additions & 5 deletions Sources/BitwardenSdk/BitwardenVault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1135,9 +1135,13 @@ public struct CipherListView {
public let organizationId: Uuid?
public let folderId: Uuid?
public let collectionIds: [Uuid]
/**
* Temporary, required to support calculating TOTP from CipherListView.
*/
public let key: EncString?
public let name: String
public let subTitle: String
public let type: CipherType
public let type: CipherListViewType
public let favorite: Bool
public let reprompt: CipherRepromptType
public let edit: Bool
Expand All @@ -1152,14 +1156,18 @@ 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],
/**
* Temporary, required to support calculating TOTP from CipherListView.
*/key: EncString?, name: String, subTitle: String, type: CipherListViewType, favorite: Bool, reprompt: CipherRepromptType, edit: Bool, viewPassword: Bool,
/**
* The number of attachments
*/attachments: UInt32, creationDate: DateTime, deletedDate: DateTime?, revisionDate: DateTime) {
self.id = id
self.organizationId = organizationId
self.folderId = folderId
self.collectionIds = collectionIds
self.key = key
self.name = name
self.subTitle = subTitle
self.type = type
Expand Down Expand Up @@ -1190,6 +1198,9 @@ extension CipherListView: Equatable, Hashable {
if lhs.collectionIds != rhs.collectionIds {
return false
}
if lhs.key != rhs.key {
return false
}
if lhs.name != rhs.name {
return false
}
Expand Down Expand Up @@ -1231,6 +1242,7 @@ extension CipherListView: Equatable, Hashable {
hasher.combine(organizationId)
hasher.combine(folderId)
hasher.combine(collectionIds)
hasher.combine(key)
hasher.combine(name)
hasher.combine(subTitle)
hasher.combine(type)
Expand All @@ -1254,9 +1266,10 @@ public struct FfiConverterTypeCipherListView: FfiConverterRustBuffer {
organizationId: FfiConverterOptionTypeUuid.read(from: &buf),
folderId: FfiConverterOptionTypeUuid.read(from: &buf),
collectionIds: FfiConverterSequenceTypeUuid.read(from: &buf),
key: FfiConverterOptionTypeEncString.read(from: &buf),
name: FfiConverterString.read(from: &buf),
subTitle: FfiConverterString.read(from: &buf),
type: FfiConverterTypeCipherType.read(from: &buf),
type: FfiConverterTypeCipherListViewType.read(from: &buf),
favorite: FfiConverterBool.read(from: &buf),
reprompt: FfiConverterTypeCipherRepromptType.read(from: &buf),
edit: FfiConverterBool.read(from: &buf),
Expand All @@ -1273,9 +1286,10 @@ public struct FfiConverterTypeCipherListView: FfiConverterRustBuffer {
FfiConverterOptionTypeUuid.write(value.organizationId, into: &buf)
FfiConverterOptionTypeUuid.write(value.folderId, into: &buf)
FfiConverterSequenceTypeUuid.write(value.collectionIds, into: &buf)
FfiConverterOptionTypeEncString.write(value.key, into: &buf)
FfiConverterString.write(value.name, into: &buf)
FfiConverterString.write(value.subTitle, into: &buf)
FfiConverterTypeCipherType.write(value.type, into: &buf)
FfiConverterTypeCipherListViewType.write(value.type, into: &buf)
FfiConverterBool.write(value.favorite, into: &buf)
FfiConverterTypeCipherRepromptType.write(value.reprompt, into: &buf)
FfiConverterBool.write(value.edit, into: &buf)
Expand All @@ -1302,6 +1316,9 @@ public struct CipherView {
public let organizationId: Uuid?
public let folderId: Uuid?
public let collectionIds: [Uuid]
/**
* Temporary, required to support re-encrypting existing items.
*/
public let key: EncString?
public let name: String
public let notes: String?
Expand All @@ -1325,7 +1342,10 @@ 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],
/**
* Temporary, required to support re-encrypting existing items.
*/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) {
self.id = id
self.organizationId = organizationId
self.folderId = folderId
Expand Down Expand Up @@ -3491,6 +3511,79 @@ public func FfiConverterTypeTotpResponse_lower(_ value: TotpResponse) -> RustBuf
return FfiConverterTypeTotpResponse.lower(value)
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.

public enum CipherListViewType {

case login(hasFido2: Bool, totp: EncString?
)
case secureNote
case card
case identity
}


public struct FfiConverterTypeCipherListViewType: FfiConverterRustBuffer {
typealias SwiftType = CipherListViewType

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CipherListViewType {
let variant: Int32 = try readInt(&buf)
switch variant {

case 1: return .login(hasFido2: try FfiConverterBool.read(from: &buf), totp: try FfiConverterOptionTypeEncString.read(from: &buf)
)

case 2: return .secureNote

case 3: return .card

case 4: return .identity

default: throw UniffiInternalError.unexpectedEnumCase
}
}

public static func write(_ value: CipherListViewType, into buf: inout [UInt8]) {
switch value {


case let .login(hasFido2,totp):
writeInt(&buf, Int32(1))
FfiConverterBool.write(hasFido2, into: &buf)
FfiConverterOptionTypeEncString.write(totp, into: &buf)


case .secureNote:
writeInt(&buf, Int32(2))


case .card:
writeInt(&buf, Int32(3))


case .identity:
writeInt(&buf, Int32(4))

}
}
}


public func FfiConverterTypeCipherListViewType_lift(_ buf: RustBuffer) throws -> CipherListViewType {
return try FfiConverterTypeCipherListViewType.lift(buf)
}

public func FfiConverterTypeCipherListViewType_lower(_ value: CipherListViewType) -> RustBuffer {
return FfiConverterTypeCipherListViewType.lower(value)
}



extension CipherListViewType: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.

Expand Down

0 comments on commit 29c6c62

Please sign in to comment.