ping-openmls-sdk-react-native-macos 0.7.15 → 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.
- package/ios/PingNativeModule.swift +23 -0
- package/ios/TypeBridge.swift +13 -0
- package/package.json +1 -1
- package/src/MessagingClient.ts +17 -0
- package/src/NativePing.ts +7 -0
|
@@ -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:)
|
package/ios/TypeBridge.swift
CHANGED
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ping-openmls-sdk-react-native-macos",
|
|
3
|
-
"version": "0.7.
|
|
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",
|
package/src/MessagingClient.ts
CHANGED
|
@@ -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
|
|