@ping-app/ping-openmls-sdk 0.10.0 → 0.10.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.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as MessageBatchMeta } from './types-B1GFwNXa.cjs';
2
- export { u as AddMemberStatus, v as AddMemberVerdict, B as BufferOverflow, w as Bytes, x as CatchupSnapshotEntry, y as ConversationRemoval, z as ConversationUpdate, F as DeviceInfo, G as DeviceRemovalFailure, D as DiscoveredDevice, J as HistoryAppEvent, N as Hlc, O as IdentityRotationFailure, Q as LogGap, V as MessageKind, W as OverflowReason, X as SenderRole, Y as StrandReason, Z as StrandedConversation, _ as WelcomeFailure, $ as WelcomeFailureReason } from './types-B1GFwNXa.cjs';
1
+ import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as ExportedSecret, u as MessageBatchMeta } from './types-gAmJFSC-.cjs';
2
+ export { v as AddMemberStatus, w as AddMemberVerdict, B as BufferOverflow, x as Bytes, y as CatchupSnapshotEntry, z as ConversationRemoval, F as ConversationUpdate, G as DeviceInfo, J as DeviceRemovalFailure, D as DiscoveredDevice, N as HistoryAppEvent, O as Hlc, Q as IdentityRotationFailure, V as LogGap, W as MessageKind, X as OverflowReason, Y as SenderRole, Z as StrandReason, _ as StrandedConversation, $ as WelcomeFailure, a0 as WelcomeFailureReason } from './types-gAmJFSC-.cjs';
3
3
  export { IndexedDbStorage } from './storage/indexeddb.cjs';
4
4
  export { WebSocketTransport } from './transport/websocket.cjs';
