@ping-app/ping-openmls-sdk 0.10.0 → 0.10.1

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/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(src_exports, {
39
39
  HPKE_PQ_ENC_BYTES: () => HPKE_PQ_ENC_BYTES,
40
40
  HPKE_PQ_PUBLIC_KEY_BYTES: () => HPKE_PQ_PUBLIC_KEY_BYTES,
41
41
  IndexedDbStorage: () => IndexedDbStorage,
42
+ MAX_PREVIEW_PREREQUISITES: () => MAX_PREVIEW_PREREQUISITES,
42
43
  MessagingClient: () => MessagingClient,
43
44
  MessagingClientClosedError: () => MessagingClientClosedError,
44
45
  NOT_PERMITTED_PREFIX: () => NOT_PERMITTED_PREFIX,
@@ -674,6 +675,7 @@ function reserveLinearMemory(memory) {
674
675
  }
675
676
 
676
677
  // src/notification-preview.ts
678
+ var MAX_PREVIEW_PREREQUISITES = 64;
677
679
  async function openNotificationPreview(opts) {
678
680
  const now = opts.now ?? (() => Date.now());
679
681
  const scoped = opts.accountNamespace !== void 0 && opts.accountNamespace.length > 0 ? scopeStorage(opts.storage, opts.accountNamespace) : opts.storage;
@@ -698,6 +700,16 @@ async function openNotificationPreview(opts) {
698
700
  const result = client.previewEnvelope(envelope, now());
699
701
  return result ?? null;
700
702
  },
703
+ async previewEnvelopeWithPrerequisites(prerequisites, envelope) {
704
+ if (closed) throw new Error("notification-preview session is closed");
705
+ assertPrerequisiteCount(prerequisites);
706
+ const result = client.previewEnvelopeWithPrerequisites(
707
+ prerequisites,
708
+ envelope,
709
+ now()
710
+ );
711
+ return result ?? null;
712
+ },
701
713
  close() {
702
714
  if (closed) return;
703
715
  closed = true;
@@ -705,6 +717,16 @@ async function openNotificationPreview(opts) {
705
717
  }
706
718
  };
707
719
  }
720
+ function assertPrerequisiteCount(prerequisites) {
721
+ if (!Array.isArray(prerequisites)) {
722
+ throw new Error("notification-preview prerequisites must be an array");
723
+ }
724
+ if (prerequisites.length > MAX_PREVIEW_PREREQUISITES) {
725
+ throw new Error(
726
+ `notification-preview takes at most ${MAX_PREVIEW_PREREQUISITES} prerequisite envelopes`
727
+ );
728
+ }
729
+ }
708
730
  function readOnlyStorage(storage) {
709
731
  const refuse = (op) => Promise.reject(
710
732
  new Error(`notification-preview storage is read-only (attempted ${op})`)
@@ -2757,6 +2779,7 @@ function sameBytesU8(a, b) {
2757
2779
  HPKE_PQ_ENC_BYTES,
2758
2780
  HPKE_PQ_PUBLIC_KEY_BYTES,
2759
2781
  IndexedDbStorage,
2782
+ MAX_PREVIEW_PREREQUISITES,
2760
2783
  MessagingClient,
2761
2784
  MessagingClientClosedError,
2762
2785
  NOT_PERMITTED_PREFIX,