ping-openmls-sdk-react-native-macos 0.7.17 → 0.8.2

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
@@ -742,7 +742,7 @@ public protocol MessagingClientProtocol: AnyObject {
742
742
 
743
743
  func exportConversationStateSnapshot(conversationId: ConversationId, nowMs: UInt64) throws -> Data
744
744
 
745
- func freshKeyPackage() throws -> Data
745
+ func freshKeyPackage() async throws -> Data
746
746
 
747
747
  func importStateSnapshot(snapshotBytes: Data, nowMs: UInt64) async throws -> ConversationId
748
748
 
@@ -948,10 +948,20 @@ open class MessagingClient:
948
948
  })
949
949
  }
950
950
 
951
- open func freshKeyPackage() throws -> Data {
952
- return try FfiConverterData.lift(rustCallWithError(FfiConverterTypePingError.lift) {
953
- uniffi_ping_ffi_fn_method_messagingclient_fresh_key_package(self.uniffiClonePointer(), $0)
954
- })
951
+ open func freshKeyPackage() async throws -> Data {
952
+ return
953
+ try await uniffiRustCallAsync(
954
+ rustFutureFunc: {
955
+ uniffi_ping_ffi_fn_method_messagingclient_fresh_key_package(
956
+ self.uniffiClonePointer()
957
+ )
958
+ },
959
+ pollFunc: ffi_ping_ffi_rust_future_poll_rust_buffer,
960
+ completeFunc: ffi_ping_ffi_rust_future_complete_rust_buffer,
961
+ freeFunc: ffi_ping_ffi_rust_future_free_rust_buffer,
962
+ liftFunc: FfiConverterData.lift,
963
+ errorHandler: FfiConverterTypePingError.lift
964
+ )
955
965
  }
956
966
 
957
967
  open func importStateSnapshot(snapshotBytes: Data, nowMs: UInt64) async throws -> ConversationId {
@@ -4398,7 +4408,7 @@ private var initializationResult: InitializationResult = {
4398
4408
  if uniffi_ping_ffi_checksum_method_messagingclient_export_conversation_state_snapshot() != 48273 {
4399
4409
  return InitializationResult.apiChecksumMismatch
4400
4410
  }
4401
- if uniffi_ping_ffi_checksum_method_messagingclient_fresh_key_package() != 54233 {
4411
+ if uniffi_ping_ffi_checksum_method_messagingclient_fresh_key_package() != 14039 {
4402
4412
  return InitializationResult.apiChecksumMismatch
4403
4413
  }
4404
4414
  if uniffi_ping_ffi_checksum_method_messagingclient_import_state_snapshot() != 56077 {
@@ -310,21 +310,24 @@ public final class PingNative: RCTEventEmitter {
310
310
  // MARK: - Messaging methods (stage 4c)
311
311
 
312
312
  /// Generate a fresh KeyPackage that peers can use to add this device to their groups.
313
- /// Synchronous on the Rust side but we wrap as a Promise for JS consistency.
313
+ /// `async` on the Rust side now (it durably checkpoints the generated private keys
314
+ /// before returning); wrapped as a Promise for JS consistency.
314
315
  @objc(freshKeyPackage:rejecter:)
315
316
  public func freshKeyPackageNative(
316
317
  _ resolve: @escaping RCTPromiseResolveBlock,
317
318
  rejecter reject: @escaping RCTPromiseRejectBlock
318
319
  ) {
319
- guard let client = self.client else {
320
- reject("NotInitialised", "MessagingClient not initialised", nil)
321
- return
322
- }
323
- do {
324
- let kp = try client.freshKeyPackage()
325
- resolve(TypeBridge.encodeBytes(kp))
326
- } catch {
327
- reject("FreshKeyPackageFailed", String(describing: error), error)
320
+ Task {
321
+ guard let client = self.client else {
322
+ reject("NotInitialised", "MessagingClient not initialised", nil)
323
+ return
324
+ }
325
+ do {
326
+ let kp = try await client.freshKeyPackage()
327
+ resolve(TypeBridge.encodeBytes(kp))
328
+ } catch {
329
+ reject("FreshKeyPackageFailed", String(describing: error), error)
330
+ }
328
331
  }
329
332
  }
330
333
 
package/ios/pingFFI.h CHANGED
@@ -424,7 +424,7 @@ RustBuffer uniffi_ping_ffi_fn_method_messagingclient_export_conversation_state_s
424
424
  #endif
425
425
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_FRESH_KEY_PACKAGE
426
426
  #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_FRESH_KEY_PACKAGE
427
- RustBuffer uniffi_ping_ffi_fn_method_messagingclient_fresh_key_package(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status
427
+ uint64_t uniffi_ping_ffi_fn_method_messagingclient_fresh_key_package(void*_Nonnull ptr
428
428
  );
429
429
  #endif
430
430
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_METHOD_MESSAGINGCLIENT_IMPORT_STATE_SNAPSHOT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ping-openmls-sdk-react-native-macos",
3
- "version": "0.7.17",
3
+ "version": "0.8.2",
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",
@@ -189,10 +189,25 @@ export class MessagingClient {
189
189
  }
190
190
  } catch (e) {
191
191
  // Expected for foreign Welcomes (other device's KP) or unknown-conv traffic.
192
- // Logged for diagnostic value during stage 5 drop to silent in production.
192
+ // In DEV we log the FULL message + stack: the previous 80-char
193
+ // truncation hid the real cause (e.g. an "Exception in HostFunction"
194
+ // thrown deep inside a storage/observer round-trip during join).
195
+ // In prod we keep the short, low-noise line.
193
196
  const msg = e instanceof Error ? e.message : String(e);
194
- // eslint-disable-next-line no-console
195
- console.log("[ws-subscribe] " + String(kind) + " dropped: " + msg.slice(0, 80));
197
+ const stack = e instanceof Error ? e.stack : undefined;
198
+ const isDev =
199
+ typeof globalThis !== "undefined" &&
200
+ (globalThis as { __DEV__?: boolean }).__DEV__ === true;
201
+ if (isDev) {
202
+ // eslint-disable-next-line no-console
203
+ console.warn(
204
+ "[ws-subscribe] " + String(kind) + " dropped: " + msg +
205
+ (stack ? "\n" + stack : ""),
206
+ );
207
+ } else {
208
+ // eslint-disable-next-line no-console
209
+ console.log("[ws-subscribe] " + String(kind) + " dropped: " + msg.slice(0, 80));
210
+ }
196
211
  }
197
212
  })();
198
213
  });
@@ -43,8 +43,25 @@ export function connectStorageBridge(storage: Storage): () => void {
43
43
  return () => subscription.remove();
44
44
  }
45
45
 
46
+ function isDev(): boolean {
47
+ return (
48
+ typeof globalThis !== "undefined" &&
49
+ (globalThis as { __DEV__?: boolean }).__DEV__ === true
50
+ );
51
+ }
52
+
46
53
  async function handle(event: StorageCallEvent, storage: Storage): Promise<void> {
47
54
  const { id, method, args } = event;
55
+ if (isDev()) {
56
+ // Trace every Rust→JS storage call so a failing round-trip during
57
+ // join/checkpoint is attributable to a specific namespace+key.
58
+ // eslint-disable-next-line no-console
59
+ console.log(
60
+ "[ping-storage] " + method +
61
+ " ns=" + String(args.namespace ?? "") +
62
+ " key=" + String(args.key ?? args.prefix ?? ""),
63
+ );
64
+ }
48
65
  try {
49
66
  let result: unknown;
50
67
  switch (method) {
@@ -74,6 +91,14 @@ async function handle(event: StorageCallEvent, storage: Storage): Promise<void>
74
91
  await NativeModules.PingNative.resolveStorageCall(id, result);
75
92
  } catch (e) {
76
93
  const message = e instanceof Error ? e.message : String(e);
94
+ if (isDev()) {
95
+ // eslint-disable-next-line no-console
96
+ console.warn(
97
+ "[ping-storage] " + method +
98
+ " ns=" + String(args.namespace ?? "") + " FAILED: " + message +
99
+ (e instanceof Error && e.stack ? "\n" + e.stack : ""),
100
+ );
101
+ }
77
102
  try {
78
103
  await NativeModules.PingNative.rejectStorageCall(id, message);
79
104
  } catch {