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

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.
@@ -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/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.14",
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