ping-openmls-sdk-react-native-macos 0.7.5 → 0.7.7

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
@@ -2953,6 +2953,91 @@ public func FfiConverterTypeMessageEnvelope_lower(_ value: MessageEnvelope) -> R
2953
2953
  return FfiConverterTypeMessageEnvelope.lower(value)
2954
2954
  }
2955
2955
 
2956
+ public struct RecoveryBackupView {
2957
+ public var v: UInt8
2958
+ public var accountId: Data
2959
+ public var identityExport: Data
2960
+ public var deviceGroupSnapshot: Data
2961
+ public var createdAtMs: UInt64
2962
+
2963
+ /// Default memberwise initializers are never public by default, so we
2964
+ /// declare one manually.
2965
+ public init(v: UInt8, accountId: Data, identityExport: Data, deviceGroupSnapshot: Data, createdAtMs: UInt64) {
2966
+ self.v = v
2967
+ self.accountId = accountId
2968
+ self.identityExport = identityExport
2969
+ self.deviceGroupSnapshot = deviceGroupSnapshot
2970
+ self.createdAtMs = createdAtMs
2971
+ }
2972
+ }
2973
+
2974
+ extension RecoveryBackupView: Equatable, Hashable {
2975
+ public static func == (lhs: RecoveryBackupView, rhs: RecoveryBackupView) -> Bool {
2976
+ if lhs.v != rhs.v {
2977
+ return false
2978
+ }
2979
+ if lhs.accountId != rhs.accountId {
2980
+ return false
2981
+ }
2982
+ if lhs.identityExport != rhs.identityExport {
2983
+ return false
2984
+ }
2985
+ if lhs.deviceGroupSnapshot != rhs.deviceGroupSnapshot {
2986
+ return false
2987
+ }
2988
+ if lhs.createdAtMs != rhs.createdAtMs {
2989
+ return false
2990
+ }
2991
+ return true
2992
+ }
2993
+
2994
+ public func hash(into hasher: inout Hasher) {
2995
+ hasher.combine(v)
2996
+ hasher.combine(accountId)
2997
+ hasher.combine(identityExport)
2998
+ hasher.combine(deviceGroupSnapshot)
2999
+ hasher.combine(createdAtMs)
3000
+ }
3001
+ }
3002
+
3003
+ #if swift(>=5.8)
3004
+ @_documentation(visibility: private)
3005
+ #endif
3006
+ public struct FfiConverterTypeRecoveryBackupView: FfiConverterRustBuffer {
3007
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RecoveryBackupView {
3008
+ return
3009
+ try RecoveryBackupView(
3010
+ v: FfiConverterUInt8.read(from: &buf),
3011
+ accountId: FfiConverterData.read(from: &buf),
3012
+ identityExport: FfiConverterData.read(from: &buf),
3013
+ deviceGroupSnapshot: FfiConverterData.read(from: &buf),
3014
+ createdAtMs: FfiConverterUInt64.read(from: &buf)
3015
+ )
3016
+ }
3017
+
3018
+ public static func write(_ value: RecoveryBackupView, into buf: inout [UInt8]) {
3019
+ FfiConverterUInt8.write(value.v, into: &buf)
3020
+ FfiConverterData.write(value.accountId, into: &buf)
3021
+ FfiConverterData.write(value.identityExport, into: &buf)
3022
+ FfiConverterData.write(value.deviceGroupSnapshot, into: &buf)
3023
+ FfiConverterUInt64.write(value.createdAtMs, into: &buf)
3024
+ }
3025
+ }
3026
+
3027
+ #if swift(>=5.8)
3028
+ @_documentation(visibility: private)
3029
+ #endif
3030
+ public func FfiConverterTypeRecoveryBackupView_lift(_ buf: RustBuffer) throws -> RecoveryBackupView {
3031
+ return try FfiConverterTypeRecoveryBackupView.lift(buf)
3032
+ }
3033
+
3034
+ #if swift(>=5.8)
3035
+ @_documentation(visibility: private)
3036
+ #endif
3037
+ public func FfiConverterTypeRecoveryBackupView_lower(_ value: RecoveryBackupView) -> RustBuffer {
3038
+ return FfiConverterTypeRecoveryBackupView.lower(value)
3039
+ }
3040
+
2956
3041
  public struct UserId {
2957
3042
  public var value: Data
2958
3043
 
@@ -3736,12 +3821,47 @@ public func decodeCatchupSnapshot(snapshotBytes: Data) throws -> CatchupSnapshot
3736
3821
  })
3737
3822
  }
3738
3823
 
