ping-openmls-sdk-react-native-macos 0.2.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -724,9 +724,9 @@ public func FfiConverterTypeMessageObserver_lower(_ value: MessageObserver) -> U
724
724
  }
725
725
 
726
726
  public protocol MessagingClientProtocol: AnyObject {
727
- func addMembers(conversationId: ConversationId, keyPackages: [Data], nowMs: UInt64) async throws
727
+ func addMembers(conversationId: ConversationId, entries: [KeyPackageEntry], nowMs: UInt64) async throws
728
728
 
729
- func buildLinkingTicket(newDeviceId: DeviceId, newDeviceKp: Data, nowMs: UInt64) async throws -> LinkingTicket
729
+ func buildLinkingTicket(newDeviceId: DeviceId, newDeviceKp: Data, lastAppEvents: [CatchupAppEvent], nowMs: UInt64) async throws -> LinkingTicket
730
730
 
731
731
  func consumeLinkingTicket(ticket: LinkingTicket, nowMs: UInt64) async throws
732
732
 
@@ -736,8 +736,14 @@ public protocol MessagingClientProtocol: AnyObject {
736
736
 
737
737
  func deviceInfo(nowMs: UInt64) -> DeviceInfo
738
738
 
739
+ func exportConversationSecret(conversationId: ConversationId, label: String, context: Data, length: UInt32) throws -> Data
740
+
741
+ func exportConversationStateSnapshot(conversationId: ConversationId, nowMs: UInt64) throws -> Data
742
+
739
743
  func freshKeyPackage() throws -> Data
740
744
 
745
+ func importStateSnapshot(snapshotBytes: Data, nowMs: UInt64) async throws -> ConversationId
746
+
741
747
  func joinConversation(welcome: MessageEnvelope, nowMs: UInt64) async throws -> ConversationId
742
748
 
743
749
  func listConversations() -> [ConversationMeta]
@@ -748,7 +754,7 @@ public protocol MessagingClientProtocol: AnyObject {
748
754
 
749
755
  func removeMembers(conversationId: ConversationId, leafIndexes: [UInt32], nowMs: UInt64) async throws
750
756
 
751
- func revokeDevice(deviceId: DeviceId, nowMs: UInt64) async throws
757
+ func revokeDevice(deviceId: DeviceId, nowMs: UInt64) async throws -> [MessageEnvelope]
752
758
 
753
759
  func send(conversationId: ConversationId, plaintext: Data, nowMs: UInt64) async throws -> MessageEnvelope
754
760
 
@@ -808,11 +814,11 @@ open class MessagingClient:
808
814
  try! rustCall { uniffi_ping_ffi_fn_free_messagingclient(pointer, $0) }
809
815
  }
810
816
 
811
- public static func `init`(identityExport: Data, deviceLabel: String, storage: Storage, transport: Transport, nowMs: UInt64) async throws -> MessagingClient {
817
+ public static func `init`(identityExport: Data, deviceLabel: String, storage: Storage, transport: Transport, nowMs: UInt64, sqlitePath: String?, sqliteEncryptionKey: Data?, deviceSigningSecretKey: Data?) async throws -> MessagingClient {
812
818
  return
813
819
  try await uniffiRustCallAsync(
814
820
  rustFutureFunc: {
815
- uniffi_ping_ffi_fn_constructor_messagingclient_init(FfiConverterData.lower(identityExport), FfiConverterString.lower(deviceLabel), FfiConverterTypeStorage.lower(storage), FfiConverterTypeTransport.lower(transport), FfiConverterUInt64.lower(nowMs))
821
+ uniffi_ping_ffi_fn_constructor_messagingclient_init(FfiConverterData.lower(identityExport), FfiConverterString.lower(deviceLabel), FfiConverterTypeStorage.lower(storage), FfiConverterTypeTransport.lower(transport), FfiConverterUInt64.lower(nowMs), FfiConverterOptionString.lower(sqlitePath), FfiConverterOptionData.lower(sqliteEncryptionKey), FfiConverterOptionData.lower(deviceSigningSecretKey))
816
822
  },
817
823
  pollFunc: ffi_ping_ffi_rust_future_poll_pointer,
818
824
  completeFunc: ffi_ping_ffi_rust_future_complete_pointer,
@@ -822,13 +828,13 @@ open class MessagingClient:
822
828
  )
823
829
  }
824
830
 
825
- open func addMembers(conversationId: ConversationId, keyPackages: [Data], nowMs: UInt64) async throws {
831
+ open func addMembers(conversationId: ConversationId, entries: [KeyPackageEntry], nowMs: UInt64) async throws {
826
832
  return
827
833
  try await uniffiRustCallAsync(
828
834
  rustFutureFunc: {
829
835
  uniffi_ping_ffi_fn_method_messagingclient_add_members(
830
836
  self.uniffiClonePointer(),
831
- FfiConverterTypeConversationId.lower(conversationId), FfiConverterSequenceData.lower(keyPackages), FfiConverterUInt64.lower(nowMs)
837
+ FfiConverterTypeConversationId.lower(conversationId), FfiConverterSequenceTypeKeyPackageEntry.lower(entries), FfiConverterUInt64.lower(nowMs)
832
838
  )
833
839
  },
834
840
  pollFunc: ffi_ping_ffi_rust_future_poll_void,
@@ -839,13 +845,13 @@ open class MessagingClient:
839
845
  )
840
846
  }
841
847
 
842
- open func buildLinkingTicket(newDeviceId: DeviceId, newDeviceKp: Data, nowMs: UInt64) async throws -> LinkingTicket {
848
+ open func buildLinkingTicket(newDeviceId: DeviceId, newDeviceKp: Data, lastAppEvents: [CatchupAppEvent], nowMs: UInt64) async throws -> LinkingTicket {
843
849
  return
844
850
  try await uniffiRustCallAsync(
845
851
  rustFutureFunc: {
846
852
  uniffi_ping_ffi_fn_method_messagingclient_build_linking_ticket(
847
853
  self.uniffiClonePointer(),
848
- FfiConverterTypeDeviceId.lower(newDeviceId), FfiConverterData.lower(newDeviceKp), FfiConverterUInt64.lower(nowMs)
854
+ FfiConverterTypeDeviceId.lower(newDeviceId), FfiConverterData.lower(newDeviceKp), FfiConverterSequenceTypeCatchupAppEvent.lower(lastAppEvents), FfiConverterUInt64.lower(nowMs)
849
855
  )
850
856
  },
851
857
  pollFunc: ffi_ping_ffi_rust_future_poll_rust_buffer,
@@ -903,12 +909,47 @@ open class MessagingClient:
903
909
  })
904
910
  }
905
911
 
912
+ open func exportConversationSecret(conversationId: ConversationId, label: String, context: Data, length: UInt32) throws -> Data {
913
+ return try FfiConverterData.lift(rustCallWithError(FfiConverterTypePingError.lift) {
914
+ uniffi_ping_ffi_fn_method_messagingclient_export_conversation_secret(self.uniffiClonePointer(),
915
+ FfiConverterTypeConversationId.lower(conversationId),
916
+ FfiConverterString.lower(label),
917
+ FfiConverterData.lower(context),
918
+ FfiConverterUInt32.lower(length), $0)
919
+ })
920
+ }
921
+
922
+ open func exportConversationStateSnapshot(conversationId: ConversationId, nowMs: UInt64) throws -> Data {
923
+ return try FfiConverterData.lift(rustCallWithError(FfiConverterTypePingError.lift) {
924
+ uniffi_ping_ffi_fn_method_messagingclient_export_conversation_state_snapshot(self.uniffiClonePointer(),
925
+ FfiConverterTypeConversationId.lower(conversationId),
926
+ FfiConverterUInt64.lower(nowMs), $0)
927
+ })
928
+ }
929
+
906
930
  open func freshKeyPackage() throws -> Data {
907
931
  return try FfiConverterData.lift(rustCallWithError(FfiConverterTypePingError.lift) {
908
932
  uniffi_ping_ffi_fn_method_messagingclient_fresh_key_package(self.uniffiClonePointer(), $0)
909
933
  })
910
934
  }
911
935
 
936
+ open func importStateSnapshot(snapshotBytes: Data, nowMs: UInt64) async throws -> ConversationId {
937
+ return
938
+ try await uniffiRustCallAsync(
939
+ rustFutureFunc: {
940
+ uniffi_ping_ffi_fn_method_messagingclient_import_state_snapshot(
941
+ self.uniffiClonePointer(),
942
+ FfiConverterData.lower(snapshotBytes), FfiConverterUInt64.lower(nowMs)
943
+ )
944
+ },
945
+ pollFunc: ffi_ping_ffi_rust_future_poll_rust_buffer,
946
+ completeFunc: ffi_ping_ffi_rust_future_complete_rust_buffer,
947
+ freeFunc: ffi_ping_ffi_rust_future_free_rust_buffer,
948
+ liftFunc: FfiConverterTypeConversationId.lift,
949
+ errorHandler: FfiConverterTypePingError.lift
950
+ )
951
+ }
952
+
912
953
  open func joinConversation(welcome: MessageEnvelope, nowMs: UInt64) async throws -> ConversationId {
913
954
  return
914
955
  try await uniffiRustCallAsync(
@@ -972,7 +1013,7 @@ open class MessagingClient:
972
1013
  )
973
1014
  }
974
1015
 
975
- open func revokeDevice(deviceId: DeviceId, nowMs: UInt64) async throws {
1016
+ open func revokeDevice(deviceId: DeviceId, nowMs: UInt64) async throws -> [MessageEnvelope] {
976
1017
  return
977
1018
  try await uniffiRustCallAsync(
978
1019
  rustFutureFunc: {
@@ -981,10 +1022,10 @@ open class MessagingClient:
981
1022
  FfiConverterTypeDeviceId.lower(deviceId), FfiConverterUInt64.lower(nowMs)
982
1023
  )
983
1024
  },
984
- pollFunc: ffi_ping_ffi_rust_future_poll_void,
985
- completeFunc: ffi_ping_ffi_rust_future_complete_void,
986
- freeFunc: ffi_ping_ffi_rust_future_free_void,
987
- liftFunc: { $0 },
1025
+ pollFunc: ffi_ping_ffi_rust_future_poll_rust_buffer,
1026
+ completeFunc: ffi_ping_ffi_rust_future_complete_rust_buffer,
1027
+ freeFunc: ffi_ping_ffi_rust_future_free_rust_buffer,
1028
+ liftFunc: FfiConverterSequenceTypeMessageEnvelope.lift,
988
1029
  errorHandler: FfiConverterTypePingError.lift
989
1030
  )
990
1031
  }
@@ -1770,6 +1811,205 @@ public func FfiConverterTypeTransport_lower(_ value: Transport) -> UnsafeMutable
1770
1811
  return FfiConverterTypeTransport.lower(value)
1771
1812
  }
1772
1813
 
1814
+ public struct CatchupAppEvent {
1815
+ public var conversationId: ConversationId
1816
+ public var appEventBytes: Data
1817
+
1818
+ /// Default memberwise initializers are never public by default, so we
1819
+ /// declare one manually.
1820
+ public init(conversationId: ConversationId, appEventBytes: Data) {
1821
+ self.conversationId = conversationId
1822
+ self.appEventBytes = appEventBytes
1823
+ }
1824
+ }
1825
+
1826
+ extension CatchupAppEvent: Equatable, Hashable {
1827
+ public static func == (lhs: CatchupAppEvent, rhs: CatchupAppEvent) -> Bool {
1828
+ if lhs.conversationId != rhs.conversationId {
1829
+ return false
1830
+ }
1831
+ if lhs.appEventBytes != rhs.appEventBytes {
1832
+ return false
1833
+ }
1834
+ return true
1835
+ }
1836
+
1837
+ public func hash(into hasher: inout Hasher) {
1838
+ hasher.combine(conversationId)
1839
+ hasher.combine(appEventBytes)
1840
+ }
1841
+ }
1842
+
1843
+ #if swift(>=5.8)
1844
+ @_documentation(visibility: private)
1845
+ #endif
1846
+ public struct FfiConverterTypeCatchupAppEvent: FfiConverterRustBuffer {
1847
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CatchupAppEvent {
1848
+ return
1849
+ try CatchupAppEvent(
1850
+ conversationId: FfiConverterTypeConversationId.read(from: &buf),
1851
+ appEventBytes: FfiConverterData.read(from: &buf)
1852
+ )
1853
+ }
1854
+
1855
+ public static func write(_ value: CatchupAppEvent, into buf: inout [UInt8]) {
1856
+ FfiConverterTypeConversationId.write(value.conversationId, into: &buf)
1857
+ FfiConverterData.write(value.appEventBytes, into: &buf)
1858
+ }
1859
+ }
1860
+
1861
+ #if swift(>=5.8)
1862
+ @_documentation(visibility: private)
1863
+ #endif
1864
+ public func FfiConverterTypeCatchupAppEvent_lift(_ buf: RustBuffer) throws -> CatchupAppEvent {
1865
+ return try FfiConverterTypeCatchupAppEvent.lift(buf)
1866
+ }
1867
+
1868
+ #if swift(>=5.8)
1869
+ @_documentation(visibility: private)
1870
+ #endif
1871
+ public func FfiConverterTypeCatchupAppEvent_lower(_ value: CatchupAppEvent) -> RustBuffer {
1872
+ return FfiConverterTypeCatchupAppEvent.lower(value)
1873
+ }
1874
+
1875
+ public struct CatchupSnapshotEntry {
1876
+ public var conversationId: ConversationId
1877
+ public var meta: ConversationMeta
1878
+ public var groupStateBytes: Data
1879
+
1880
+ /// Default memberwise initializers are never public by default, so we
1881
+ /// declare one manually.
1882
+ public init(conversationId: ConversationId, meta: ConversationMeta, groupStateBytes: Data) {
1883
+ self.conversationId = conversationId
1884
+ self.meta = meta
1885
+ self.groupStateBytes = groupStateBytes
1886
+ }
1887
+ }
1888
+
1889
+ extension CatchupSnapshotEntry: Equatable, Hashable {
1890
+ public static func == (lhs: CatchupSnapshotEntry, rhs: CatchupSnapshotEntry) -> Bool {
1891
+ if lhs.conversationId != rhs.conversationId {
1892
+ return false
1893
+ }
1894
+ if lhs.meta != rhs.meta {
1895
+ return false
1896
+ }
1897
+ if lhs.groupStateBytes != rhs.groupStateBytes {
1898
+ return false
1899
+ }
1900
+ return true
1901
+ }
1902
+
1903
+ public func hash(into hasher: inout Hasher) {
1904
+ hasher.combine(conversationId)
1905
+ hasher.combine(meta)
1906
+ hasher.combine(groupStateBytes)
1907
+ }
1908
+ }
1909
+
1910
+ #if swift(>=5.8)
1911
+ @_documentation(visibility: private)
1912
+ #endif
1913
+ public struct FfiConverterTypeCatchupSnapshotEntry: FfiConverterRustBuffer {
1914
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CatchupSnapshotEntry {
1915
+ return
1916
+ try CatchupSnapshotEntry(
1917
+ conversationId: FfiConverterTypeConversationId.read(from: &buf),
1918
+ meta: FfiConverterTypeConversationMeta.read(from: &buf),
1919
+ groupStateBytes: FfiConverterData.read(from: &buf)
1920
+ )
1921
+ }
1922
+
1923
+ public static func write(_ value: CatchupSnapshotEntry, into buf: inout [UInt8]) {
1924
+ FfiConverterTypeConversationId.write(value.conversationId, into: &buf)
1925
+ FfiConverterTypeConversationMeta.write(value.meta, into: &buf)
1926
+ FfiConverterData.write(value.groupStateBytes, into: &buf)
1927
+ }
1928
+ }
1929
+
1930
+ #if swift(>=5.8)
1931
+ @_documentation(visibility: private)
1932
+ #endif
1933
+ public func FfiConverterTypeCatchupSnapshotEntry_lift(_ buf: RustBuffer) throws -> CatchupSnapshotEntry {
1934
+ return try FfiConverterTypeCatchupSnapshotEntry.lift(buf)
1935
+ }
1936
+
1937
+ #if swift(>=5.8)
1938
+ @_documentation(visibility: private)
1939
+ #endif
1940
+ public func FfiConverterTypeCatchupSnapshotEntry_lower(_ value: CatchupSnapshotEntry) -> RustBuffer {
1941
+ return FfiConverterTypeCatchupSnapshotEntry.lower(value)
1942
+ }
1943
+
1944
+ public struct CatchupSnapshotView {
1945
+ public var v: UInt8
1946
+ public var conversationMetas: [CatchupSnapshotEntry]
1947
+ public var lastAppEventsPerConv: [CatchupAppEvent]
1948
+
1949
+ /// Default memberwise initializers are never public by default, so we
1950
+ /// declare one manually.
1951
+ public init(v: UInt8, conversationMetas: [CatchupSnapshotEntry], lastAppEventsPerConv: [CatchupAppEvent]) {
1952
+ self.v = v
1953
+ self.conversationMetas = conversationMetas
1954
+ self.lastAppEventsPerConv = lastAppEventsPerConv
1955
+ }
1956
+ }
1957
+
1958
+ extension CatchupSnapshotView: Equatable, Hashable {
1959
+ public static func == (lhs: CatchupSnapshotView, rhs: CatchupSnapshotView) -> Bool {
1960
+ if lhs.v != rhs.v {
1961
+ return false
1962
+ }
1963
+ if lhs.conversationMetas != rhs.conversationMetas {
1964
+ return false
1965
+ }
1966
+ if lhs.lastAppEventsPerConv != rhs.lastAppEventsPerConv {
1967
+ return false
1968
+ }
1969
+ return true
1970
+ }
1971
+
1972
+ public func hash(into hasher: inout Hasher) {
1973
+ hasher.combine(v)
1974
+ hasher.combine(conversationMetas)
1975
+ hasher.combine(lastAppEventsPerConv)
1976
+ }
1977
+ }
1978
+
1979
+ #if swift(>=5.8)
1980
+ @_documentation(visibility: private)
1981
+ #endif
1982
+ public struct FfiConverterTypeCatchupSnapshotView: FfiConverterRustBuffer {
1983
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CatchupSnapshotView {
1984
+ return
1985
+ try CatchupSnapshotView(
1986
+ v: FfiConverterUInt8.read(from: &buf),
1987
+ conversationMetas: FfiConverterSequenceTypeCatchupSnapshotEntry.read(from: &buf),
1988
+ lastAppEventsPerConv: FfiConverterSequenceTypeCatchupAppEvent.read(from: &buf)
1989
+ )
1990
+ }
1991
+
1992
+ public static func write(_ value: CatchupSnapshotView, into buf: inout [UInt8]) {
1993
+ FfiConverterUInt8.write(value.v, into: &buf)
1994
+ FfiConverterSequenceTypeCatchupSnapshotEntry.write(value.conversationMetas, into: &buf)
1995
+ FfiConverterSequenceTypeCatchupAppEvent.write(value.lastAppEventsPerConv, into: &buf)
1996
+ }
1997
+ }
1998
+
1999
+ #if swift(>=5.8)
2000
+ @_documentation(visibility: private)
2001
+ #endif
2002
+ public func FfiConverterTypeCatchupSnapshotView_lift(_ buf: RustBuffer) throws -> CatchupSnapshotView {
2003
+ return try FfiConverterTypeCatchupSnapshotView.lift(buf)
2004
+ }
2005
+
2006
+ #if swift(>=5.8)
2007
+ @_documentation(visibility: private)
2008
+ #endif
2009
+ public func FfiConverterTypeCatchupSnapshotView_lower(_ value: CatchupSnapshotView) -> RustBuffer {
2010
+ return FfiConverterTypeCatchupSnapshotView.lower(value)
2011
+ }
2012
+
1773
2013
  public struct ConversationId {
1774
2014
  public var value: Data
1775
2015
 
@@ -2277,6 +2517,67 @@ public func FfiConverterTypeIncomingMessage_lower(_ value: IncomingMessage) -> R
2277
2517
  return FfiConverterTypeIncomingMessage.lower(value)
2278
2518
  }
2279
2519
 
2520
+ public struct KeyPackageEntry {
2521
+ public var deviceId: DeviceId
2522
+ public var keyPackage: Data
2523
+
2524
+ /// Default memberwise initializers are never public by default, so we
2525
+ /// declare one manually.
2526
+ public init(deviceId: DeviceId, keyPackage: Data) {
2527
+ self.deviceId = deviceId
2528
+ self.keyPackage = keyPackage
2529
+ }
2530
+ }
2531
+
2532
+ extension KeyPackageEntry: Equatable, Hashable {
2533
+ public static func == (lhs: KeyPackageEntry, rhs: KeyPackageEntry) -> Bool {
2534
+ if lhs.deviceId != rhs.deviceId {
2535
+ return false
2536
+ }
2537
+ if lhs.keyPackage != rhs.keyPackage {
2538
+ return false
2539
+ }
2540
+ return true
2541
+ }
2542
+
2543
+ public func hash(into hasher: inout Hasher) {
2544
+ hasher.combine(deviceId)
2545
+ hasher.combine(keyPackage)
2546
+ }
2547
+ }
2548
+
2549
+ #if swift(>=5.8)
2550
+ @_documentation(visibility: private)
2551
+ #endif
2552
+ public struct FfiConverterTypeKeyPackageEntry: FfiConverterRustBuffer {
2553
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> KeyPackageEntry {
2554
+ return
2555
+ try KeyPackageEntry(
2556
+ deviceId: FfiConverterTypeDeviceId.read(from: &buf),
2557
+ keyPackage: FfiConverterData.read(from: &buf)
2558
+ )
2559
+ }
2560
+
2561
+ public static func write(_ value: KeyPackageEntry, into buf: inout [UInt8]) {
2562
+ FfiConverterTypeDeviceId.write(value.deviceId, into: &buf)
2563
+ FfiConverterData.write(value.keyPackage, into: &buf)
2564
+ }
2565
+ }
2566
+
2567
+ #if swift(>=5.8)
2568
+ @_documentation(visibility: private)
2569
+ #endif
2570
+ public func FfiConverterTypeKeyPackageEntry_lift(_ buf: RustBuffer) throws -> KeyPackageEntry {
2571
+ return try FfiConverterTypeKeyPackageEntry.lift(buf)
2572
+ }
2573
+
2574
+ #if swift(>=5.8)
2575
+ @_documentation(visibility: private)
2576
+ #endif
2577
+ public func FfiConverterTypeKeyPackageEntry_lower(_ value: KeyPackageEntry) -> RustBuffer {
2578
+ return FfiConverterTypeKeyPackageEntry.lower(value)
2579
+ }
2580
+
2280
2581
  public struct LinkingTicket {
2281
2582
  public var v: UInt8
2282
2583
  public var userId: UserId
@@ -2852,23 +3153,48 @@ private struct FfiConverterSequenceString: FfiConverterRustBuffer {
2852
3153
  #if swift(>=5.8)
2853
3154
  @_documentation(visibility: private)
2854
3155
  #endif
2855
- private struct FfiConverterSequenceData: FfiConverterRustBuffer {
2856
- typealias SwiftType = [Data]
3156
+ private struct FfiConverterSequenceTypeCatchupAppEvent: FfiConverterRustBuffer {
3157
+ typealias SwiftType = [CatchupAppEvent]
2857
3158
 
2858
- static func write(_ value: [Data], into buf: inout [UInt8]) {
3159
+ static func write(_ value: [CatchupAppEvent], into buf: inout [UInt8]) {
2859
3160
  let len = Int32(value.count)
2860
3161
  writeInt(&buf, len)
2861
3162
  for item in value {
2862
- FfiConverterData.write(item, into: &buf)
3163
+ FfiConverterTypeCatchupAppEvent.write(item, into: &buf)
2863
3164
  }
2864
3165
  }
2865
3166
 
2866
- static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Data] {
3167
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [CatchupAppEvent] {
2867
3168
  let len: Int32 = try readInt(&buf)
2868
- var seq = [Data]()
3169
+ var seq = [CatchupAppEvent]()
2869
3170
  seq.reserveCapacity(Int(len))
2870
3171
  for _ in 0 ..< len {
2871
- try seq.append(FfiConverterData.read(from: &buf))
3172
+ try seq.append(FfiConverterTypeCatchupAppEvent.read(from: &buf))
3173
+ }
3174
+ return seq
3175
+ }
3176
+ }
3177
+
3178
+ #if swift(>=5.8)
3179
+ @_documentation(visibility: private)
3180
+ #endif
3181
+ private struct FfiConverterSequenceTypeCatchupSnapshotEntry: FfiConverterRustBuffer {
3182
+ typealias SwiftType = [CatchupSnapshotEntry]
3183
+
3184
+ static func write(_ value: [CatchupSnapshotEntry], into buf: inout [UInt8]) {
3185
+ let len = Int32(value.count)
3186
+ writeInt(&buf, len)
3187
+ for item in value {
3188
+ FfiConverterTypeCatchupSnapshotEntry.write(item, into: &buf)
3189
+ }
3190
+ }
3191
+
3192
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [CatchupSnapshotEntry] {
3193
+ let len: Int32 = try readInt(&buf)
3194
+ var seq = [CatchupSnapshotEntry]()
3195
+ seq.reserveCapacity(Int(len))
3196
+ for _ in 0 ..< len {
3197
+ try seq.append(FfiConverterTypeCatchupSnapshotEntry.read(from: &buf))
2872
3198
  }
2873
3199
  return seq
2874
3200
  }
@@ -2974,6 +3300,31 @@ private struct FfiConverterSequenceTypeIncomingMessage: FfiConverterRustBuffer {
2974
3300
  }
2975
3301
  }
2976
3302
 
3303
+ #if swift(>=5.8)
3304
+ @_documentation(visibility: private)
3305
+ #endif
3306
+ private struct FfiConverterSequenceTypeKeyPackageEntry: FfiConverterRustBuffer {
3307
+ typealias SwiftType = [KeyPackageEntry]
3308
+
3309
+ static func write(_ value: [KeyPackageEntry], into buf: inout [UInt8]) {
3310
+ let len = Int32(value.count)
3311
+ writeInt(&buf, len)
3312
+ for item in value {
3313
+ FfiConverterTypeKeyPackageEntry.write(item, into: &buf)
3314
+ }
3315
+ }
3316
+
3317
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [KeyPackageEntry] {
3318
+ let len: Int32 = try readInt(&buf)
3319
+ var seq = [KeyPackageEntry]()
3320
+ seq.reserveCapacity(Int(len))
3321
+ for _ in 0 ..< len {
3322
+ try seq.append(FfiConverterTypeKeyPackageEntry.read(from: &buf))
3323
+ }
3324
+ return seq
3325
+ }
3326
+ }
3327
+
2977
3328
  #if swift(>=5.8)
2978
3329
  @_documentation(visibility: private)
2979
3330
  #endif
@@ -3112,12 +3463,38 @@ public func uniffiForeignFutureHandleCountPing() -> Int {
3112
3463
  UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.count
3113
3464
  }
3114
3465
 
3466
+ public func decodeCatchupSnapshot(snapshotBytes: Data) throws -> CatchupSnapshotView {
3467
+ return try FfiConverterTypeCatchupSnapshotView.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3468
+ uniffi_ping_ffi_fn_func_decode_catchup_snapshot(
3469
+ FfiConverterData.lower(snapshotBytes), $0
3470
+ )
3471
+ })
3472
+ }
3473
+
3115
3474
  public func generateIdentityExport() -> Data {
3116
3475
  return try! FfiConverterData.lift(try! rustCall {
3117
3476
  uniffi_ping_ffi_fn_func_generate_identity_export($0)
3118
3477
  })
3119
3478
  }
3120
3479
 
3480
+ public func openLinkingTicket(sealed: Data, newDevicePriv: Data) throws -> LinkingTicket {
3481
+ return try FfiConverterTypeLinkingTicket.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3482
+ uniffi_ping_ffi_fn_func_open_linking_ticket(
3483
+ FfiConverterData.lower(sealed),
3484
+ FfiConverterData.lower(newDevicePriv), $0
3485
+ )
3486
+ })
3487
+ }
3488
+
3489
+ public func sealLinkingTicket(ticket: LinkingTicket, newDevicePub: Data) throws -> Data {
3490
+ return try FfiConverterData.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3491
+ uniffi_ping_ffi_fn_func_seal_linking_ticket(
3492
+ FfiConverterTypeLinkingTicket.lower(ticket),
3493
+ FfiConverterData.lower(newDevicePub), $0
3494
+ )
3495
+ })
3496
+ }
3497
+
3121
3498
  private enum InitializationResult {
3122
3499
  case ok
3123
3500
  case contractVersionMismatch
@@ -3134,19 +3511,28 @@ private var initializationResult: InitializationResult = {
3134
3511
  if bindings_contract_version != scaffolding_contract_version {
3135
3512
  return InitializationResult.contractVersionMismatch
3136
3513
  }
3514
+ if uniffi_ping_ffi_checksum_func_decode_catchup_snapshot() != 40316 {
3515
+ return InitializationResult.apiChecksumMismatch
3516
+ }
3137
3517
  if uniffi_ping_ffi_checksum_func_generate_identity_export() != 15026 {
3138
3518
  return InitializationResult.apiChecksumMismatch
3139
3519
  }
3520
+ if uniffi_ping_ffi_checksum_func_open_linking_ticket() != 64091 {
3521
+ return InitializationResult.apiChecksumMismatch
3522
+ }
3523
+ if uniffi_ping_ffi_checksum_func_seal_linking_ticket() != 37263 {
3524
+ return InitializationResult.apiChecksumMismatch
3525
+ }
3140
3526
  if uniffi_ping_ffi_checksum_method_messageobserver_on_application_message() != 7190 {
3141
3527
  return InitializationResult.apiChecksumMismatch
3142
3528
  }
3143
3529
  if uniffi_ping_ffi_checksum_method_messageobserver_on_conversation_updated() != 50154 {
3144
3530
  return InitializationResult.apiChecksumMismatch
3145
3531
  }
3146
- if uniffi_ping_ffi_checksum_method_messagingclient_add_members() != 59894 {
3532
+ if uniffi_ping_ffi_checksum_method_messagingclient_add_members() != 2224 {
3147
3533
  return InitializationResult.apiChecksumMismatch
3148
3534
  }
3149
- if uniffi_ping_ffi_checksum_method_messagingclient_build_linking_ticket() != 54304 {
3535
+ if uniffi_ping_ffi_checksum_method_messagingclient_build_linking_ticket() != 21631 {
3150
3536
  return InitializationResult.apiChecksumMismatch
3151
3537
  }
3152
3538
  if uniffi_ping_ffi_checksum_method_messagingclient_consume_linking_ticket() != 11953 {
@@ -3161,9 +3547,18 @@ private var initializationResult: InitializationResult = {
3161
3547
  if uniffi_ping_ffi_checksum_method_messagingclient_device_info() != 51623 {
3162
3548
  return InitializationResult.apiChecksumMismatch
3163
3549
  }
3550
+ if uniffi_ping_ffi_checksum_method_messagingclient_export_conversation_secret() != 18264 {
3551
+ return InitializationResult.apiChecksumMismatch
3552
+ }
3553
+ if uniffi_ping_ffi_checksum_method_messagingclient_export_conversation_state_snapshot() != 48273 {
3554
+ return InitializationResult.apiChecksumMismatch
3555
+ }
3164
3556
  if uniffi_ping_ffi_checksum_method_messagingclient_fresh_key_package() != 54233 {
3165
3557
  return InitializationResult.apiChecksumMismatch
3166
3558
  }
3559
+ if uniffi_ping_ffi_checksum_method_messagingclient_import_state_snapshot() != 56077 {
3560
+ return InitializationResult.apiChecksumMismatch
3561
+ }
3167
3562
  if uniffi_ping_ffi_checksum_method_messagingclient_join_conversation() != 48291 {
3168
3563
  return InitializationResult.apiChecksumMismatch
3169
3564
  }
@@ -3179,7 +3574,7 @@ private var initializationResult: InitializationResult = {
3179
3574
  if uniffi_ping_ffi_checksum_method_messagingclient_remove_members() != 62054 {
3180
3575
  return InitializationResult.apiChecksumMismatch
3181
3576
  }
3182
- if uniffi_ping_ffi_checksum_method_messagingclient_revoke_device() != 63664 {
3577
+ if uniffi_ping_ffi_checksum_method_messagingclient_revoke_device() != 28772 {
3183
3578
  return InitializationResult.apiChecksumMismatch
3184
3579
  }
3185
3580
  if uniffi_ping_ffi_checksum_method_messagingclient_send() != 11574 {
@@ -3215,7 +3610,7 @@ private var initializationResult: InitializationResult = {
3215
3610
  if uniffi_ping_ffi_checksum_method_transport_send() != 46493 {
3216
3611
  return InitializationResult.apiChecksumMismatch
3217
3612
  }
3218
- if uniffi_ping_ffi_checksum_constructor_messagingclient_init() != 38981 {
3613
+ if uniffi_ping_ffi_checksum_constructor_messagingclient_init() != 35443 {
3219
3614
  return InitializationResult.apiChecksumMismatch
3220
3615
  }
3221
3616
 
@@ -49,9 +49,17 @@ RCT_EXTERN_METHOD(generateIdentityExport: (RCTPromiseResolveBlock)resolve
49
49
  rejecter: (RCTPromiseRejectBlock)reject)
50
50
 
51
51
  // Stage 4b: MessagingClient lifecycle.
52
+ // [CR-4] sqlitePath + sqliteEncryptionKeyB64 are optional (nullable) — passing nil for
53
+ // path falls back to the in-memory provider.
54
+ // `deviceSigningSecretKeyB64` is the optional 32-byte Ed25519 secret the SDK adopts
55
+ // as its device signing key on first init — used to align device_id with the host
56
+ // auth layer's JWT claim. Pass nil to keep the random-key default.
52
57
  RCT_EXTERN_METHOD(initClient: (NSString *)identityB64
53
58
  deviceLabel: (NSString *)deviceLabel
54
59
  nowMs: (double)nowMs
60
+ sqlitePath: (NSString *)sqlitePath
61
+ sqliteEncryptionKeyB64: (NSString *)sqliteEncryptionKeyB64
62
+ deviceSigningSecretKeyB64: (NSString *)deviceSigningSecretKeyB64
55
63
  resolver: (RCTPromiseResolveBlock)resolve
56
64
  rejecter: (RCTPromiseRejectBlock)reject)
57
65
 
@@ -81,8 +89,9 @@ RCT_EXTERN_METHOD(sendMessage: (NSArray *)conversationId
81
89
  resolver: (RCTPromiseResolveBlock)resolve
82
90
  rejecter: (RCTPromiseRejectBlock)reject)
83
91
 
92
+ // [CR-2] entries are `{ deviceId: [Int], keyPackage: [Int] }` dicts.
84
93
  RCT_EXTERN_METHOD(addMembers: (NSArray *)conversationId
85
- keyPackages: (NSArray *)keyPackages
94
+ entries: (NSArray *)entries
86
95
  nowMs: (double)nowMs
87
96
  resolver: (RCTPromiseResolveBlock)resolve
88
97
  rejecter: (RCTPromiseRejectBlock)reject)
@@ -114,8 +123,10 @@ RCT_EXTERN_METHOD(setObserver: (RCTPromiseResolveBlock)resolve
114
123
  rejecter: (RCTPromiseRejectBlock)reject)
115
124
 
116
125
  // Stage 4f: linking + revocation.
126
+ // [CR-13] lastAppEvents is an array of { conversationId, appEventBytes } dicts.
117
127
  RCT_EXTERN_METHOD(buildLinkingTicket: (NSArray *)newDeviceId
118
128
  newDeviceKp: (NSArray *)newDeviceKp
129
+ lastAppEvents: (NSArray *)lastAppEvents
119
130
  nowMs: (double)nowMs
120
131
  resolver: (RCTPromiseResolveBlock)resolve
121
132
  rejecter: (RCTPromiseRejectBlock)reject)
@@ -130,6 +141,25 @@ RCT_EXTERN_METHOD(revokeDevice: (NSArray *)deviceId
130
141
  resolver: (RCTPromiseResolveBlock)resolve
131
142
  rejecter: (RCTPromiseRejectBlock)reject)
132
143
 
144
+ // [CR-8] Export a derived secret from a conversation's MLS exporter.
145
+ RCT_EXTERN_METHOD(exportConversationSecret: (NSArray *)conversationId
146
+ label: (NSString *)label
147
+ context: (NSArray *)context
148
+ length: (nonnull NSNumber *)length
149
+ resolver: (RCTPromiseResolveBlock)resolve
150
+ rejecter: (RCTPromiseRejectBlock)reject)
151
+
152
+ // [CR-7] Export/import a portable MLS state snapshot for cross-device transfer.
153
+ RCT_EXTERN_METHOD(exportConversationStateSnapshot: (NSArray *)conversationId
154
+ nowMs: (double)nowMs
155
+ resolver: (RCTPromiseResolveBlock)resolve
156
+ rejecter: (RCTPromiseRejectBlock)reject)
157
+
158
+ RCT_EXTERN_METHOD(importStateSnapshot: (NSArray *)snapshotBytes
159
+ nowMs: (double)nowMs
160
+ resolver: (RCTPromiseResolveBlock)resolve
161
+ rejecter: (RCTPromiseRejectBlock)reject)
162
+
133
163
  // Stage 5 polish: macOS clipboard helper.
134
164
  RCT_EXTERN_METHOD(setClipboard: (NSString *)text
135
165
  resolver: (RCTPromiseResolveBlock)resolve