ping-openmls-sdk-react-native-macos 0.7.13 → 0.7.15

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
  }
@@ -155,6 +155,21 @@ RCT_EXTERN_METHOD(openLinkingTicket: (NSArray *)sealed
155
155
  resolver: (RCTPromiseResolveBlock)resolve
156
156
  rejecter: (RCTPromiseRejectBlock)reject)
157
157
 
158
+ // Generic HPKE-Base seal/open of arbitrary bytes under a caller-supplied `info`.
159
+ // Free functions — one shared HPKE for app-layer envelopes (device-linking auth
160
+ // envelope) so platforms stop hand-rolling HPKE that drifts cross-platform.
161
+ RCT_EXTERN_METHOD(hpkeSeal: (NSArray *)plaintext
162
+ recipientPub: (NSArray *)recipientPub
163
+ info: (NSArray *)info
164
+ resolver: (RCTPromiseResolveBlock)resolve
165
+ rejecter: (RCTPromiseRejectBlock)reject)
166
+
167
+ RCT_EXTERN_METHOD(hpkeOpen: (NSArray *)sealed
168
+ recipientPriv: (NSArray *)recipientPriv
169
+ info: (NSArray *)info
170
+ resolver: (RCTPromiseResolveBlock)resolve
171
+ rejecter: (RCTPromiseRejectBlock)reject)
172
+
158
173
  RCT_EXTERN_METHOD(revokeDevice: (NSArray *)deviceId
159
174
  nowMs: (double)nowMs
160
175
  resolver: (RCTPromiseResolveBlock)resolve
@@ -709,6 +709,48 @@ public final class PingNative: RCTEventEmitter {
709
709
  }
710
710
  }
711
711
 
712
+ /// Generic HPKE-Base seal of arbitrary bytes ([CR-3] auth-envelope sharing).
713
+ /// Free function — like `openLinkingTicket`, no `client` needed. One shared
714
+ /// HPKE so the desktop link host stops hand-rolling HPKE that drifts.
715
+ @objc(hpkeSeal:recipientPub:info:resolver:rejecter:)
716
+ public func hpkeSealNative(
717
+ _ plaintextBytes: NSArray,
718
+ recipientPub recipientPubBytes: NSArray,
719
+ info infoBytes: NSArray,
720
+ resolver resolve: @escaping RCTPromiseResolveBlock,
721
+ rejecter reject: @escaping RCTPromiseRejectBlock
722
+ ) {
723
+ do {
724
+ let plaintext = try TypeBridge.decodeBytesOrThrow(plaintextBytes, field: "plaintext")
725
+ let pub = try TypeBridge.decodeBytesOrThrow(recipientPubBytes, field: "recipientPub")
726
+ let info = try TypeBridge.decodeBytesOrThrow(infoBytes, field: "info")
727
+ let out = try hpkeSeal(plaintext: plaintext, recipientPub: pub, info: info)
728
+ resolve(TypeBridge.encodeBytes(out))
729
+ } catch {
730
+ reject("HpkeSealFailed", String(describing: error), error)
731
+ }
732
+ }
733
+
734
+ /// Generic HPKE-Base open — inverse of `hpkeSeal`.
735
+ @objc(hpkeOpen:recipientPriv:info:resolver:rejecter:)
736
+ public func hpkeOpenNative(
737
+ _ sealedBytes: NSArray,
738
+ recipientPriv recipientPrivBytes: NSArray,
739
+ info infoBytes: NSArray,
740
+ resolver resolve: @escaping RCTPromiseResolveBlock,
741
+ rejecter reject: @escaping RCTPromiseRejectBlock
742
+ ) {
743
+ do {
744
+ let sealed = try TypeBridge.decodeBytesOrThrow(sealedBytes, field: "sealed")
745
+ let priv = try TypeBridge.decodeBytesOrThrow(recipientPrivBytes, field: "recipientPriv")
746
+ let info = try TypeBridge.decodeBytesOrThrow(infoBytes, field: "info")
747
+ let out = try hpkeOpen(sealed: sealed, recipientPriv: priv, info: info)
748
+ resolve(TypeBridge.encodeBytes(out))
749
+ } catch {
750
+ reject("HpkeOpenFailed", String(describing: error), error)
751
+ }
752
+ }
753
+
712
754
  /// Revoke a device ([CR-2]). Returns the array of Commit envelopes the SDK
713
755
  /// produced — one per conversation the device was a locally-known leaf in.
714
756
  /// Empty array means the device wasn't locally known (scope limit per CR-2).
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.13",
3
+ "version": "0.7.15",
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",
@@ -400,6 +400,40 @@ export class MessagingClient {
400
400
  return decodeLinkingTicket(raw);
401
401
  }
402
402
 
403
+ /**
404
+ * Generic HPKE-Base seal of `plaintext` to `recipientPub` (32-byte X25519)
405
+ * under `info`. One shared HPKE implementation so app layers (e.g. the
406
+ * device-linking auth envelope) stop hand-rolling per-platform HPKE that
407
+ * drifts and breaks cross-platform. Mirrors the wasm SDK's
408
+ * `MessagingClient.hpkeSeal`.
409
+ */
410
+ static async hpkeSeal(
411
+ plaintext: Uint8Array,
412
+ recipientPub: Uint8Array,
413
+ info: Uint8Array,
414
+ ): Promise<Uint8Array> {
415
+ const out = await NativePing.hpkeSeal(
416
+ Array.from(plaintext),
417
+ Array.from(recipientPub),
418
+ Array.from(info),
419
+ );
420
+ return Uint8Array.from(out);
421
+ }
422
+
423
+ /** Generic HPKE-Base open — inverse of {@link hpkeSeal}. `info` must match the sender. */
424
+ static async hpkeOpen(
425
+ sealed: Uint8Array,
426
+ recipientPriv: Uint8Array,
427
+ info: Uint8Array,
428
+ ): Promise<Uint8Array> {
429
+ const out = await NativePing.hpkeOpen(
430
+ Array.from(sealed),
431
+ Array.from(recipientPriv),
432
+ Array.from(info),
433
+ );
434
+ return Uint8Array.from(out);
435
+ }
436
+
403
437
  /**
404
438
  * Admit a freshly-linked device to every chat in `entries` — one Commit +
405
439
  * Welcome per chat, with per-chat outcomes. Host calls this AFTER
package/src/NativePing.ts CHANGED
@@ -213,6 +213,15 @@ export interface Spec extends TurboModule {
213
213
  newDevicePriv: number[],
214
214
  ): Promise<Record<string, unknown>>;
215
215
 
216
+ /**
217
+ * Generic HPKE-Base seal/open of arbitrary bytes under a caller-supplied
218
+ * `info`. One shared HPKE for app-layer envelopes (e.g. device-linking auth
219
+ * envelope) so platforms stop hand-rolling HPKE that drifts cross-platform.
220
+ * `recipientPub`/`recipientPriv` are 32-byte X25519 keys.
221
+ */
222
+ hpkeSeal(plaintext: number[], recipientPub: number[], info: number[]): Promise<number[]>;
223
+ hpkeOpen(sealed: number[], recipientPriv: number[], info: number[]): Promise<number[]>;
224
+
216
225
  /**
217
226
  * Revoke a device ([CR-2]). Returns one Commit envelope per conversation the
218
227
  * device was a locally-known leaf in. Empty array means the device wasn't locally