5
- export { NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.cjs';
5
+ export { MAX_PREVIEW_PREREQUISITES, NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.cjs';
6
6
 
7
7
  /**
8
8
  * Ping wire contract version. Bumped on incompatible profile changes.
@@ -1093,6 +1093,22 @@ declare class MessagingClient {
1093
1093
  * byte-equality is enforced by `protocol/conformance/export_secret/`.
1094
1094
  */
1095
1095
  exportConversationSecret(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<Uint8Array>;
1096
+ /**
1097
+ * {@link exportConversationSecret} together with the MLS epoch the secret was
1098
+ * exported at, from one read under one lock inside the core: the pair can
1099
+ * never disagree across a Commit.
1100
+ *
1101
+ * A host that files a key under an epoch number (a call's media key ring)
1102
+ * takes BOTH from this call. A conversation handle's `epoch` is this thread's
1103
+ * copy and any other read is a second request, so either may be a Commit away
1104
+ * from the secret.
1105
+ *
1106
+ * Same derivation, same arguments and the same refusals as
1107
+ * {@link exportConversationSecret}: at one epoch both answer the same bytes.
1108
+ * `secret` is a secret: never log it, persist it only encrypted, and call
1109
+ * `secret.fill(0)` after use. `epoch` is a plain number and may be logged.
1110
+ */
1111
+ exportConversationSecretWithEpoch(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<ExportedSecret>;
1096
1112
  /**
1097
1113
  * Subscribe to decrypted application messages, one call per message. A
1098
1114
  * batch or page result (the sequenced paths) is fanned out here per
@@ -1226,4 +1242,4 @@ declare function emulateSendBatch(transport: Pick<Transport, "send">, envelopes:
1226
1242
  * server error code rides along for diagnostics. */
1227
1243
  declare function describeTransportError(e: unknown): string;
1228
1244
 
1229
- export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
1245
+ export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, ExportedSecret, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as MessageBatchMeta } from './types-B1GFwNXa.js';
2
- export { u as AddMemberStatus, v as AddMemberVerdict, B as BufferOverflow, w as Bytes, x as CatchupSnapshotEntry, y as ConversationRemoval, z as ConversationUpdate, F as DeviceInfo, G as DeviceRemovalFailure, D as DiscoveredDevice, J as HistoryAppEvent, N as Hlc, O as IdentityRotationFailure, Q as LogGap, V as MessageKind, W as OverflowReason, X as SenderRole, Y as StrandReason, Z as StrandedConversation, _ as WelcomeFailure, $ as WelcomeFailureReason } from './types-B1GFwNXa.js';
1
+ import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as ExportedSecret, u as MessageBatchMeta } from './types-gAmJFSC-.js';
2
+ export { v as AddMemberStatus, w as AddMemberVerdict, B as BufferOverflow, x as Bytes, y as CatchupSnapshotEntry, z as ConversationRemoval, F as ConversationUpdate, G as DeviceInfo, J as DeviceRemovalFailure, D as DiscoveredDevice, N as HistoryAppEvent, O as Hlc, Q as IdentityRotationFailure, V as LogGap, W as MessageKind, X as OverflowReason, Y as SenderRole, Z as StrandReason, _ as StrandedConversation, $ as WelcomeFailure, a0 as WelcomeFailureReason } from './types-gAmJFSC-.js';
3
3
  export { IndexedDbStorage } from './storage/indexeddb.js';
4
4
  export { WebSocketTransport } from './transport/websocket.js';
5
- export { NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.js';
5
+ export { MAX_PREVIEW_PREREQUISITES, NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.js';
6
6
 
7
7
  /**
8
8
  * Ping wire contract version. Bumped on incompatible profile changes.
@@ -1093,6 +1093,22 @@ declare class MessagingClient {
1093
1093
  * byte-equality is enforced by `protocol/conformance/export_secret/`.
1094
1094
  */
1095
1095
  exportConversationSecret(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<Uint8Array>;
1096
+ /**
1097
+ * {@link exportConversationSecret} together with the MLS epoch the secret was
1098
+ * exported at, from one read under one lock inside the core: the pair can
1099
+ * never disagree across a Commit.
1100
+ *
1101
+ * A host that files a key under an epoch number (a call's media key ring)
1102
+ * takes BOTH from this call. A conversation handle's `epoch` is this thread's
1103
+ * copy and any other read is a second request, so either may be a Commit away
1104
+ * from the secret.
1105
+ *
1106
+ * Same derivation, same arguments and the same refusals as
1107
+ * {@link exportConversationSecret}: at one epoch both answer the same bytes.
1108
+ * `secret` is a secret: never log it, persist it only encrypted, and call
1109
+ * `secret.fill(0)` after use. `epoch` is a plain number and may be logged.
1110
+ */
1111
+ exportConversationSecretWithEpoch(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<ExportedSecret>;
1096
1112
  /**
1097
1113
  * Subscribe to decrypted application messages, one call per message. A
1098
1114
  * batch or page result (the sequenced paths) is fanned out here per
@@ -1226,4 +1242,4 @@ declare function emulateSendBatch(transport: Pick<Transport, "send">, envelopes:
1226
1242
  * server error code rides along for diagnostics. */
1227
1243
  declare function describeTransportError(e: unknown): string;
1228
1244
 
1229
- export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
1245
+ export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, ExportedSecret, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
package/dist/index.js CHANGED
@@ -609,6 +609,7 @@ function reserveLinearMemory(memory) {
609
609
  }
610
610
 
611
611
  // src/notification-preview.ts
612
+ var MAX_PREVIEW_PREREQUISITES = 64;
612
613
  async function openNotificationPreview(opts) {
613
614
  const now = opts.now ?? (() => Date.now());
614
615
  const scoped = opts.accountNamespace !== void 0 && opts.accountNamespace.length > 0 ? scopeStorage(opts.storage, opts.accountNamespace) : opts.storage;
@@ -633,6 +634,16 @@ async function openNotificationPreview(opts) {
633
634
  const result = client.previewEnvelope(envelope, now());
634
635
  return result ?? null;
635
636
  },
637
+ async previewEnvelopeWithPrerequisites(prerequisites, envelope) {
638
+ if (closed) throw new Error("notification-preview session is closed");
639
+ assertPrerequisiteCount(prerequisites);
640
+ const result = client.previewEnvelopeWithPrerequisites(
641
+ prerequisites,
642
+ envelope,
643
+ now()
644
+ );
645
+ return result ?? null;
646
+ },
636
647
  close() {
637
648
  if (closed) return;
638
649
  closed = true;
@@ -640,6 +651,16 @@ async function openNotificationPreview(opts) {
640
651
  }
641
652
  };
642
653
  }
654
+ function assertPrerequisiteCount(prerequisites) {
655
+ if (!Array.isArray(prerequisites)) {
656
+ throw new Error("notification-preview prerequisites must be an array");
657
+ }
658
+ if (prerequisites.length > MAX_PREVIEW_PREREQUISITES) {
659
+ throw new Error(
660
+ `notification-preview takes at most ${MAX_PREVIEW_PREREQUISITES} prerequisite envelopes`
661
+ );
662
+ }
663
+ }
643
664
  function readOnlyStorage(storage) {
644
665
  const refuse = (op) => Promise.reject(
645
666
  new Error(`notification-preview storage is read-only (attempted ${op})`)
@@ -2301,6 +2322,34 @@ var MessagingClient = class _MessagingClient {
2301
2322
  length
2302
2323
  });
2303
2324
  }
2325
+ /**
2326
+ * {@link exportConversationSecret} together with the MLS epoch the secret was
2327
+ * exported at, from one read under one lock inside the core: the pair can
2328
+ * never disagree across a Commit.
2329
+ *
2330
+ * A host that files a key under an epoch number (a call's media key ring)
2331
+ * takes BOTH from this call. A conversation handle's `epoch` is this thread's
2332
+ * copy and any other read is a second request, so either may be a Commit away
2333
+ * from the secret.
2334
+ *
2335
+ * Same derivation, same arguments and the same refusals as
2336
+ * {@link exportConversationSecret}: at one epoch both answer the same bytes.
2337
+ * `secret` is a secret: never log it, persist it only encrypted, and call
2338
+ * `secret.fill(0)` after use. `epoch` is a plain number and may be logged.
2339
+ */
2340
+ async exportConversationSecretWithEpoch(conv, label, context, length) {
2341
+ if (length <= 0 || length > 1024) {
2342
+ throw new Error("exportConversationSecretWithEpoch: length must be 1..=1024");
2343
+ }
2344
+ return await this.call({
2345
+ kind: "exportConversationSecretWithEpoch",
2346
+ id: this.nextId++,
2347
+ conv,
2348
+ label,
2349
+ context,
2350
+ length
2351
+ });
2352
+ }
2304
2353
  /**
2305
2354
  * Subscribe to decrypted application messages, one call per message. A
2306
2355
  * batch or page result (the sequenced paths) is fanned out here per
@@ -2690,6 +2739,7 @@ export {
2690
2739
  HPKE_PQ_ENC_BYTES,
2691
2740
  HPKE_PQ_PUBLIC_KEY_BYTES,
2692
2741
  IndexedDbStorage,
2742
+ MAX_PREVIEW_PREREQUISITES,
2693
2743
  MessagingClient,
2694
2744
  MessagingClientClosedError,
2695
2745
  NOT_PERMITTED_PREFIX,