3824
+ public func decryptBackup(blob: Data, mnemonicPhrase: String) throws -> RecoveryBackupView {
3825
+ return try FfiConverterTypeRecoveryBackupView.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3826
+ uniffi_ping_ffi_fn_func_decrypt_backup(
3827
+ FfiConverterData.lower(blob),
3828
+ FfiConverterString.lower(mnemonicPhrase), $0
3829
+ )
3830
+ })
3831
+ }
3832
+
3833
+ public func encryptBackup(mnemonicPhrase: String, accountId: Data, identityExport: Data, deviceGroupSnapshot: Data, createdAtMs: UInt64) throws -> Data {
3834
+ return try FfiConverterData.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3835
+ uniffi_ping_ffi_fn_func_encrypt_backup(
3836
+ FfiConverterString.lower(mnemonicPhrase),
3837
+ FfiConverterData.lower(accountId),
3838
+ FfiConverterData.lower(identityExport),
3839
+ FfiConverterData.lower(deviceGroupSnapshot),
3840
+ FfiConverterUInt64.lower(createdAtMs), $0
3841
+ )
3842
+ })
3843
+ }
3844
+
3739
3845
  public func generateIdentityExport() -> Data {
3740
3846
  return try! FfiConverterData.lift(try! rustCall {
3741
3847
  uniffi_ping_ffi_fn_func_generate_identity_export($0)
3742
3848
  })
3743
3849
  }
3744
3850
 
