Skip to content

Commit 3571477

Browse files
Update Swift SDK to ab3c7dbd0699a57f626acf430d1bcf3120d2cc07
1 parent 2a66094 commit 3571477

File tree

6 files changed

+336
-111
lines changed

6 files changed

+336
-111
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ let package = Package(
3333
),
3434
.binaryTarget(
3535
name: "BitwardenFFI",
36-
url: "https://github.com/bitwarden/sdk-swift/releases/download/v1.0.0-unstable-a3d1c11/BitwardenFFI-1.0.0-a3d1c11.xcframework.zip",
37-
checksum: "c10a9bfea745349daa4082ebc7b797f3d0cb0e4e15b7875012459adffd50ece1"
36+
url: "https://github.com/bitwarden/sdk-swift/releases/download/v1.0.0-unstable-ab3c7db/BitwardenFFI-1.0.0-ab3c7db.xcframework.zip",
37+
checksum: "d3fa6e182688aa4849811f0b82fdf0e0cdd08c4e7baf917f0b98386389172d11"
3838
),
3939
]
4040
)

Sources/BitwardenSdk/BitwardenCollections.swift

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ fileprivate struct FfiConverterString: FfiConverter {
464464

465465

466466
public struct Collection {
467-
public let id: Uuid?
468-
public let organizationId: Uuid
467+
public let id: CollectionId?
468+
public let organizationId: OrganizationId
469469
public let name: EncString
470470
public let externalId: String?
471471
public let hidePasswords: Bool
@@ -476,7 +476,7 @@ public struct Collection {
476476

477477
// Default memberwise initializers are never public by default, so we
478478
// declare one manually.
479-
public init(id: Uuid?, organizationId: Uuid, name: EncString, externalId: String?, hidePasswords: Bool, readOnly: Bool, manage: Bool, defaultUserCollectionEmail: String?, type: CollectionType) {
479+
public init(id: CollectionId?, organizationId: OrganizationId, name: EncString, externalId: String?, hidePasswords: Bool, readOnly: Bool, manage: Bool, defaultUserCollectionEmail: String?, type: CollectionType) {
480480
self.id = id
481481
self.organizationId = organizationId
482482
self.name = name
@@ -548,8 +548,8 @@ public struct FfiConverterTypeCollection: FfiConverterRustBuffer {
548548
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Collection {
549549
return
550550
try Collection(
551-
id: FfiConverterOptionTypeUuid.read(from: &buf),
552-
organizationId: FfiConverterTypeUuid.read(from: &buf),
551+
id: FfiConverterOptionTypeCollectionId.read(from: &buf),
552+
organizationId: FfiConverterTypeOrganizationId.read(from: &buf),
553553
name: FfiConverterTypeEncString.read(from: &buf),
554554
externalId: FfiConverterOptionString.read(from: &buf),
555555
hidePasswords: FfiConverterBool.read(from: &buf),
@@ -561,8 +561,8 @@ public struct FfiConverterTypeCollection: FfiConverterRustBuffer {
561561
}
562562

563563
public static func write(_ value: Collection, into buf: inout [UInt8]) {
564-
FfiConverterOptionTypeUuid.write(value.id, into: &buf)
565-
FfiConverterTypeUuid.write(value.organizationId, into: &buf)
564+
FfiConverterOptionTypeCollectionId.write(value.id, into: &buf)
565+
FfiConverterTypeOrganizationId.write(value.organizationId, into: &buf)
566566
FfiConverterTypeEncString.write(value.name, into: &buf)
567567
FfiConverterOptionString.write(value.externalId, into: &buf)
568568
FfiConverterBool.write(value.hidePasswords, into: &buf)
@@ -590,8 +590,8 @@ public func FfiConverterTypeCollection_lower(_ value: Collection) -> RustBuffer
590590

591591

592592
public struct CollectionView {
593-
public let id: Uuid?
594-
public let organizationId: Uuid
593+
public let id: CollectionId?
594+
public let organizationId: OrganizationId
595595
public let name: String
596596
public let externalId: String?
597597
public let hidePasswords: Bool
@@ -601,7 +601,7 @@ public struct CollectionView {
601601

602602
// Default memberwise initializers are never public by default, so we
603603
// declare one manually.
604-
public init(id: Uuid?, organizationId: Uuid, name: String, externalId: String?, hidePasswords: Bool, readOnly: Bool, manage: Bool, type: CollectionType) {
604+
public init(id: CollectionId?, organizationId: OrganizationId, name: String, externalId: String?, hidePasswords: Bool, readOnly: Bool, manage: Bool, type: CollectionType) {
605605
self.id = id
606606
self.organizationId = organizationId
607607
self.name = name
@@ -668,8 +668,8 @@ public struct FfiConverterTypeCollectionView: FfiConverterRustBuffer {
668668
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CollectionView {
669669
return
670670
try CollectionView(
671-
id: FfiConverterOptionTypeUuid.read(from: &buf),
672-
organizationId: FfiConverterTypeUuid.read(from: &buf),
671+
id: FfiConverterOptionTypeCollectionId.read(from: &buf),
672+
organizationId: FfiConverterTypeOrganizationId.read(from: &buf),
673673
name: FfiConverterString.read(from: &buf),
674674
externalId: FfiConverterOptionString.read(from: &buf),
675675
hidePasswords: FfiConverterBool.read(from: &buf),
@@ -680,8 +680,8 @@ public struct FfiConverterTypeCollectionView: FfiConverterRustBuffer {
680680
}
681681

682682
public static func write(_ value: CollectionView, into buf: inout [UInt8]) {
683-
FfiConverterOptionTypeUuid.write(value.id, into: &buf)
684-
FfiConverterTypeUuid.write(value.organizationId, into: &buf)
683+
FfiConverterOptionTypeCollectionId.write(value.id, into: &buf)
684+
FfiConverterTypeOrganizationId.write(value.organizationId, into: &buf)
685685
FfiConverterString.write(value.name, into: &buf)
686686
FfiConverterOptionString.write(value.externalId, into: &buf)
687687
FfiConverterBool.write(value.hidePasswords, into: &buf)
@@ -810,27 +810,71 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
810810
#if swift(>=5.8)
811811
@_documentation(visibility: private)
812812
#endif
813-
fileprivate struct FfiConverterOptionTypeUuid: FfiConverterRustBuffer {
814-
typealias SwiftType = Uuid?
813+
fileprivate struct FfiConverterOptionTypeCollectionId: FfiConverterRustBuffer {
814+
typealias SwiftType = CollectionId?
815815

816816
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
817817
guard let value = value else {
818818
writeInt(&buf, Int8(0))
819819
return
820820
}
821821
writeInt(&buf, Int8(1))
822-
FfiConverterTypeUuid.write(value, into: &buf)
822+
FfiConverterTypeCollectionId.write(value, into: &buf)
823823
}
824824

825825
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
826826
switch try readInt(&buf) as Int8 {
827827
case 0: return nil
828-
case 1: return try FfiConverterTypeUuid.read(from: &buf)
828+
case 1: return try FfiConverterTypeCollectionId.read(from: &buf)
829829
default: throw UniffiInternalError.unexpectedOptionalTag
830830
}
831831
}
832832
}
833833

834+
835+
/**
836+
* Typealias from the type name used in the UDL file to the builtin type. This
837+
* is needed because the UDL type name is used in function/method signatures.
838+
*/
839+
public typealias CollectionId = Uuid
840+
841+
#if swift(>=5.8)
842+
@_documentation(visibility: private)
843+
#endif
844+
public struct FfiConverterTypeCollectionId: FfiConverter {
845+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CollectionId {
846+
return try FfiConverterTypeUuid.read(from: &buf)
847+
}
848+
849+
public static func write(_ value: CollectionId, into buf: inout [UInt8]) {
850+
return FfiConverterTypeUuid.write(value, into: &buf)
851+
}
852+
853+
public static func lift(_ value: RustBuffer) throws -> CollectionId {
854+
return try FfiConverterTypeUuid_lift(value)
855+
}
856+
857+
public static func lower(_ value: CollectionId) -> RustBuffer {
858+
return FfiConverterTypeUuid_lower(value)
859+
}
860+
}
861+
862+
863+
#if swift(>=5.8)
864+
@_documentation(visibility: private)
865+
#endif
866+
public func FfiConverterTypeCollectionId_lift(_ value: RustBuffer) throws -> CollectionId {
867+
return try FfiConverterTypeCollectionId.lift(value)
868+
}
869+
870+
#if swift(>=5.8)
871+
@_documentation(visibility: private)
872+
#endif
873+
public func FfiConverterTypeCollectionId_lower(_ value: CollectionId) -> RustBuffer {
874+
return FfiConverterTypeCollectionId.lower(value)
875+
}
876+
877+
834878
private enum InitializationResult {
835879
case ok
836880
case contractVersionMismatch
@@ -847,8 +891,8 @@ private let initializationResult: InitializationResult = {
847891
return InitializationResult.contractVersionMismatch
848892
}
849893

850-
uniffiEnsureBitwardenCoreInitialized()
851894
uniffiEnsureBitwardenCryptoInitialized()
895+
uniffiEnsureBitwardenCoreInitialized()
852896
return InitializationResult.ok
853897
}()
854898

Sources/BitwardenSdk/BitwardenCore.swift

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,14 +1065,14 @@ public struct InitOrgCryptoRequest {
10651065
/**
10661066
* The encryption keys for all the organizations the user is a part of
10671067
*/
1068-
public let organizationKeys: [Uuid: UnsignedSharedKey]
1068+
public let organizationKeys: [OrganizationId: UnsignedSharedKey]
10691069

10701070
// Default memberwise initializers are never public by default, so we
10711071
// declare one manually.
10721072
public init(
10731073
/**
10741074
* The encryption keys for all the organizations the user is a part of
1075-
*/organizationKeys: [Uuid: UnsignedSharedKey]) {
1075+
*/organizationKeys: [OrganizationId: UnsignedSharedKey]) {
10761076
self.organizationKeys = organizationKeys
10771077
}
10781078
}
@@ -1104,12 +1104,12 @@ public struct FfiConverterTypeInitOrgCryptoRequest: FfiConverterRustBuffer {
11041104
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> InitOrgCryptoRequest {
11051105
return
11061106
try InitOrgCryptoRequest(
1107-
organizationKeys: FfiConverterDictionaryTypeUuidTypeUnsignedSharedKey.read(from: &buf)
1107+
organizationKeys: FfiConverterDictionaryTypeOrganizationIdTypeUnsignedSharedKey.read(from: &buf)
11081108
)
11091109
}
11101110

11111111
public static func write(_ value: InitOrgCryptoRequest, into buf: inout [UInt8]) {
1112-
FfiConverterDictionaryTypeUuidTypeUnsignedSharedKey.write(value.organizationKeys, into: &buf)
1112+
FfiConverterDictionaryTypeOrganizationIdTypeUnsignedSharedKey.write(value.organizationKeys, into: &buf)
11131113
}
11141114
}
11151115

@@ -1136,7 +1136,7 @@ public struct InitUserCryptoRequest {
11361136
/**
11371137
* The user's ID.
11381138
*/
1139-
public let userId: Uuid?
1139+
public let userId: UserId?
11401140
/**
11411141
* The user's KDF parameters, as received from the prelogin request
11421142
*/
@@ -1167,7 +1167,7 @@ public struct InitUserCryptoRequest {
11671167
public init(
11681168
/**
11691169
* The user's ID.
1170-
*/userId: Uuid?,
1170+
*/userId: UserId?,
11711171
/**
11721172
* The user's KDF parameters, as received from the prelogin request
11731173
*/kdfParams: Kdf,
@@ -1247,7 +1247,7 @@ public struct FfiConverterTypeInitUserCryptoRequest: FfiConverterRustBuffer {
12471247
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> InitUserCryptoRequest {
12481248
return
12491249
try InitUserCryptoRequest(
1250-
userId: FfiConverterOptionTypeUuid.read(from: &buf),
1250+
userId: FfiConverterOptionTypeUserId.read(from: &buf),
12511251
kdfParams: FfiConverterTypeKdf.read(from: &buf),
12521252
email: FfiConverterString.read(from: &buf),
12531253
privateKey: FfiConverterTypeEncString.read(from: &buf),
@@ -1258,7 +1258,7 @@ public struct FfiConverterTypeInitUserCryptoRequest: FfiConverterRustBuffer {
12581258
}
12591259

12601260
public static func write(_ value: InitUserCryptoRequest, into buf: inout [UInt8]) {
1261-
FfiConverterOptionTypeUuid.write(value.userId, into: &buf)
1261+
FfiConverterOptionTypeUserId.write(value.userId, into: &buf)
12621262
FfiConverterTypeKdf.write(value.kdfParams, into: &buf)
12631263
FfiConverterString.write(value.email, into: &buf)
12641264
FfiConverterTypeEncString.write(value.privateKey, into: &buf)
@@ -2793,22 +2793,22 @@ fileprivate struct FfiConverterOptionTypeSignedSecurityState: FfiConverterRustBu
27932793
#if swift(>=5.8)
27942794
@_documentation(visibility: private)
27952795
#endif
2796-
fileprivate struct FfiConverterOptionTypeUuid: FfiConverterRustBuffer {
2797-
typealias SwiftType = Uuid?
2796+
fileprivate struct FfiConverterOptionTypeUserId: FfiConverterRustBuffer {
2797+
typealias SwiftType = UserId?
27982798

27992799
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
28002800
guard let value = value else {
28012801
writeInt(&buf, Int8(0))
28022802
return
28032803
}
28042804
writeInt(&buf, Int8(1))
2805-
FfiConverterTypeUuid.write(value, into: &buf)
2805+
FfiConverterTypeUserId.write(value, into: &buf)
28062806
}
28072807

28082808
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
28092809
switch try readInt(&buf) as Int8 {
28102810
case 0: return nil
2811-
case 1: return try FfiConverterTypeUuid.read(from: &buf)
2811+
case 1: return try FfiConverterTypeUserId.read(from: &buf)
28122812
default: throw UniffiInternalError.unexpectedOptionalTag
28132813
}
28142814
}
@@ -2841,22 +2841,22 @@ fileprivate struct FfiConverterOptionTypeEncString: FfiConverterRustBuffer {
28412841
#if swift(>=5.8)
28422842
@_documentation(visibility: private)
28432843
#endif
2844-
fileprivate struct FfiConverterDictionaryTypeUuidTypeUnsignedSharedKey: FfiConverterRustBuffer {
2845-
public static func write(_ value: [Uuid: UnsignedSharedKey], into buf: inout [UInt8]) {
2844+
fileprivate struct FfiConverterDictionaryTypeOrganizationIdTypeUnsignedSharedKey: FfiConverterRustBuffer {
2845+
public static func write(_ value: [OrganizationId: UnsignedSharedKey], into buf: inout [UInt8]) {
28462846
let len = Int32(value.count)
28472847
writeInt(&buf, len)
28482848
for (key, value) in value {
2849-
FfiConverterTypeUuid.write(key, into: &buf)
2849+
FfiConverterTypeOrganizationId.write(key, into: &buf)
28502850
FfiConverterTypeUnsignedSharedKey.write(value, into: &buf)
28512851
}
28522852
}
28532853

2854-
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Uuid: UnsignedSharedKey] {
2854+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OrganizationId: UnsignedSharedKey] {
28552855
let len: Int32 = try readInt(&buf)
2856-
var dict = [Uuid: UnsignedSharedKey]()
2856+
var dict = [OrganizationId: UnsignedSharedKey]()
28572857
dict.reserveCapacity(Int(len))
28582858
for _ in 0..<len {
2859-
let key = try FfiConverterTypeUuid.read(from: &buf)
2859+
let key = try FfiConverterTypeOrganizationId.read(from: &buf)
28602860
let value = try FfiConverterTypeUnsignedSharedKey.read(from: &buf)
28612861
dict[key] = value
28622862
}
@@ -3041,6 +3041,50 @@ public func FfiConverterTypeSignedSecurityState_lower(_ value: SignedSecuritySta
30413041

30423042

30433043

3044+
/**
3045+
* Typealias from the type name used in the UDL file to the builtin type. This
3046+
* is needed because the UDL type name is used in function/method signatures.
3047+
*/
3048+
public typealias UserId = Uuid
3049+
3050+
#if swift(>=5.8)
3051+
@_documentation(visibility: private)
3052+
#endif
3053+
public struct FfiConverterTypeUserId: FfiConverter {
3054+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserId {
3055+
return try FfiConverterTypeUuid.read(from: &buf)
3056+
}
3057+
3058+
public static func write(_ value: UserId, into buf: inout [UInt8]) {
3059+
return FfiConverterTypeUuid.write(value, into: &buf)
3060+
}
3061+
3062+
public static func lift(_ value: RustBuffer) throws -> UserId {
3063+
return try FfiConverterTypeUuid_lift(value)
3064+
}
3065+
3066+
public static func lower(_ value: UserId) -> RustBuffer {
3067+
return FfiConverterTypeUuid_lower(value)
3068+
}
3069+
}
3070+
3071+
3072+
#if swift(>=5.8)
3073+
@_documentation(visibility: private)
3074+
#endif
3075+
public func FfiConverterTypeUserId_lift(_ value: RustBuffer) throws -> UserId {
3076+
return try FfiConverterTypeUserId.lift(value)
3077+
}
3078+
3079+
#if swift(>=5.8)
3080+
@_documentation(visibility: private)
3081+
#endif
3082+
public func FfiConverterTypeUserId_lower(_ value: UserId) -> RustBuffer {
3083+
return FfiConverterTypeUserId.lower(value)
3084+
}
3085+
3086+
3087+
30443088
/**
30453089
* Typealias from the type name used in the UDL file to the builtin type. This
30463090
* is needed because the UDL type name is used in function/method signatures.

Sources/BitwardenSdk/BitwardenFido.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2666,8 +2666,8 @@ private let initializationResult: InitializationResult = {
26662666
return InitializationResult.contractVersionMismatch
26672667
}
26682668

2669-
uniffiEnsureBitwardenVaultInitialized()
26702669
uniffiEnsureBitwardenCoreInitialized()
2670+
uniffiEnsureBitwardenVaultInitialized()
26712671
return InitializationResult.ok
26722672
}()
26732673

0 commit comments

Comments
 (0)