ping-openmls-sdk-react-native-macos 0.7.14 → 0.7.16

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
@@ -752,6 +752,8 @@ public protocol MessagingClientProtocol: AnyObject {
752
752
 
753
753
  func listDevices() -> [DeviceInfo]
754
754
 
755
+ func members(conversationId: ConversationId) -> [MemberInfo]
756
+
755
757
  func processEnvelope(envelope: MessageEnvelope, nowMs: UInt64) async throws -> IncomingMessage?
756
758
 
757
759
  func removeMembers(conversationId: ConversationId, leafIndexes: [UInt32], nowMs: UInt64) async throws
@@ -998,6 +1000,13 @@ open class MessagingClient:
998
1000
  })
999
1001
  }
1000
1002
 
1003
+ open func members(conversationId: ConversationId) -> [MemberInfo] {
1004
+ return try! FfiConverterSequenceTypeMemberInfo.lift(try! rustCall {
1005
+ uniffi_ping_ffi_fn_method_messagingclient_members(self.uniffiClonePointer(),
1006
+ FfiConverterTypeConversationId.lower(conversationId), $0)
1007
+ })
1008
+ }
1009
+
1001
1010
  open func processEnvelope(envelope: MessageEnvelope, nowMs: UInt64) async throws -> IncomingMessage? {
1002
1011
  return
1003
1012
  try await uniffiRustCallAsync(
@@ -3014,6 +3023,67 @@ public func FfiConverterTypeLinkingTicket_lower(_ value: LinkingTicket) -> RustB
3014
3023
  return FfiConverterTypeLinkingTicket.lower(value)
3015
3024
  }
3016
3025
 
3026
+ public struct MemberInfo {
3027
+ public var userId: UserId
3028
+ public var leafIndex: UInt32
3029
+
3030
+ /// Default memberwise initializers are never public by default, so we
3031
+ /// declare one manually.
3032
+ public init(userId: UserId, leafIndex: UInt32) {
3033
+ self.userId = userId
3034
+ self.leafIndex = leafIndex
3035
+ }
3036
+ }
3037
+
3038
+ extension MemberInfo: Equatable, Hashable {
3039
+ public static func == (lhs: MemberInfo, rhs: MemberInfo) -> Bool {
3040
+ if lhs.userId != rhs.userId {
3041
+ return false
3042
+ }
3043
+ if lhs.leafIndex != rhs.leafIndex {
3044
+ return false
3045
+ }
3046
+ return true
3047
+ }
3048
+
3049
+ public func hash(into hasher: inout Hasher) {
3050
+ hasher.combine(userId)
3051
+ hasher.combine(leafIndex)
3052
+ }
3053
+ }
3054
+
3055
+ #if swift(>=5.8)
3056
+ @_documentation(visibility: private)
3057
+ #endif
3058
+ public struct FfiConverterTypeMemberInfo: FfiConverterRustBuffer {
3059
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MemberInfo {
3060
+ return
3061
+ try MemberInfo(
3062
+ userId: FfiConverterTypeUserId.read(from: &buf),
3063
+ leafIndex: FfiConverterUInt32.read(from: &buf)
3064
+ )
3065
+ }
3066
+
3067
+ public static func write(_ value: MemberInfo, into buf: inout [UInt8]) {
3068
+ FfiConverterTypeUserId.write(value.userId, into: &buf)
3069
+ FfiConverterUInt32.write(value.leafIndex, into: &buf)
3070
+ }
3071
+ }
3072
+
3073
+ #if swift(>=5.8)
3074
+ @_documentation(visibility: private)
3075
+ #endif
3076
+ public func FfiConverterTypeMemberInfo_lift(_ buf: RustBuffer) throws -> MemberInfo {
3077
+ return try FfiConverterTypeMemberInfo.lift(buf)
3078
+ }
3079
+
3080
+ #if swift(>=5.8)
3081
+ @_documentation(visibility: private)
3082
+ #endif
3083
+ public func FfiConverterTypeMemberInfo_lower(_ value: MemberInfo) -> RustBuffer {
3084
+ return FfiConverterTypeMemberInfo.lower(value)
3085
+ }
3086
+
3017
3087
  public struct MessageEnvelope {
3018
3088
  public var v: UInt8
3019
3089
  public var conversationId: ConversationId
@@ -3947,6 +4017,31 @@ private struct FfiConverterSequenceTypeKeyPackageEntry: FfiConverterRustBuffer {
3947
4017
  }
3948
4018
  }
3949
4019
 
4020
+ #if swift(>=5.8)
4021
+ @_documentation(visibility: private)
4022
+ #endif
4023
+ private struct FfiConverterSequenceTypeMemberInfo: FfiConverterRustBuffer {
4024
+ typealias SwiftType = [MemberInfo]
4025
+
4026
+ static func write(_ value: [MemberInfo], into buf: inout [UInt8]) {
4027
+ let len = Int32(value.count)
4028
+ writeInt(&buf, len)
4029
+ for item in value {
4030
+ FfiConverterTypeMemberInfo.write(item, into: &buf)
4031
+ }
4032
+ }
4033
+
4034
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [MemberInfo] {
4035
+ let len: Int32 = try readInt(&buf)
4036
+ var seq = [MemberInfo]()
4037
+ seq.reserveCapacity(Int(len))
4038
+ for _ in 0 ..< len {
4039
+ try seq.append(FfiConverterTypeMemberInfo.read(from: &buf))
4040
+ }
4041
+ return seq
4042
+ }
4043
+ }
4044
+
3950
4045
  #if swift(>=5.8)
3951
4046
  @_documentation(visibility: private)
3952
4047
  #endif
@@ -4318,6 +4413,9 @@ private var initializationResult: InitializationResult = {
4318
4413
  if uniffi_ping_ffi_checksum_method_messagingclient_list_devices() != 10141 {
4319
4414
  return InitializationResult.apiChecksumMismatch
4320
4415
  }
4416
+ if uniffi_ping_ffi_checksum_method_messagingclient_members() != 51351 {
4417
+ return InitializationResult.apiChecksumMismatch
4418
+ }
4321
4419
  if uniffi_ping_ffi_checksum_method_messagingclient_process_envelope() != 11247 {
4322
4420
  return InitializationResult.apiChecksumMismatch
4323
4421
  }
@@ -580,6 +580,29 @@ public final class PingNative: RCTEventEmitter {
580
580
  resolve(TypeBridge.encodeConversationMetaArray(metas))
581
581
  }
582
582
 
583
+ /// Member roster for a conversation, recovered from the MLS group's leaf
584
+ /// credentials. One entry per device leaf — JS dedups by `user_id` for a
585
+ /// per-user list. Empty for an unknown id. Sync (the FFI call is sync +
586
+ /// non-throwing); only the id decode can throw.
587
+ @objc(members:resolver:rejecter:)
588
+ public func membersNative(
589
+ _ conversationIdBytes: NSArray,
590
+ resolver resolve: @escaping RCTPromiseResolveBlock,
591
+ rejecter reject: @escaping RCTPromiseRejectBlock
592
+ ) {
593
+ guard let client = self.client else {
594
+ reject("NotInitialised", "MessagingClient not initialised", nil)
595
+ return
596
+ }
597
+ do {
598
+ let convId = try TypeBridge.decodeConversationId(conversationIdBytes)
599
+ let members = client.members(conversationId: convId)
600
+ resolve(TypeBridge.encodeMemberInfoArray(members))
601
+ } catch {
602
+ reject("MembersFailed", String(describing: error), error)
603
+ }
604
+ }
605
+
583
606
  /// Returns metadata for every device the client knows about (for v0.1, just the
584
607
  /// local device — see ping-ffi/lib.rs note).
585
608
  @objc(listDevices:rejecter:)
@@ -217,6 +217,19 @@ enum TypeBridge {
217
217
  return ms.map { encodeConversationMeta($0) }
218
218
  }
219
219
 
220
+ // MARK: - MemberInfo
221
+
222
+ static func encodeMemberInfo(_ m: MemberInfo) -> [String: Any] {
223
+ return [
224
+ "user_id": encodeUserId(m.userId),
225
+ "leaf_index": Int(m.leafIndex),
226
+ ]
227
+ }
228
+
229
+ static func encodeMemberInfoArray(_ ms: [MemberInfo]) -> [[String: Any]] {
230
+ return ms.map { encodeMemberInfo($0) }
231
+ }
232
+
220
233
  // MARK: - DeviceInfo
221
234
 
222
235
  static func encodeDeviceInfo(_ d: DeviceInfo) -> [String: Any] {
package/ios/pingFFI.h CHANGED
@@ -447,6 +447,11 @@ RustBuffer uniffi_ping_ffi_fn_method_messagingclient_list_conversations(void*_No
447
447
  RustBuffer uniffi_ping_ffi_fn_method_messagingclient_list_devices(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status
448
448
  );
449
449
  #endif
450
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_MEMBERS
451
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_MEMBERS
452
+ RustBuffer uniffi_ping_ffi_fn_method_messagingclient_members(void*_Nonnull ptr, RustBuffer conversation_id, RustCallStatus *_Nonnull out_status
453
+ );
454
+ #endif
450
455
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_PROCESS_ENVELOPE
451
456
  #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_PROCESS_ENVELOPE
452
457
  uint64_t uniffi_ping_ffi_fn_method_messagingclient_process_envelope(void*_Nonnull ptr, RustBuffer envelope, uint64_t now_ms
@@ -1055,6 +1060,12 @@ uint16_t uniffi_ping_ffi_checksum_method_messagingclient_list_conversations(void
1055
1060
  #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_METHOD_MESSAGINGCLIENT_LIST_DEVICES
1056
1061
  uint16_t uniffi_ping_ffi_checksum_method_messagingclient_list_devices(void
1057
1062
 
1063
+ );
1064
+ #endif
1065
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_METHOD_MESSAGINGCLIENT_MEMBERS
1066
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_METHOD_MESSAGINGCLIENT_MEMBERS
1067
+ uint16_t uniffi_ping_ffi_checksum_method_messagingclient_members(void
1068
+
1058
1069
  );
1059
1070
  #endif
1060
1071
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_METHOD_MESSAGINGCLIENT_PROCESS_ENVELOPE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ping-openmls-sdk-react-native-macos",
3
- "version": "0.7.14",
3
+ "version": "0.7.16",
4
4
  "description": "Real MLS for React Native macOS apps — wraps the ping-openmls-sdk Rust core via UniFFI.",
5
5
  "homepage": "https://github.com/AMP-Media-Development/ping-openmls-sdk",
6
6
  "license": "Apache-2.0",
@@ -317,6 +317,23 @@ export class MessagingClient {
317
317
  return arr.map(decodeConversationMeta);
318
318
  }
319
319
 
320
+ /**
321
+ * Member roster for a conversation, recovered from the MLS group's leaf
322
+ * credentials (no network). One entry per device leaf — dedup by
323
+ * `user_id` for a per-user list. Empty for an unknown id. Shape matches
324
+ * the web JS SDK (`{ user_id, leaf_index }`) so shared consumers can read
325
+ * either binding uniformly.
326
+ */
327
+ async members(
328
+ conversationId: Uint8Array,
329
+ ): Promise<Array<{ user_id: Uint8Array; leaf_index: number }>> {
330
+ const arr = await NativePing.members(Array.from(conversationId));
331
+ return (arr ?? []).map((m) => ({
332
+ user_id: Uint8Array.from((m.user_id as number[]) ?? []),
333
+ leaf_index: Number(m.leaf_index ?? 0),
334
+ }));
335
+ }
336
+
320
337
  /** Device info for every known device. v0.1: just the local device. */
321
338
  async listDevices(): Promise<DeviceInfo[]> {
322
339
  const arr = await NativePing.listDevices();
package/src/NativePing.ts CHANGED
@@ -168,6 +168,13 @@ export interface Spec extends TurboModule {
168
168
  /** Metadata for every open conversation. */
169
169
  listConversations(): Promise<Record<string, unknown>[]>;
170
170
 
171
+ /**
172
+ * Member roster for a conversation — `[{ user_id, leaf_index }]`, one entry
173
+ * per device leaf (dedup by `user_id` for a per-user list). Recovered from
174
+ * MLS leaf credentials; empty for an unknown id.
175
+ */
176
+ members(conversationId: number[]): Promise<Record<string, unknown>[]>;
177
+
171
178
  /** Metadata for every known device (v0.1: just the local device). */
172
179
  listDevices(): Promise<Record<string, unknown>[]>;
173
180