3851
+ public func generateMnemonicPhrase() throws -> String {
3852
+ return try FfiConverterString.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3853
+ uniffi_ping_ffi_fn_func_generate_mnemonic_phrase($0)
3854
+ })
3855
+ }
3856
+
3857
+ public func normalizeMnemonicPhrase(phrase: String) throws -> String {
3858
+ return try FfiConverterString.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3859
+ uniffi_ping_ffi_fn_func_normalize_mnemonic_phrase(
3860
+ FfiConverterString.lower(phrase), $0
3861
+ )
3862
+ })
3863
+ }
3864
+
3745
3865
  public func openLinkingTicket(sealed: Data, newDevicePriv: Data) throws -> LinkingTicket {
3746
3866
  return try FfiConverterTypeLinkingTicket.lift(rustCallWithError(FfiConverterTypePingError.lift) {
3747
3867
  uniffi_ping_ffi_fn_func_open_linking_ticket(
@@ -3779,9 +3899,21 @@ private var initializationResult: InitializationResult = {
3779
3899
  if uniffi_ping_ffi_checksum_func_decode_catchup_snapshot() != 40316 {
3780
3900
  return InitializationResult.apiChecksumMismatch
3781
3901
  }
3902
+ if uniffi_ping_ffi_checksum_func_decrypt_backup() != 58907 {
3903
+ return InitializationResult.apiChecksumMismatch
3904
+ }
3905
+ if uniffi_ping_ffi_checksum_func_encrypt_backup() != 7671 {
3906
+ return InitializationResult.apiChecksumMismatch
3907
+ }
3782
3908
  if uniffi_ping_ffi_checksum_func_generate_identity_export() != 15026 {
3783
3909
  return InitializationResult.apiChecksumMismatch
3784
3910
  }
3911
+ if uniffi_ping_ffi_checksum_func_generate_mnemonic_phrase() != 9754 {
3912
+ return InitializationResult.apiChecksumMismatch
3913
+ }
3914
+ if uniffi_ping_ffi_checksum_func_normalize_mnemonic_phrase() != 55353 {
3915
+ return InitializationResult.apiChecksumMismatch
3916
+ }
3785
3917
  if uniffi_ping_ffi_checksum_func_open_linking_ticket() != 64091 {
3786
3918
  return InitializationResult.apiChecksumMismatch
3787
3919
  }
@@ -146,6 +146,15 @@ RCT_EXTERN_METHOD(consumeLinkingTicket: (NSDictionary *)ticket
146
146
  resolver: (RCTPromiseResolveBlock)resolve
147
147
  rejecter: (RCTPromiseRejectBlock)reject)
148
148
 
149
+ // [CR-3] HPKE-open a sealed LinkingTicket on the new device. Free
150
+ // function (not on the client instance) — the new device is pre-init
151
+ // and doesn't have a MessagingClient yet at the time of the open call.
152
+ // Returns the same dict shape `consumeLinkingTicket` accepts as input.
153
+ RCT_EXTERN_METHOD(openLinkingTicket: (NSArray *)sealed
154
+ newDevicePriv: (NSArray *)newDevicePriv
155
+ resolver: (RCTPromiseResolveBlock)resolve
156
+ rejecter: (RCTPromiseRejectBlock)reject)
157
+
149
158
  RCT_EXTERN_METHOD(revokeDevice: (NSArray *)deviceId
150
159
  nowMs: (double)nowMs
151
160
  resolver: (RCTPromiseResolveBlock)resolve
@@ -684,6 +684,31 @@ public final class PingNative: RCTEventEmitter {
684
684
  }
685
685
  }
686
686
 
687
+ /// HPKE-open a sealed `LinkingTicket` on the new device ([CR-3]).
688
+ /// Free function (not on `client`) — the new device is pre-init and
689
+ /// doesn't have a `MessagingClient` yet when the open happens. Mirrors
690
+ /// the wasm SDK's `MessagingClient.openLinkingTicket(sealed, priv)`
691
+ /// static so the desktop link host can decode the ticket before
692
+ /// calling `init` + `consumeLinkingTicket`.
693
+ @objc(openLinkingTicket:newDevicePriv:resolver:rejecter:)
694
+ public func openLinkingTicketNative(
695
+ _ sealedBytes: NSArray,
696
+ newDevicePriv newDevicePrivBytes: NSArray,
697
+ resolver resolve: @escaping RCTPromiseResolveBlock,
698
+ rejecter reject: @escaping RCTPromiseRejectBlock
699
+ ) {
700
+ do {
701
+ let sealed = try TypeBridge.decodeBytesOrThrow(sealedBytes, field: "sealed")
702
+ let priv = try TypeBridge.decodeBytesOrThrow(newDevicePrivBytes, field: "newDevicePriv")
703
+ // `open_linking_ticket` is a UniFFI top-level free function;
704
+ // Swift exposes it camelCased.
705
+ let ticket = try openLinkingTicket(sealed: sealed, newDevicePriv: priv)
706
+ resolve(TypeBridge.encodeLinkingTicket(ticket))
707
+ } catch {
708
+ reject("OpenLinkingFailed", String(describing: error), error)
709
+ }
710
+ }
711
+
687
712
  /// Revoke a device ([CR-2]). Returns the array of Commit envelopes the SDK
688
713
  /// produced — one per conversation the device was a locally-known leaf in.
689
714
  /// Empty array means the device wasn't locally known (scope limit per CR-2).
package/ios/pingFFI.h CHANGED
@@ -552,10 +552,31 @@ uint64_t uniffi_ping_ffi_fn_method_transport_send(void*_Nonnull ptr, RustBuffer
552
552
  RustBuffer uniffi_ping_ffi_fn_func_decode_catchup_snapshot(RustBuffer snapshot_bytes, RustCallStatus *_Nonnull out_status
553
553
  );
554
554
  #endif
555
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_DECRYPT_BACKUP
556
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_DECRYPT_BACKUP
557
+ RustBuffer uniffi_ping_ffi_fn_func_decrypt_backup(RustBuffer blob, RustBuffer mnemonic_phrase, RustCallStatus *_Nonnull out_status
558
+ );
559
+ #endif
560
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_ENCRYPT_BACKUP
561
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_ENCRYPT_BACKUP
562
+ RustBuffer uniffi_ping_ffi_fn_func_encrypt_backup(RustBuffer mnemonic_phrase, RustBuffer account_id, RustBuffer identity_export, RustBuffer device_group_snapshot, uint64_t created_at_ms, RustCallStatus *_Nonnull out_status
563
+ );
564
+ #endif
555
565
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_GENERATE_IDENTITY_EXPORT
556
566
  #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_GENERATE_IDENTITY_EXPORT
557
567
  RustBuffer uniffi_ping_ffi_fn_func_generate_identity_export(RustCallStatus *_Nonnull out_status
558
568
 
569
+ );
570
+ #endif
571
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_GENERATE_MNEMONIC_PHRASE
572
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_GENERATE_MNEMONIC_PHRASE
573
+ RustBuffer uniffi_ping_ffi_fn_func_generate_mnemonic_phrase(RustCallStatus *_Nonnull out_status
574
+
575
+ );
576
+ #endif
577
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_NORMALIZE_MNEMONIC_PHRASE
578
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_NORMALIZE_MNEMONIC_PHRASE
579
+ RustBuffer uniffi_ping_ffi_fn_func_normalize_mnemonic_phrase(RustBuffer phrase, RustCallStatus *_Nonnull out_status
559
580
  );
560
581
  #endif
561
582
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_FN_FUNC_OPEN_LINKING_TICKET
@@ -852,12 +873,36 @@ void ffi_ping_ffi_rust_future_complete_void(uint64_t handle, RustCallStatus *_No
852
873
  #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_DECODE_CATCHUP_SNAPSHOT
853
874
  uint16_t uniffi_ping_ffi_checksum_func_decode_catchup_snapshot(void
854
875
 
876
+ );
877
+ #endif
878
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_DECRYPT_BACKUP
879
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_DECRYPT_BACKUP
880
+ uint16_t uniffi_ping_ffi_checksum_func_decrypt_backup(void
881
+
882
+ );
883
+ #endif
884
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_ENCRYPT_BACKUP
885
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_ENCRYPT_BACKUP
886
+ uint16_t uniffi_ping_ffi_checksum_func_encrypt_backup(void
887
+
855
888
  );
856
889
  #endif
857
890
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_GENERATE_IDENTITY_EXPORT
858
891
  #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_GENERATE_IDENTITY_EXPORT
859
892
  uint16_t uniffi_ping_ffi_checksum_func_generate_identity_export(void
860
893
 
894
+ );
895
+ #endif
896
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_GENERATE_MNEMONIC_PHRASE
897
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_GENERATE_MNEMONIC_PHRASE
898
+ uint16_t uniffi_ping_ffi_checksum_func_generate_mnemonic_phrase(void
899
+
900
+ );
901
+ #endif
902
+ #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_NORMALIZE_MNEMONIC_PHRASE
903
+ #define UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_NORMALIZE_MNEMONIC_PHRASE
904
+ uint16_t uniffi_ping_ffi_checksum_func_normalize_mnemonic_phrase(void
905
+
861
906
  );
862
907
  #endif
863
908
  #ifndef UNIFFI_FFIDEF_UNIFFI_PING_FFI_CHECKSUM_FUNC_OPEN_LINKING_TICKET
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ping-openmls-sdk-react-native-macos",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
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",
@@ -373,6 +373,33 @@ export class MessagingClient {
373
373
  await NativePing.consumeLinkingTicket(encodeLinkingTicket(ticket), Date.now());
374
374
  }
375
375
 
376
+ /**
377
+ * [CR-3] HPKE-open a sealed linking ticket on the new device. Static —
378
+ * the new device hasn't initialised a `MessagingClient` yet at the
379
+ * time of the open call (it does `openLinkingTicket` first to extract
380
+ * the auth-layer fields, hands them to `/v1/auth/link-verify` to
381
+ * mint tokens, THEN `init`s and `consumeLinkingTicket`s).
382
+ *
383
+ * Mirrors the wasm SDK's `MessagingClient.openLinkingTicket` so the
384
+ * desktop link host can share code shape with the web link host.
385
+ *
386
+ * @param sealed - HPKE-sealed bytes from `getLinkingTicket(ticketId)`
387
+ * (the BE relays exactly what the existing device
388
+ * `sealLinkingTicket`'d).
389
+ * @param newDevicePriv - 32-byte X25519 private key the new device
390
+ * generated for this pairing session.
391
+ */
392
+ static async openLinkingTicket(
393
+ sealed: Uint8Array,
394
+ newDevicePriv: Uint8Array,
395
+ ): Promise<LinkingTicket> {
396
+ const raw = await NativePing.openLinkingTicket(
397
+ Array.from(sealed),
398
+ Array.from(newDevicePriv),
399
+ );
400
+ return decodeLinkingTicket(raw);
401
+ }
402
+
376
403
  /**
377
404
  * Admit a freshly-linked device to every chat in `entries` — one Commit +
378
405
  * Welcome per chat, with per-chat outcomes. Host calls this AFTER
package/src/NativePing.ts CHANGED
@@ -200,6 +200,19 @@ export interface Spec extends TurboModule {
200
200
  nowMs: number,
201
201
  ): Promise<null>;
202
202
 
203
+ /**
204
+ * [CR-3] HPKE-open a sealed linking ticket on the new device. Free
205
+ * function — runs BEFORE `initClient` so the host can decode the
206
+ * ticket fields (`user_pubkey`, `new_device_id`, `device_binding_sig`)
207
+ * and submit them to the auth layer's `/v1/auth/link-verify` before
208
+ * spinning up the messaging client. Returns the same dict shape
209
+ * `consumeLinkingTicket` accepts.
210
+ */
211
+ openLinkingTicket(
212
+ sealed: number[],
213
+ newDevicePriv: number[],
214
+ ): Promise<Record<string, unknown>>;
215
+
203
216
  /**
204
217
  * Revoke a device ([CR-2]). Returns one Commit envelope per conversation the
205
218
  * device was a locally-known leaf in. Empty array means the device wasn't locally