@agora-sdk/secure-chat-core 0.6.5 → 0.8.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.
- package/dist/cjs/content/builders.d.ts +40 -0
- package/dist/cjs/content/builders.js +85 -0
- package/dist/cjs/content/builders.js.map +1 -0
- package/dist/cjs/content/cbor.d.ts +48 -0
- package/dist/cjs/content/cbor.js +298 -0
- package/dist/cjs/content/cbor.js.map +1 -0
- package/dist/cjs/content/frame.d.ts +24 -0
- package/dist/cjs/content/frame.js +39 -0
- package/dist/cjs/content/frame.js.map +1 -0
- package/dist/cjs/content/mimi-content.d.ts +194 -0
- package/dist/cjs/content/mimi-content.js +289 -0
- package/dist/cjs/content/mimi-content.js.map +1 -0
- package/dist/cjs/context/secure-chat-context.d.ts +19 -3
- package/dist/cjs/context/secure-chat-context.js +53 -13
- package/dist/cjs/context/secure-chat-context.js.map +1 -1
- package/dist/cjs/hooks/message-fold.d.ts +91 -0
- package/dist/cjs/hooks/message-fold.js +218 -0
- package/dist/cjs/hooks/message-fold.js.map +1 -0
- package/dist/cjs/hooks/useSecureConversations.js +11 -0
- package/dist/cjs/hooks/useSecureConversations.js.map +1 -1
- package/dist/cjs/hooks/useSecureDevice.js +15 -1
- package/dist/cjs/hooks/useSecureDevice.js.map +1 -1
- package/dist/cjs/hooks/useSecureHandshakes.js +36 -2
- package/dist/cjs/hooks/useSecureHandshakes.js.map +1 -1
- package/dist/cjs/hooks/useSecureMessages.d.ts +30 -18
- package/dist/cjs/hooks/useSecureMessages.js +197 -130
- package/dist/cjs/hooks/useSecureMessages.js.map +1 -1
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +30 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/persistence/repository.d.ts +24 -0
- package/dist/cjs/persistence/repository.js +35 -0
- package/dist/cjs/persistence/repository.js.map +1 -1
- package/dist/cjs/persistence/store.js +11 -0
- package/dist/cjs/persistence/store.js.map +1 -1
- package/dist/cjs/transport/rest.d.ts +2 -2
- package/dist/cjs/transport/rest.js +2 -2
- package/dist/cjs/transport/rest.js.map +1 -1
- package/dist/cjs/transport/socket.d.ts +1 -1
- package/dist/cjs/transport/socket.js +17 -1
- package/dist/cjs/transport/socket.js.map +1 -1
- package/dist/cjs/version.d.ts +13 -0
- package/dist/cjs/version.js +19 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/content/builders.d.ts +40 -0
- package/dist/esm/content/builders.js +77 -0
- package/dist/esm/content/builders.js.map +1 -0
- package/dist/esm/content/cbor.d.ts +48 -0
- package/dist/esm/content/cbor.js +292 -0
- package/dist/esm/content/cbor.js.map +1 -0
- package/dist/esm/content/frame.d.ts +24 -0
- package/dist/esm/content/frame.js +34 -0
- package/dist/esm/content/frame.js.map +1 -0
- package/dist/esm/content/mimi-content.d.ts +194 -0
- package/dist/esm/content/mimi-content.js +283 -0
- package/dist/esm/content/mimi-content.js.map +1 -0
- package/dist/esm/context/secure-chat-context.d.ts +19 -3
- package/dist/esm/context/secure-chat-context.js +53 -13
- package/dist/esm/context/secure-chat-context.js.map +1 -1
- package/dist/esm/hooks/message-fold.d.ts +91 -0
- package/dist/esm/hooks/message-fold.js +214 -0
- package/dist/esm/hooks/message-fold.js.map +1 -0
- package/dist/esm/hooks/useSecureConversations.js +11 -0
- package/dist/esm/hooks/useSecureConversations.js.map +1 -1
- package/dist/esm/hooks/useSecureDevice.js +15 -1
- package/dist/esm/hooks/useSecureDevice.js.map +1 -1
- package/dist/esm/hooks/useSecureHandshakes.js +36 -2
- package/dist/esm/hooks/useSecureHandshakes.js.map +1 -1
- package/dist/esm/hooks/useSecureMessages.d.ts +30 -18
- package/dist/esm/hooks/useSecureMessages.js +199 -132
- package/dist/esm/hooks/useSecureMessages.js.map +1 -1
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/persistence/repository.d.ts +24 -0
- package/dist/esm/persistence/repository.js +35 -0
- package/dist/esm/persistence/repository.js.map +1 -1
- package/dist/esm/persistence/store.js +11 -0
- package/dist/esm/persistence/store.js.map +1 -1
- package/dist/esm/transport/rest.d.ts +2 -2
- package/dist/esm/transport/rest.js +2 -2
- package/dist/esm/transport/rest.js.map +1 -1
- package/dist/esm/transport/socket.d.ts +1 -1
- package/dist/esm/transport/socket.js +17 -1
- package/dist/esm/transport/socket.js.map +1 -1
- package/dist/esm/version.d.ts +13 -0
- package/dist/esm/version.js +16 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { SecureMessageModel } from "../contract/index.js";
|
|
2
2
|
import { GroupHandle, type SecureDecryptFailureReason } from "@agora-sdk/secure-chat-crypto";
|
|
3
|
+
import { type MimiContent } from "../content/mimi-content.js";
|
|
4
|
+
import { type RenderedContent } from "./message-fold.js";
|
|
3
5
|
/**
|
|
4
6
|
* Decryption outcome for a stored message:
|
|
5
|
-
* - `ok` — decrypted + authenticated; `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - `rejected` — fails closed
|
|
9
|
-
* too-old epoch). NEVER retried; `plaintext` is null and `rejectedReason` says why.
|
|
7
|
+
* - `ok` — decrypted + authenticated + decoded; `content`/`mimi`/`contentHash` are set (unless it is a
|
|
8
|
+
* folded mutation, which the list omits, or a reserved control frame, which is hidden).
|
|
9
|
+
* - `pending` — not decryptable yet (no handle, or epoch ahead). Retried when the group advances.
|
|
10
|
+
* - `rejected` — fails closed (replay/gap/bad-auth/malformed/too-old, or undecodable content). Never retried.
|
|
10
11
|
*/
|
|
11
12
|
export type SecureMessageStatus = "ok" | "pending" | "rejected";
|
|
12
|
-
/** A stored message paired with its
|
|
13
|
+
/** A stored message paired with its decoded, folded content. */
|
|
13
14
|
export interface DecryptedSecureMessage {
|
|
14
15
|
/** The raw message row from the server (still holds the base64 ciphertext). */
|
|
15
16
|
model: SecureMessageModel;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
17
|
+
/** The Tier-2 projection (body/replyTo/editedAt/deleted/reactions), or `null` when not `ok`. */
|
|
18
|
+
content: RenderedContent | null;
|
|
19
|
+
/** The raw decoded `MimiContent` (power users), or `null` when not `ok`. */
|
|
20
|
+
mimi: MimiContent | null;
|
|
21
|
+
/** SHA-256 content-hash — reference this to reply/react/edit/delete — or `null` when not `ok`. */
|
|
22
|
+
contentHash: Uint8Array | null;
|
|
23
|
+
/** Decryption outcome. */
|
|
19
24
|
status: SecureMessageStatus;
|
|
20
|
-
/** When `status` is `rejected`, why
|
|
25
|
+
/** When `status` is `rejected`, why. */
|
|
21
26
|
rejectedReason?: SecureDecryptFailureReason;
|
|
22
27
|
}
|
|
23
28
|
/** Options for {@link useSecureMessages}. */
|
|
@@ -29,7 +34,7 @@ export interface UseSecureMessagesOptions {
|
|
|
29
34
|
}
|
|
30
35
|
/** The state and actions returned by {@link useSecureMessages}. */
|
|
31
36
|
export interface UseSecureMessagesValues {
|
|
32
|
-
/**
|
|
37
|
+
/** Rendered messages (post/reply rows with folded reactions/edits/deletes), newest first. */
|
|
33
38
|
messages: DecryptedSecureMessage[];
|
|
34
39
|
/** True while a page load or refresh is in flight. */
|
|
35
40
|
loading: boolean;
|
|
@@ -41,15 +46,21 @@ export interface UseSecureMessagesValues {
|
|
|
41
46
|
loadMore: () => Promise<void>;
|
|
42
47
|
/** Reload from the newest message, replacing the current list. */
|
|
43
48
|
refresh: () => Promise<void>;
|
|
44
|
-
/** Encrypt + send a text
|
|
49
|
+
/** Encrypt + send a text post. */
|
|
45
50
|
sendMessage: (text: string) => Promise<void>;
|
|
51
|
+
/** Send a reply to the message with `targetHash` (its {@link DecryptedSecureMessage.contentHash}). */
|
|
52
|
+
reply: (targetHash: Uint8Array, text: string) => Promise<void>;
|
|
53
|
+
/** React to the message with `targetHash` using `token` (e.g. an emoji). */
|
|
54
|
+
react: (targetHash: Uint8Array, token: string) => Promise<void>;
|
|
55
|
+
/** Edit the message with `targetHash`, replacing its body with `text`. */
|
|
56
|
+
editMessage: (targetHash: Uint8Array, text: string) => Promise<void>;
|
|
57
|
+
/** Delete (tombstone) the message with `targetHash`. */
|
|
58
|
+
deleteMessage: (targetHash: Uint8Array) => Promise<void>;
|
|
59
|
+
/** Withdraw your reaction whose own content-hash is `reactionHash`. */
|
|
60
|
+
unreact: (reactionHash: Uint8Array) => Promise<void>;
|
|
46
61
|
}
|
|
47
62
|
/**
|
|
48
|
-
* Load, decrypt, send, and live-receive messages in one secure conversation.
|
|
49
|
-
*
|
|
50
|
-
* Auto-resolves the MLS group handle (via `resolveGroup`) and the sender device id (from the
|
|
51
|
-
* persisted device) unless overridden in `options`. Joins the conversation socket room for live
|
|
52
|
-
* `secure:message` events.
|
|
63
|
+
* Load, decrypt, send, and live-receive MIMI-content messages in one secure conversation.
|
|
53
64
|
*
|
|
54
65
|
* @param conversationId - The conversation to read and send within.
|
|
55
66
|
* @param options - {@link UseSecureMessagesOptions}.
|
|
@@ -57,8 +68,9 @@ export interface UseSecureMessagesValues {
|
|
|
57
68
|
*
|
|
58
69
|
* @example
|
|
59
70
|
* ```tsx
|
|
60
|
-
* const { messages, sendMessage } = useSecureMessages(conversationId);
|
|
71
|
+
* const { messages, sendMessage, react } = useSecureMessages(conversationId);
|
|
61
72
|
* await sendMessage("hello 💜");
|
|
73
|
+
* await react(messages[0].contentHash!, "👍");
|
|
62
74
|
* ```
|
|
63
75
|
*/
|
|
64
76
|
export declare function useSecureMessages(conversationId: string, options?: UseSecureMessagesOptions): UseSecureMessagesValues;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// useSecureMessages — load, decrypt, send, and live-receive messages in a secure conversation.
|
|
2
|
+
// useSecureMessages — load, decrypt, send, and live-receive MIMI-content messages in a secure conversation.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// Content is the IETF MimiContent format (CBOR) inside a [kind][payload] routing frame inside the
|
|
5
|
+
// size-bucket padding frame — all ABOVE the unchanged SecureChatCrypto seam (which still exchanges
|
|
6
|
+
// Uint8Array). The hook owns message-list STATE (dedup, ordering, decrypt-once, write-through) keyed by
|
|
7
|
+
// server messageId; a MessageFold collapses reaction/edit/delete/un-react messages onto their target by
|
|
8
|
+
// MIMI content-hash. The durable source of truth stays REST; realtime is a notification optimization.
|
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
10
|
exports.useSecureMessages = useSecureMessages;
|
|
10
11
|
const react_1 = require("react");
|
|
@@ -13,13 +14,48 @@ const base64_js_1 = require("../util/base64.js");
|
|
|
13
14
|
const padding_js_1 = require("../util/padding.js");
|
|
14
15
|
const debug_js_1 = require("../util/debug.js");
|
|
15
16
|
const secure_chat_context_js_1 = require("../context/secure-chat-context.js");
|
|
17
|
+
const frame_js_1 = require("../content/frame.js");
|
|
18
|
+
const mimi_content_js_1 = require("../content/mimi-content.js");
|
|
19
|
+
const builders_js_1 = require("../content/builders.js");
|
|
20
|
+
const message_fold_js_1 = require("./message-fold.js");
|
|
16
21
|
const log = (0, debug_js_1.createDebugLogger)("messages");
|
|
22
|
+
const REJECT_MALFORMED = { status: "rejected", rejectedReason: "malformed" };
|
|
23
|
+
/** Decode a content-frame to a typed outcome. Pure; fails closed on any framing/schema error. */
|
|
24
|
+
function decodeFrame(frameBytes, model, senderDeviceId) {
|
|
25
|
+
let unf;
|
|
26
|
+
try {
|
|
27
|
+
unf = (0, frame_js_1.unframe)(frameBytes);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return REJECT_MALFORMED;
|
|
31
|
+
}
|
|
32
|
+
// kind 1 = IUC control (reserved; out of scope here): authenticate + hide, never render, never error.
|
|
33
|
+
if (unf.kind === frame_js_1.ContentKind.IucControl)
|
|
34
|
+
return { status: "ok", control: true };
|
|
35
|
+
if (unf.kind !== frame_js_1.ContentKind.Mimi)
|
|
36
|
+
return REJECT_MALFORMED;
|
|
37
|
+
let mimi;
|
|
38
|
+
try {
|
|
39
|
+
mimi = (0, mimi_content_js_1.decodeMimiContent)(unf.payload);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return REJECT_MALFORMED;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
status: "ok",
|
|
46
|
+
control: false,
|
|
47
|
+
decoded: {
|
|
48
|
+
messageId: model.id,
|
|
49
|
+
createdAt: model.createdAt,
|
|
50
|
+
senderDeviceId,
|
|
51
|
+
contentHash: (0, mimi_content_js_1.contentHash)(mimi),
|
|
52
|
+
mimi,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const cmpStr = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
17
57
|
/**
|
|
18
|
-
* Load, decrypt, send, and live-receive messages in one secure conversation.
|
|
19
|
-
*
|
|
20
|
-
* Auto-resolves the MLS group handle (via `resolveGroup`) and the sender device id (from the
|
|
21
|
-
* persisted device) unless overridden in `options`. Joins the conversation socket room for live
|
|
22
|
-
* `secure:message` events.
|
|
58
|
+
* Load, decrypt, send, and live-receive MIMI-content messages in one secure conversation.
|
|
23
59
|
*
|
|
24
60
|
* @param conversationId - The conversation to read and send within.
|
|
25
61
|
* @param options - {@link UseSecureMessagesOptions}.
|
|
@@ -27,40 +63,38 @@ const log = (0, debug_js_1.createDebugLogger)("messages");
|
|
|
27
63
|
*
|
|
28
64
|
* @example
|
|
29
65
|
* ```tsx
|
|
30
|
-
* const { messages, sendMessage } = useSecureMessages(conversationId);
|
|
66
|
+
* const { messages, sendMessage, react } = useSecureMessages(conversationId);
|
|
31
67
|
* await sendMessage("hello 💜");
|
|
68
|
+
* await react(messages[0].contentHash!, "👍");
|
|
32
69
|
* ```
|
|
33
70
|
*/
|
|
34
71
|
function useSecureMessages(conversationId, options = {}) {
|
|
35
|
-
const { rest, crypto, socket, repo, resolveGroup, getGroupVersion, subscribeGroupChange, padding } = (0, secure_chat_context_js_1.useSecureChat)();
|
|
36
|
-
const [messages, setMessages] = (0, react_1.useState)([]);
|
|
72
|
+
const { rest, crypto, socket, repo, resolveGroup, persistGroupState, getGroupVersion, subscribeGroupChange, padding, } = (0, secure_chat_context_js_1.useSecureChat)();
|
|
37
73
|
const [before, setBefore] = (0, react_1.useState)(undefined);
|
|
38
74
|
const [hasMore, setHasMore] = (0, react_1.useState)(true);
|
|
39
75
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
40
76
|
const [error, setError] = (0, react_1.useState)(null);
|
|
41
77
|
const [group, setGroup] = (0, react_1.useState)(options.group ?? null);
|
|
42
78
|
const [senderDeviceId, setSenderDeviceId] = (0, react_1.useState)(options.senderDeviceId);
|
|
43
|
-
// Bumps when THIS conversation's group handle advances (a join or a processed Commit, driven by
|
|
44
|
-
// useSecureHandshakes calling rememberGroup). Feeds the group-resolve effect's deps so we re-resolve
|
|
45
|
-
// the now-current handle and flush buffered (plaintext:null) rows.
|
|
46
79
|
const [groupVersion, setGroupVersion] = (0, react_1.useState)(0);
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
80
|
+
// Rendered state lives in refs (the fold mutates target rows in place); `bump` forces a re-derive.
|
|
81
|
+
const byIdRef = (0, react_1.useRef)(new Map());
|
|
82
|
+
const foldRef = (0, react_1.useRef)(new message_fold_js_1.MessageFold());
|
|
83
|
+
// Decrypt-once cache by id: MLS application keys are single-use, so the one decrypt that succeeds is
|
|
84
|
+
// the only one that ever will. Survives StrictMode double-invokes and multi-effect decrypts.
|
|
85
|
+
const okCache = (0, react_1.useRef)(new Map());
|
|
86
|
+
const [version, bump] = (0, react_1.useReducer)((x) => x + 1, 0);
|
|
87
|
+
const groupRef = (0, react_1.useRef)(group);
|
|
88
|
+
groupRef.current = group;
|
|
53
89
|
(0, react_1.useEffect)(() => {
|
|
54
90
|
return subscribeGroupChange(() => setGroupVersion(getGroupVersion(conversationId)));
|
|
55
91
|
}, [subscribeGroupChange, getGroupVersion, conversationId]);
|
|
56
|
-
// Resolve the group handle: explicit override, else persisted state.
|
|
92
|
+
// Resolve the group handle: explicit override, else persisted state. (Same as before.)
|
|
57
93
|
(0, react_1.useEffect)(() => {
|
|
58
94
|
if (options.group) {
|
|
59
95
|
setGroup(options.group);
|
|
60
96
|
return;
|
|
61
97
|
}
|
|
62
|
-
// Clear any stale handle from the previous conversation before re-resolving, so live messages
|
|
63
|
-
// for the new conversation never decrypt against the old group during the async window.
|
|
64
98
|
setGroup(null);
|
|
65
99
|
let alive = true;
|
|
66
100
|
resolveGroup(conversationId)
|
|
@@ -75,9 +109,8 @@ function useSecureMessages(conversationId, options = {}) {
|
|
|
75
109
|
return () => {
|
|
76
110
|
alive = false;
|
|
77
111
|
};
|
|
78
|
-
// `groupVersion` re-runs this when a Commit/join advances the handle → flushes buffered rows.
|
|
79
112
|
}, [options.group, conversationId, resolveGroup, groupVersion]);
|
|
80
|
-
// Resolve the sender device id: explicit override, else persisted device row.
|
|
113
|
+
// Resolve the sender device id: explicit override, else persisted device row. (Same as before.)
|
|
81
114
|
(0, react_1.useEffect)(() => {
|
|
82
115
|
if (options.senderDeviceId) {
|
|
83
116
|
setSenderDeviceId(options.senderDeviceId);
|
|
@@ -98,86 +131,127 @@ function useSecureMessages(conversationId, options = {}) {
|
|
|
98
131
|
alive = false;
|
|
99
132
|
};
|
|
100
133
|
}, [options.senderDeviceId, repo]);
|
|
134
|
+
// Decrypt one message to a typed outcome. Two short-circuits BEFORE the single-use ratchet: the
|
|
135
|
+
// in-memory okCache and the durable content-frame store. A store/cache hit re-decodes locally and
|
|
136
|
+
// NEVER touches the ratchet (re-decrypting a consumed key throws "Desired gen in the past").
|
|
101
137
|
const decrypt = (0, react_1.useCallback)(async (model) => {
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
138
|
+
const cached = okCache.current.get(model.id);
|
|
139
|
+
if (cached)
|
|
140
|
+
return cached;
|
|
141
|
+
const storedFrame = await repo.loadMessageContent(conversationId, model.id);
|
|
142
|
+
if (storedFrame !== null) {
|
|
143
|
+
// The frame was already authenticated when first decrypted (and write-through only happens on an
|
|
144
|
+
// `ok` decrypt). The server-reported senderDeviceId is just a render label here; coalesce its
|
|
145
|
+
// possible null to "" so the fold's DecodedContentMessage stays a plain string.
|
|
146
|
+
const outcome = decodeFrame(storedFrame, model, model.senderDeviceId ?? "");
|
|
147
|
+
if (outcome.status === "ok")
|
|
148
|
+
okCache.current.set(model.id, outcome);
|
|
149
|
+
return outcome;
|
|
106
150
|
}
|
|
151
|
+
const grp = groupRef.current;
|
|
152
|
+
if (!grp)
|
|
153
|
+
return { status: "pending" };
|
|
107
154
|
let plaintext;
|
|
155
|
+
let sender;
|
|
108
156
|
try {
|
|
109
|
-
({ plaintext } = await crypto.decryptMessage(
|
|
157
|
+
({ plaintext, senderDeviceId: sender } = await crypto.decryptMessage(grp, (0, base64_js_1.fromBase64)(model.ciphertext)));
|
|
110
158
|
}
|
|
111
159
|
catch (err) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// at an epoch we HAVE reached is a terminal rejection — the MLS core refused it (replay,
|
|
115
|
-
// over-window gap, bad auth, malformed, too-old epoch). Fail closed: never show it as text and
|
|
116
|
-
// never silently retry it forever (the old behavior masked replays/forgeries as "pending").
|
|
117
|
-
if (BigInt(model.epoch) > group.epoch) {
|
|
118
|
-
log.debug("decrypt buffered — message epoch ahead of ours", {
|
|
119
|
-
messageId: model.id,
|
|
120
|
-
messageEpoch: model.epoch,
|
|
121
|
-
groupEpoch: group.epoch.toString(),
|
|
122
|
-
});
|
|
123
|
-
return { model, plaintext: null, status: "pending" };
|
|
124
|
-
}
|
|
160
|
+
if (BigInt(model.epoch) > grp.epoch)
|
|
161
|
+
return { status: "pending" }; // epoch ahead → buffer
|
|
125
162
|
const rejectedReason = err instanceof secure_chat_crypto_1.SecureChatDecryptError ? err.reason : "unknown";
|
|
126
|
-
|
|
127
|
-
messageId: model.id,
|
|
128
|
-
messageEpoch: model.epoch,
|
|
129
|
-
groupEpoch: group.epoch.toString(),
|
|
130
|
-
rejectedReason,
|
|
131
|
-
});
|
|
132
|
-
return { model, plaintext: null, status: "rejected", rejectedReason };
|
|
163
|
+
return { status: "rejected", rejectedReason };
|
|
133
164
|
}
|
|
134
|
-
|
|
135
|
-
// size-bucket padding frame (see util/padding). A bad frame here is NOT a decrypt failure — it's a
|
|
136
|
-
// framing/version mismatch from an authenticated sender — so fail closed as "malformed" rather
|
|
137
|
-
// than rendering raw padded bytes as text.
|
|
165
|
+
let frameBytes;
|
|
138
166
|
try {
|
|
139
|
-
|
|
167
|
+
frameBytes = (0, padding_js_1.unpadPlaintext)(plaintext); // authenticated sender, bad padding ⇒ malformed (fail closed)
|
|
140
168
|
}
|
|
141
169
|
catch {
|
|
142
|
-
return
|
|
170
|
+
return REJECT_MALFORMED;
|
|
171
|
+
}
|
|
172
|
+
const outcome = decodeFrame(frameBytes, model, sender);
|
|
173
|
+
if (outcome.status === "ok") {
|
|
174
|
+
okCache.current.set(model.id, outcome);
|
|
175
|
+
// Write-through the raw content-frame bytes (re-decoded + re-folded on reload), then persist the
|
|
176
|
+
// advanced RECEIVE ratchet (decrypt moved the generation in memory; a reload must not rewind it).
|
|
177
|
+
await repo.saveMessageContent(conversationId, model.id, frameBytes);
|
|
178
|
+
await persistGroupState(conversationId, grp);
|
|
179
|
+
}
|
|
180
|
+
return outcome;
|
|
181
|
+
}, [crypto, repo, conversationId, persistGroupState]);
|
|
182
|
+
// Fold one outcome into rendered state. `ok` is terminal (never downgraded — forward secrecy).
|
|
183
|
+
const ingest = (0, react_1.useCallback)((model, outcome) => {
|
|
184
|
+
const entries = byIdRef.current;
|
|
185
|
+
const prev = entries.get(model.id);
|
|
186
|
+
if (prev?.status === "ok")
|
|
187
|
+
return;
|
|
188
|
+
if (outcome.status === "ok") {
|
|
189
|
+
if (outcome.control) {
|
|
190
|
+
entries.set(model.id, { model, status: "ok", renderable: false });
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
const { renderable } = foldRef.current.apply(outcome.decoded);
|
|
194
|
+
entries.set(model.id, { model, status: "ok", renderable, decoded: outcome.decoded });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (outcome.status === "pending") {
|
|
198
|
+
if (!prev)
|
|
199
|
+
entries.set(model.id, { model, status: "pending", renderable: false });
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
if (!prev || prev.status === "pending")
|
|
203
|
+
entries.set(model.id, { model, status: "rejected", renderable: false, rejectedReason: outcome.rejectedReason });
|
|
204
|
+
}
|
|
205
|
+
bump();
|
|
206
|
+
}, []);
|
|
207
|
+
// Derive the rendered list: only renderable (post/reply) rows + non-ok rows, newest-first. Mutation
|
|
208
|
+
// and control rows are folded/hidden. Recomputed on every `bump` (fold mutates rows in place).
|
|
209
|
+
const messages = (0, react_1.useMemo)(() => {
|
|
210
|
+
const rows = [];
|
|
211
|
+
for (const e of byIdRef.current.values()) {
|
|
212
|
+
if (e.status === "ok") {
|
|
213
|
+
if (!e.renderable)
|
|
214
|
+
continue;
|
|
215
|
+
rows.push({
|
|
216
|
+
model: e.model,
|
|
217
|
+
content: foldRef.current.getContent(e.model.id),
|
|
218
|
+
mimi: e.decoded?.mimi ?? null,
|
|
219
|
+
contentHash: e.decoded?.contentHash ?? null,
|
|
220
|
+
status: "ok",
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
rows.push({ model: e.model, content: null, mimi: null, contentHash: null, status: e.status, rejectedReason: e.rejectedReason });
|
|
225
|
+
}
|
|
143
226
|
}
|
|
144
|
-
|
|
227
|
+
rows.sort((a, b) => cmpStr(b.model.createdAt, a.model.createdAt) || cmpStr(b.model.id, a.model.id));
|
|
228
|
+
return rows;
|
|
229
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
230
|
+
}, [version]);
|
|
145
231
|
const load = (0, react_1.useCallback)(async (reset) => {
|
|
146
232
|
setLoading(true);
|
|
147
233
|
setError(null);
|
|
148
234
|
try {
|
|
149
|
-
const page = await rest.listMessages(conversationId, {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
235
|
+
const page = await rest.listMessages(conversationId, { before: reset ? undefined : before, limit: 40 });
|
|
236
|
+
if (reset) {
|
|
237
|
+
byIdRef.current.clear();
|
|
238
|
+
foldRef.current.reset();
|
|
239
|
+
}
|
|
154
240
|
const oldest = page.messages[page.messages.length - 1];
|
|
155
241
|
setBefore(oldest ? oldest.createdAt : before);
|
|
156
242
|
setHasMore(page.hasMore);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
reset,
|
|
162
|
-
before: reset ? undefined : before,
|
|
163
|
-
count: decrypted.length,
|
|
164
|
-
hasMore: page.hasMore,
|
|
165
|
-
ok: decrypted.filter((m) => m.status === "ok").length,
|
|
166
|
-
pending: decrypted.filter((m) => m.status === "pending").length,
|
|
167
|
-
rejected: decrypted.filter((m) => m.status === "rejected").length,
|
|
168
|
-
});
|
|
243
|
+
for (const model of page.messages)
|
|
244
|
+
ingest(model, await decrypt(model));
|
|
245
|
+
bump();
|
|
246
|
+
log.debug("loaded message page", { conversationId, reset, count: page.messages.length, hasMore: page.hasMore });
|
|
169
247
|
}
|
|
170
248
|
catch (err) {
|
|
171
|
-
log.debug("load message page failed", {
|
|
172
|
-
conversationId,
|
|
173
|
-
error: err instanceof Error ? err.message : String(err),
|
|
174
|
-
});
|
|
175
249
|
setError(err);
|
|
176
250
|
}
|
|
177
251
|
finally {
|
|
178
252
|
setLoading(false);
|
|
179
253
|
}
|
|
180
|
-
}, [rest, conversationId, before, decrypt]);
|
|
254
|
+
}, [rest, conversationId, before, decrypt, ingest]);
|
|
181
255
|
const refresh = (0, react_1.useCallback)(async () => {
|
|
182
256
|
setBefore(undefined);
|
|
183
257
|
await load(true);
|
|
@@ -187,82 +261,75 @@ function useSecureMessages(conversationId, options = {}) {
|
|
|
187
261
|
return;
|
|
188
262
|
await load(false);
|
|
189
263
|
}, [hasMore, loading, load]);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// provider): the crypto layer tags the sender from the restored device identity, so after a
|
|
193
|
-
// reload the first send must wait for useSecureDevice's importDeviceState to complete.
|
|
264
|
+
// Shared send: encode → frame → pad → encrypt → persist ratchet → POST → persist content → optimistic.
|
|
265
|
+
const sendContent = (0, react_1.useCallback)(async (mimi) => {
|
|
194
266
|
if (!group)
|
|
195
267
|
throw new Error("Cannot send: no MLS group handle for this conversation.");
|
|
196
268
|
if (!senderDeviceId)
|
|
197
269
|
throw new Error("Cannot send: senderDeviceId is required.");
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
270
|
+
const frame = (0, frame_js_1.frameContent)(frame_js_1.ContentKind.Mimi, (0, mimi_content_js_1.encodeMimiContent)(mimi));
|
|
271
|
+
const { ciphertext, epoch } = await crypto.encryptMessage(group, (0, padding_js_1.padPlaintext)(frame, padding));
|
|
272
|
+
// Persist the advanced SEND ratchet BEFORE the network send (it moved regardless of success).
|
|
273
|
+
await persistGroupState(conversationId, group);
|
|
201
274
|
const sent = await rest.sendMessage(conversationId, {
|
|
202
275
|
ciphertext: (0, base64_js_1.toBase64)(ciphertext),
|
|
203
276
|
epoch: epoch.toString(),
|
|
204
277
|
senderDeviceId,
|
|
205
278
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
senderDeviceId,
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
279
|
+
await repo.saveMessageContent(conversationId, sent.id, frame);
|
|
280
|
+
// Optimistic: we can't decrypt our own MLS message, so seed the decoded content directly and cache
|
|
281
|
+
// it so the server echo short-circuits (no rejected flicker).
|
|
282
|
+
const decoded = {
|
|
283
|
+
messageId: sent.id, createdAt: sent.createdAt, senderDeviceId, contentHash: (0, mimi_content_js_1.contentHash)(mimi), mimi,
|
|
284
|
+
};
|
|
285
|
+
const outcome = { status: "ok", control: false, decoded };
|
|
286
|
+
okCache.current.set(sent.id, outcome);
|
|
287
|
+
ingest(sent, outcome);
|
|
288
|
+
log.debug("sent content", { conversationId, messageId: sent.id, epoch: epoch.toString() });
|
|
289
|
+
}, [crypto, rest, repo, conversationId, group, senderDeviceId, padding, persistGroupState, ingest]);
|
|
290
|
+
const sendMessage = (0, react_1.useCallback)((text) => sendContent((0, builders_js_1.buildPost)(text)), [sendContent]);
|
|
291
|
+
const reply = (0, react_1.useCallback)((t, text) => sendContent((0, builders_js_1.buildReply)(text, t)), [sendContent]);
|
|
292
|
+
const react = (0, react_1.useCallback)((t, token) => sendContent((0, builders_js_1.buildReaction)(t, token)), [sendContent]);
|
|
293
|
+
const editMessage = (0, react_1.useCallback)((t, text) => sendContent((0, builders_js_1.buildEdit)(t, text)), [sendContent]);
|
|
294
|
+
const deleteMessage = (0, react_1.useCallback)((t) => sendContent((0, builders_js_1.buildDelete)(t)), [sendContent]);
|
|
295
|
+
const unreact = (0, react_1.useCallback)((reactionHash) => sendContent((0, builders_js_1.buildUnreact)(reactionHash)), [sendContent]);
|
|
223
296
|
(0, react_1.useEffect)(() => {
|
|
224
297
|
refresh();
|
|
225
298
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
226
299
|
}, [conversationId]);
|
|
227
|
-
//
|
|
228
|
-
// resolveGroup is still in flight (those rows come back `pending`); a Commit/join also advances the
|
|
229
|
-
// epoch, letting previously-ahead rows decrypt. Retry ONLY `pending` rows — never `rejected` ones, so
|
|
230
|
-
// a replay/forgery the core already refused isn't retried on every epoch bump. `ok` rows are kept.
|
|
300
|
+
// Retry buffered (pending) rows when the group handle advances.
|
|
231
301
|
(0, react_1.useEffect)(() => {
|
|
232
302
|
if (!group)
|
|
233
303
|
return;
|
|
234
|
-
|
|
304
|
+
const pendingModels = [...byIdRef.current.values()].filter((e) => e.status === "pending").map((e) => e.model);
|
|
305
|
+
if (pendingModels.length === 0)
|
|
235
306
|
return;
|
|
236
307
|
let alive = true;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
308
|
+
(async () => {
|
|
309
|
+
for (const m of pendingModels) {
|
|
310
|
+
const outcome = await decrypt(m);
|
|
311
|
+
if (!alive)
|
|
312
|
+
return;
|
|
313
|
+
ingest(m, outcome);
|
|
314
|
+
}
|
|
315
|
+
})();
|
|
241
316
|
return () => {
|
|
242
317
|
alive = false;
|
|
243
318
|
};
|
|
244
|
-
}, [group, decrypt]);
|
|
245
|
-
// Live receive: join the conversation room and decrypt inbound ciphertext.
|
|
319
|
+
}, [group, decrypt, ingest]);
|
|
320
|
+
// Live receive: join the conversation room and decrypt+ingest inbound ciphertext.
|
|
246
321
|
(0, react_1.useEffect)(() => {
|
|
247
322
|
socket.joinConversation(conversationId);
|
|
248
323
|
const off = socket.on("secure:message", (model) => {
|
|
249
324
|
if (model.conversationId !== conversationId)
|
|
250
325
|
return;
|
|
251
|
-
decrypt(model).then((
|
|
252
|
-
if (prev.some((p) => p.model.id === m.model.id)) {
|
|
253
|
-
log.trace("live message deduped", { messageId: m.model.id });
|
|
254
|
-
return prev;
|
|
255
|
-
}
|
|
256
|
-
log.debug("live message received", {
|
|
257
|
-
conversationId,
|
|
258
|
-
messageId: m.model.id,
|
|
259
|
-
status: m.status,
|
|
260
|
-
});
|
|
261
|
-
return [m, ...prev];
|
|
262
|
-
}));
|
|
326
|
+
decrypt(model).then((outcome) => ingest(model, outcome));
|
|
263
327
|
});
|
|
264
328
|
return off;
|
|
265
|
-
}, [socket, conversationId, decrypt]);
|
|
266
|
-
return {
|
|
329
|
+
}, [socket, conversationId, decrypt, ingest]);
|
|
330
|
+
return {
|
|
331
|
+
messages, loading, hasMore, error, loadMore, refresh,
|
|
332
|
+
sendMessage, reply, react, editMessage, deleteMessage, unreact,
|
|
333
|
+
};
|
|
267
334
|
}
|
|
268
335
|
//# sourceMappingURL=useSecureMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSecureMessages.js","sourceRoot":"","sources":["../../../src/hooks/useSecureMessages.tsx"],"names":[],"mappings":";AAAA,+FAA+F;AAC/F,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,6FAA6F;AAC7F,6CAA6C;;AAiF7C,8CA8PC;AA7UD,iCAAiE;AAEjE,sEAIuC;AACvC,iDAAmF;AACnF,mDAAkE;AAClE,+CAAqD;AACrD,8EAAkE;AAElE,MAAM,GAAG,GAAG,IAAA,4BAAiB,EAAC,UAAU,CAAC,CAAC;AAkD1C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,iBAAiB,CAC/B,cAAsB,EACtB,UAAoC,EAAE;IAEtC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAChG,IAAA,sCAAa,GAAE,CAAC;IAElB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAA2B,EAAE,CAAC,CAAC;IACvE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAqB,SAAS,CAAC,CAAC;IACpE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAU,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqB,OAAO,CAAC,KAAK,IAAI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AE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO;QACpD,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO;KAC/D,CAAC;AACJ,CAAC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { VERSION } from "./version.js";
|
|
1
2
|
export { SecureChatProvider, useSecureChat } from "./context/secure-chat-context.js";
|
|
2
3
|
export type { SecureChatProviderProps, SecureChatContextValue, } from "./context/secure-chat-context.js";
|
|
3
4
|
export { useSecureDevice } from "./hooks/useSecureDevice.js";
|
|
@@ -30,5 +31,12 @@ export { padPlaintext, unpadPlaintext, nextBucket } from "./util/padding.js";
|
|
|
30
31
|
export type { PaddingPolicy } from "./util/padding.js";
|
|
31
32
|
export { computeSafetyNumber } from "./util/safety-number.js";
|
|
32
33
|
export type { SafetyNumber } from "./util/safety-number.js";
|
|
34
|
+
export { encodeMimiContent, decodeMimiContent, contentHash, Cardinality, Disposition, HashAlg, PartSemantics, MIMI_LIMITS, } from "./content/mimi-content.js";
|
|
35
|
+
export type { MimiContent, Part, NullPart, SinglePart, ExternalPart, MultiPart, Expiration, } from "./content/mimi-content.js";
|
|
36
|
+
export { buildPost, buildReply, buildEdit, buildDelete, buildReaction, buildUnreact, } from "./content/builders.js";
|
|
37
|
+
export { frameContent, unframe, ContentKind } from "./content/frame.js";
|
|
38
|
+
export type { RenderedContent } from "./hooks/message-fold.js";
|
|
39
|
+
export { encode as encodeCbor, decode as decodeCbor, CborTag } from "./content/cbor.js";
|
|
40
|
+
export type { CborValue, CborMap, CborLimits } from "./content/cbor.js";
|
|
33
41
|
export { setSecureChatDebug, isSecureChatDebugEnabled } from "./util/debug.js";
|
|
34
42
|
export type { SecureChatDebugLevel, SecureChatDebugLogger } from "./util/debug.js";
|