@palbase/web 1.3.0 → 1.4.0

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.
@@ -764,6 +764,16 @@ interface ChatMessage {
764
764
  * a visible message of its own — it only overlays the target's text + flag.
765
765
  */
766
766
  readonly edited: boolean;
767
+ /**
768
+ * Whether this message has been deleted-for-everyone (a cooperative encrypted
769
+ * tombstone from the original sender). Defaults to `false`. Once a valid
770
+ * tombstone folds onto this message it stays `true` (absorbing/sticky within
771
+ * retention). A deleted message renders ONLY the neutral "deleted" descriptor
772
+ * as its `text`, with reactions + reply + edit HIDDEN — delete DOMINATES edit.
773
+ * A delete is never a visible message of its own. (delete-for-me is a separate,
774
+ * local-only suppression that omits the message from this view entirely.)
775
+ */
776
+ readonly isDeleted: boolean;
767
777
  }
768
778
  /** The receipt from a send — the server's monotonic sequence + accepted epoch. */
769
779
  interface SentReceipt {
@@ -813,6 +823,10 @@ interface EditPayload {
813
823
  targetClientMsgId: string;
814
824
  newText: string;
815
825
  }
826
+ interface DeletePayload {
827
+ targetClientMsgId: string;
828
+ scope: string;
829
+ }
816
830
 
817
831
  /** A decoded incoming message handed to chat listeners. */
818
832
  interface IncomingMessage {
@@ -839,6 +853,10 @@ interface IncomingMessage {
839
853
  /** The decoded edit payload, present only when `envelopeType === 'edit'`. Lets
840
854
  * the Chat route an edit into its EditFold instead of appending a visible bubble. */
841
855
  edit?: EditPayload | null;
856
+ /** The decoded delete payload, present only when `envelopeType === 'delete'`. Lets
857
+ * the Chat route a delete-for-everyone tombstone into its DeleteFold instead of
858
+ * appending a visible bubble. */
859
+ delete?: DeletePayload | null;
842
860
  }
843
861
 
844
862
  /** The intended participants of a draft chat (held until the first send). */
@@ -883,6 +901,16 @@ interface ChatBackend {
883
901
  receipt: SentReceipt;
884
902
  clientMsgId: string;
885
903
  }>;
904
+ /** Send a delete-for-everyone tombstone on a target message through the same MLS
905
+ * application path as `sendText` (the server stays blind — a delete is just
906
+ * another opaque application message). Returns the receipt + the wire clientMsgId. */
907
+ sendDelete(group: MessagingGroup, args: {
908
+ clientMsgId: string;
909
+ targetClientMsgId: string;
910
+ }): Promise<{
911
+ receipt: SentReceipt;
912
+ clientMsgId: string;
913
+ }>;
886
914
  history(group: MessagingGroup, limit: number, before?: number): Promise<ChatMessage[]>;
887
915
  members(group: MessagingGroup): Promise<ChatMember[]>;
888
916
  addMember(group: MessagingGroup, userId: string): Promise<void>;
@@ -895,6 +923,10 @@ interface ChatBackend {
895
923
  subscribeLive(group: MessagingGroup, chat: Chat): Unsubscribe$1;
896
924
  /** Resolve a sender device id → its owning user id (for senderUserId). */
897
925
  userIdForDevice(group: MessagingGroup, deviceId: string): Promise<string | null>;
926
+ /** Load this chat's persisted delete-for-me suppression keys (durable, no wire). */
927
+ loadSuppressed(group: MessagingGroup): Promise<string[]>;
928
+ /** Persist this chat's delete-for-me suppression keys (durable, no wire). */
929
+ saveSuppressed(group: MessagingGroup, keys: string[]): Promise<void>;
898
930
  }
899
931
  declare class Chat {
900
932
  /** Stable, URL/log-safe id (the grp_ display id once active; a reserved local id while draft). */
@@ -917,6 +949,15 @@ declare class Chat {
917
949
  private readonly reactionFold;
918
950
  /** The single authoritative edit fold for this chat (live + own-send + history). */
919
951
  private readonly editFold;
952
+ /** The single authoritative delete-for-everyone fold (live + own-send + history).
953
+ * A tombstone scrubs its target in place (delete DOMINATES edit at render). */
954
+ private readonly deleteFold;
955
+ /** delete-for-me suppression keys (clientMsgId, or `seq:<serverSeq>` for legacy)
956
+ * — the message is OMITTED from this view. Local + persisted per chat, NO wire. */
957
+ private readonly suppressed;
958
+ /** True once the persisted suppression set has been loaded (so the omit applies
959
+ * even on the cold-launch hydrate path before a fresh deleteForMe). */
960
+ private suppressedLoaded;
920
961
  /** Per-target BASE (original) text, so the rendered text is `edit ?? original`.
921
962
  * Seeded once per target (write-once base) so a 2nd own edit can't corrupt it. */
922
963
  private readonly originalTextByClientMsgId;
@@ -948,9 +989,26 @@ declare class Chat {
948
989
  get typing(): readonly ChatMember[];
949
990
  get lastMessage(): ChatMessage | null;
950
991
  get unreadCount(): number;
992
+ /**
993
+ * The RENDER PRECEDENCE — the single composition point (live AND history project
994
+ * through it identically). Over the raw `messageList` (which already carries the
995
+ * folded edit text + reactions + reply):
996
+ * (1) in the delete-for-me suppression set → OMIT the message entirely;
997
+ * (2) else tombstoned (delete-for-everyone) → the neutral "deleted" descriptor
998
+ * with reactions/reply/edit HIDDEN (delete DOMINATES edit — short-circuit);
999
+ * (3) else the row as-is (edit overlay + reactions + reply already applied).
1000
+ * Pure over (messageList, deleteFold, suppressed) — recomputed on every read so a
1001
+ * just-folded delete / just-suppressed key takes effect without rewriting rows.
1002
+ */
1003
+ private surfaced;
1004
+ /** The delete-for-me suppression key: clientMsgId when present, else `seq:<n>`. */
1005
+ private suppressionKey;
951
1006
  get title(): string;
952
1007
  presence(userId: string): PresenceState | null;
953
1008
  private ensureWired;
1009
+ /** Hydrate the persisted delete-for-me suppression keys (once), then re-emit so
1010
+ * any already-surfaced suppressed message is omitted (cold-launch parity). */
1011
+ private loadSuppressed;
954
1012
  private hydrateHistory;
955
1013
  private mergeHistory;
956
1014
  /** @internal — called by the backend's live subscription. */
@@ -1028,6 +1086,20 @@ declare class Chat {
1028
1086
  * reactions + reply context. Only the original author's edits count — for an own
1029
1087
  * message self IS the author, so the author-gate passes. */
1030
1088
  edit(message: ChatMessage, newText: string): Promise<void>;
1089
+ /** Delete a message for EVERYONE (a cooperative encrypted tombstone). Only the
1090
+ * ORIGINAL SENDER can do this — for an own message self IS the author, so the
1091
+ * author-gate passes. Legacy messages (empty clientMsgId) are DISABLED (a
1092
+ * tombstone keys on the target's clientMsgId, which they lack) — no-op. Sends a
1093
+ * `type:'delete'` envelope through the SAME MLS path as a text message (the
1094
+ * server stays blind), folds the own delete locally so the target scrubs in
1095
+ * place instantly (the durable echo dedups on the SAME wire clientMsgId), and
1096
+ * re-emits. NEVER appends a bubble. delete-for-me'ing the target becomes moot. */
1097
+ deleteForEveryone(message: ChatMessage): Promise<void>;
1098
+ /** Delete a message for ME only — a LOCAL, per-device suppression. NO wire, NO
1099
+ * attribution, no server contact: the message is OMITTED from THIS view and the
1100
+ * suppression key persists per chat (survives reload). The key is the message's
1101
+ * clientMsgId when present, else `seq:<serverSeq>` for legacy messages. */
1102
+ deleteForMe(message: ChatMessage): Promise<void>;
1031
1103
  }
1032
1104
 
1033
1105
  declare class PalbeMessaging {
@@ -764,6 +764,16 @@ interface ChatMessage {
764
764
  * a visible message of its own — it only overlays the target's text + flag.
765
765
  */
766
766
  readonly edited: boolean;
767
+ /**
768
+ * Whether this message has been deleted-for-everyone (a cooperative encrypted
769
+ * tombstone from the original sender). Defaults to `false`. Once a valid
770
+ * tombstone folds onto this message it stays `true` (absorbing/sticky within
771
+ * retention). A deleted message renders ONLY the neutral "deleted" descriptor
772
+ * as its `text`, with reactions + reply + edit HIDDEN — delete DOMINATES edit.
773
+ * A delete is never a visible message of its own. (delete-for-me is a separate,
774
+ * local-only suppression that omits the message from this view entirely.)
775
+ */
776
+ readonly isDeleted: boolean;
767
777
  }
768
778
  /** The receipt from a send — the server's monotonic sequence + accepted epoch. */
769
779
  interface SentReceipt {
@@ -813,6 +823,10 @@ interface EditPayload {
813
823
  targetClientMsgId: string;
814
824
  newText: string;
815
825
  }
826
+ interface DeletePayload {
827
+ targetClientMsgId: string;
828
+ scope: string;
829
+ }
816
830
 
817
831
  /** A decoded incoming message handed to chat listeners. */
818
832
  interface IncomingMessage {
@@ -839,6 +853,10 @@ interface IncomingMessage {
839
853
  /** The decoded edit payload, present only when `envelopeType === 'edit'`. Lets
840
854
  * the Chat route an edit into its EditFold instead of appending a visible bubble. */
841
855
  edit?: EditPayload | null;
856
+ /** The decoded delete payload, present only when `envelopeType === 'delete'`. Lets
857
+ * the Chat route a delete-for-everyone tombstone into its DeleteFold instead of
858
+ * appending a visible bubble. */
859
+ delete?: DeletePayload | null;
842
860
  }
843
861
 
844
862
  /** The intended participants of a draft chat (held until the first send). */
@@ -883,6 +901,16 @@ interface ChatBackend {
883
901
  receipt: SentReceipt;
884
902
  clientMsgId: string;
885
903
  }>;
904
+ /** Send a delete-for-everyone tombstone on a target message through the same MLS
905
+ * application path as `sendText` (the server stays blind — a delete is just
906
+ * another opaque application message). Returns the receipt + the wire clientMsgId. */
907
+ sendDelete(group: MessagingGroup, args: {
908
+ clientMsgId: string;
909
+ targetClientMsgId: string;
910
+ }): Promise<{
911
+ receipt: SentReceipt;
912
+ clientMsgId: string;
913
+ }>;
886
914
  history(group: MessagingGroup, limit: number, before?: number): Promise<ChatMessage[]>;
887
915
  members(group: MessagingGroup): Promise<ChatMember[]>;
888
916
  addMember(group: MessagingGroup, userId: string): Promise<void>;
@@ -895,6 +923,10 @@ interface ChatBackend {
895
923
  subscribeLive(group: MessagingGroup, chat: Chat): Unsubscribe$1;
896
924
  /** Resolve a sender device id → its owning user id (for senderUserId). */
897
925
  userIdForDevice(group: MessagingGroup, deviceId: string): Promise<string | null>;
926
+ /** Load this chat's persisted delete-for-me suppression keys (durable, no wire). */
927
+ loadSuppressed(group: MessagingGroup): Promise<string[]>;
928
+ /** Persist this chat's delete-for-me suppression keys (durable, no wire). */
929
+ saveSuppressed(group: MessagingGroup, keys: string[]): Promise<void>;
898
930
  }
899
931
  declare class Chat {
900
932
  /** Stable, URL/log-safe id (the grp_ display id once active; a reserved local id while draft). */
@@ -917,6 +949,15 @@ declare class Chat {
917
949
  private readonly reactionFold;
918
950
  /** The single authoritative edit fold for this chat (live + own-send + history). */
919
951
  private readonly editFold;
952
+ /** The single authoritative delete-for-everyone fold (live + own-send + history).
953
+ * A tombstone scrubs its target in place (delete DOMINATES edit at render). */
954
+ private readonly deleteFold;
955
+ /** delete-for-me suppression keys (clientMsgId, or `seq:<serverSeq>` for legacy)
956
+ * — the message is OMITTED from this view. Local + persisted per chat, NO wire. */
957
+ private readonly suppressed;
958
+ /** True once the persisted suppression set has been loaded (so the omit applies
959
+ * even on the cold-launch hydrate path before a fresh deleteForMe). */
960
+ private suppressedLoaded;
920
961
  /** Per-target BASE (original) text, so the rendered text is `edit ?? original`.
921
962
  * Seeded once per target (write-once base) so a 2nd own edit can't corrupt it. */
922
963
  private readonly originalTextByClientMsgId;
@@ -948,9 +989,26 @@ declare class Chat {
948
989
  get typing(): readonly ChatMember[];
949
990
  get lastMessage(): ChatMessage | null;
950
991
  get unreadCount(): number;
992
+ /**
993
+ * The RENDER PRECEDENCE — the single composition point (live AND history project
994
+ * through it identically). Over the raw `messageList` (which already carries the
995
+ * folded edit text + reactions + reply):
996
+ * (1) in the delete-for-me suppression set → OMIT the message entirely;
997
+ * (2) else tombstoned (delete-for-everyone) → the neutral "deleted" descriptor
998
+ * with reactions/reply/edit HIDDEN (delete DOMINATES edit — short-circuit);
999
+ * (3) else the row as-is (edit overlay + reactions + reply already applied).
1000
+ * Pure over (messageList, deleteFold, suppressed) — recomputed on every read so a
1001
+ * just-folded delete / just-suppressed key takes effect without rewriting rows.
1002
+ */
1003
+ private surfaced;
1004
+ /** The delete-for-me suppression key: clientMsgId when present, else `seq:<n>`. */
1005
+ private suppressionKey;
951
1006
  get title(): string;
952
1007
  presence(userId: string): PresenceState | null;
953
1008
  private ensureWired;
1009
+ /** Hydrate the persisted delete-for-me suppression keys (once), then re-emit so
1010
+ * any already-surfaced suppressed message is omitted (cold-launch parity). */
1011
+ private loadSuppressed;
954
1012
  private hydrateHistory;
955
1013
  private mergeHistory;
956
1014
  /** @internal — called by the backend's live subscription. */
@@ -1028,6 +1086,20 @@ declare class Chat {
1028
1086
  * reactions + reply context. Only the original author's edits count — for an own
1029
1087
  * message self IS the author, so the author-gate passes. */
1030
1088
  edit(message: ChatMessage, newText: string): Promise<void>;
1089
+ /** Delete a message for EVERYONE (a cooperative encrypted tombstone). Only the
1090
+ * ORIGINAL SENDER can do this — for an own message self IS the author, so the
1091
+ * author-gate passes. Legacy messages (empty clientMsgId) are DISABLED (a
1092
+ * tombstone keys on the target's clientMsgId, which they lack) — no-op. Sends a
1093
+ * `type:'delete'` envelope through the SAME MLS path as a text message (the
1094
+ * server stays blind), folds the own delete locally so the target scrubs in
1095
+ * place instantly (the durable echo dedups on the SAME wire clientMsgId), and
1096
+ * re-emits. NEVER appends a bubble. delete-for-me'ing the target becomes moot. */
1097
+ deleteForEveryone(message: ChatMessage): Promise<void>;
1098
+ /** Delete a message for ME only — a LOCAL, per-device suppression. NO wire, NO
1099
+ * attribution, no server contact: the message is OMITTED from THIS view and the
1100
+ * suppression key persists per chat (survives reload). The key is the message's
1101
+ * clientMsgId when present, else `seq:<serverSeq>` for legacy messages. */
1102
+ deleteForMe(message: ChatMessage): Promise<void>;
1031
1103
  }
1032
1104
 
1033
1105
  declare class PalbeMessaging {