@agora-sdk/secure-chat-core 0.1.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/LICENSE +202 -0
- package/dist/cjs/context/secure-chat-context.d.ts +60 -0
- package/dist/cjs/context/secure-chat-context.js +70 -0
- package/dist/cjs/context/secure-chat-context.js.map +1 -0
- package/dist/cjs/contract/index.d.ts +150 -0
- package/dist/cjs/contract/index.js +16 -0
- package/dist/cjs/contract/index.js.map +1 -0
- package/dist/cjs/hooks/useSecureConversations.d.ts +35 -0
- package/dist/cjs/hooks/useSecureConversations.js +109 -0
- package/dist/cjs/hooks/useSecureConversations.js.map +1 -0
- package/dist/cjs/hooks/useSecureDevice.d.ts +47 -0
- package/dist/cjs/hooks/useSecureDevice.js +120 -0
- package/dist/cjs/hooks/useSecureDevice.js.map +1 -0
- package/dist/cjs/hooks/useSecureMessages.d.ts +52 -0
- package/dist/cjs/hooks/useSecureMessages.js +113 -0
- package/dist/cjs/hooks/useSecureMessages.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/transport/rest.d.ts +154 -0
- package/dist/cjs/transport/rest.js +208 -0
- package/dist/cjs/transport/rest.js.map +1 -0
- package/dist/cjs/transport/socket.d.ts +79 -0
- package/dist/cjs/transport/socket.js +70 -0
- package/dist/cjs/transport/socket.js.map +1 -0
- package/dist/cjs/util/base64.d.ts +8 -0
- package/dist/cjs/util/base64.js +69 -0
- package/dist/cjs/util/base64.js.map +1 -0
- package/dist/esm/context/secure-chat-context.d.ts +60 -0
- package/dist/esm/context/secure-chat-context.js +66 -0
- package/dist/esm/context/secure-chat-context.js.map +1 -0
- package/dist/esm/contract/index.d.ts +150 -0
- package/dist/esm/contract/index.js +15 -0
- package/dist/esm/contract/index.js.map +1 -0
- package/dist/esm/hooks/useSecureConversations.d.ts +35 -0
- package/dist/esm/hooks/useSecureConversations.js +106 -0
- package/dist/esm/hooks/useSecureConversations.js.map +1 -0
- package/dist/esm/hooks/useSecureDevice.d.ts +47 -0
- package/dist/esm/hooks/useSecureDevice.js +117 -0
- package/dist/esm/hooks/useSecureDevice.js.map +1 -0
- package/dist/esm/hooks/useSecureMessages.d.ts +52 -0
- package/dist/esm/hooks/useSecureMessages.js +110 -0
- package/dist/esm/hooks/useSecureMessages.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/transport/rest.d.ts +154 -0
- package/dist/esm/transport/rest.js +201 -0
- package/dist/esm/transport/rest.js.map +1 -0
- package/dist/esm/transport/socket.d.ts +79 -0
- package/dist/esm/transport/socket.js +66 -0
- package/dist/esm/transport/socket.js.map +1 -0
- package/dist/esm/util/base64.d.ts +8 -0
- package/dist/esm/util/base64.js +63 -0
- package/dist/esm/util/base64.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Replyke
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SecureChatCrypto } from "@agora-sdk/secure-chat-crypto";
|
|
3
|
+
import { SecureChatRestClient } from "../transport/rest";
|
|
4
|
+
import { SecureChatSocketClient } from "../transport/socket";
|
|
5
|
+
/**
|
|
6
|
+
* The value exposed by {@link useSecureChat}: the shared transport clients, the injected crypto,
|
|
7
|
+
* and the active project id. The hooks build everything else on top of these.
|
|
8
|
+
*/
|
|
9
|
+
export interface SecureChatContextValue {
|
|
10
|
+
/** REST client for the blind Delivery Service endpoints. */
|
|
11
|
+
rest: SecureChatRestClient;
|
|
12
|
+
/** Realtime client for the `/secure` socket.io namespace. */
|
|
13
|
+
socket: SecureChatSocketClient;
|
|
14
|
+
/** The injected MLS crypto implementation (mock, or platform ts-mls/native). */
|
|
15
|
+
crypto: SecureChatCrypto;
|
|
16
|
+
/** The Agora project id these clients are scoped to. */
|
|
17
|
+
projectId: string;
|
|
18
|
+
}
|
|
19
|
+
/** Props for {@link SecureChatProvider}. */
|
|
20
|
+
export interface SecureChatProviderProps {
|
|
21
|
+
/** The MLS crypto implementation (mock for tests; ts-mls/OpenMLS-WASM in platform packages). */
|
|
22
|
+
crypto: SecureChatCrypto;
|
|
23
|
+
/** Agora project id (path-scoped on every endpoint). */
|
|
24
|
+
projectId: string;
|
|
25
|
+
/** Current access token. Re-pass on refresh; read lazily per request. */
|
|
26
|
+
accessToken?: string;
|
|
27
|
+
/** Override token resolution (takes precedence over `accessToken`). */
|
|
28
|
+
getAccessToken?: () => string | undefined;
|
|
29
|
+
/** Override the API base URL. Defaults to @agora-sdk/core `getApiBaseUrl()`. */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Override the socket origin. Defaults to @agora-sdk/core `getSocketUrl()`. */
|
|
32
|
+
socketUrl?: string;
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Provides the secure-chat transport + crypto to the `useSecure*` hooks. Render it inside a
|
|
37
|
+
* `ReplykeProvider`: by default it inherits the API base URL and socket origin from
|
|
38
|
+
* `@agora-sdk/core`'s runtime, and disconnects the socket on unmount.
|
|
39
|
+
*
|
|
40
|
+
* @param props - {@link SecureChatProviderProps} — the injected crypto, project id, token, and
|
|
41
|
+
* optional base/socket URL overrides.
|
|
42
|
+
* @returns A context provider wrapping `children`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <ReplykeProvider projectId={projectId} baseUrl={baseUrl}>
|
|
47
|
+
* <SecureChatProvider crypto={crypto} projectId={projectId} accessToken={token}>
|
|
48
|
+
* <Chat />
|
|
49
|
+
* </SecureChatProvider>
|
|
50
|
+
* </ReplykeProvider>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function SecureChatProvider({ crypto, projectId, accessToken, getAccessToken, baseUrl, socketUrl, children, }: SecureChatProviderProps): React.JSX.Element;
|
|
54
|
+
/**
|
|
55
|
+
* Access the nearest {@link SecureChatContextValue}.
|
|
56
|
+
*
|
|
57
|
+
* @returns The shared rest/socket/crypto/projectId for this provider subtree.
|
|
58
|
+
* @throws {Error} When called outside a `<SecureChatProvider>`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useSecureChat(): SecureChatContextValue;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecureChatProvider = SecureChatProvider;
|
|
4
|
+
exports.useSecureChat = useSecureChat;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
// SecureChatProvider — wires the transport + crypto for the secure-chat hooks.
|
|
7
|
+
//
|
|
8
|
+
// Sits INSIDE a ReplykeProvider: by default it resolves the API base URL and socket origin from
|
|
9
|
+
// @agora-sdk/core's runtime singletons (getApiBaseUrl / getSocketUrl), so whatever `baseUrl` the
|
|
10
|
+
// app set on ReplykeProvider is honored here too. Crypto is injected (a `SecureChatCrypto`), keeping
|
|
11
|
+
// core platform- and library-agnostic — the web/native packages supply the concrete MLS impl.
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const core_1 = require("@agora-sdk/core");
|
|
14
|
+
const rest_1 = require("../transport/rest");
|
|
15
|
+
const socket_1 = require("../transport/socket");
|
|
16
|
+
const SecureChatContext = (0, react_1.createContext)(null);
|
|
17
|
+
/**
|
|
18
|
+
* Provides the secure-chat transport + crypto to the `useSecure*` hooks. Render it inside a
|
|
19
|
+
* `ReplykeProvider`: by default it inherits the API base URL and socket origin from
|
|
20
|
+
* `@agora-sdk/core`'s runtime, and disconnects the socket on unmount.
|
|
21
|
+
*
|
|
22
|
+
* @param props - {@link SecureChatProviderProps} — the injected crypto, project id, token, and
|
|
23
|
+
* optional base/socket URL overrides.
|
|
24
|
+
* @returns A context provider wrapping `children`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <ReplykeProvider projectId={projectId} baseUrl={baseUrl}>
|
|
29
|
+
* <SecureChatProvider crypto={crypto} projectId={projectId} accessToken={token}>
|
|
30
|
+
* <Chat />
|
|
31
|
+
* </SecureChatProvider>
|
|
32
|
+
* </ReplykeProvider>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function SecureChatProvider({ crypto, projectId, accessToken, getAccessToken, baseUrl, socketUrl, children, }) {
|
|
36
|
+
// Keep the latest token in a ref so the per-request resolver always returns the current value
|
|
37
|
+
// without rebuilding the transport clients on every token change.
|
|
38
|
+
const tokenRef = (0, react_1.useRef)(accessToken);
|
|
39
|
+
tokenRef.current = accessToken;
|
|
40
|
+
const resolveToken = (0, react_1.useMemo)(() => getAccessToken ?? (() => tokenRef.current), [getAccessToken]);
|
|
41
|
+
const rest = (0, react_1.useMemo)(() => new rest_1.SecureChatRestClient({
|
|
42
|
+
projectId,
|
|
43
|
+
getAccessToken: resolveToken,
|
|
44
|
+
getBaseUrl: () => baseUrl ?? (0, core_1.getApiBaseUrl)(),
|
|
45
|
+
}), [projectId, resolveToken, baseUrl]);
|
|
46
|
+
const socket = (0, react_1.useMemo)(() => new socket_1.SecureChatSocketClient({
|
|
47
|
+
projectId,
|
|
48
|
+
getAccessToken: resolveToken,
|
|
49
|
+
getSocketUrl: () => socketUrl ?? (0, core_1.getSocketUrl)(),
|
|
50
|
+
}), [projectId, resolveToken, socketUrl]);
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
return () => socket.disconnect();
|
|
53
|
+
}, [socket]);
|
|
54
|
+
const value = (0, react_1.useMemo)(() => ({ rest, socket, crypto, projectId }), [rest, socket, crypto, projectId]);
|
|
55
|
+
return (0, jsx_runtime_1.jsx)(SecureChatContext.Provider, { value: value, children: children });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Access the nearest {@link SecureChatContextValue}.
|
|
59
|
+
*
|
|
60
|
+
* @returns The shared rest/socket/crypto/projectId for this provider subtree.
|
|
61
|
+
* @throws {Error} When called outside a `<SecureChatProvider>`.
|
|
62
|
+
*/
|
|
63
|
+
function useSecureChat() {
|
|
64
|
+
const ctx = (0, react_1.useContext)(SecureChatContext);
|
|
65
|
+
if (!ctx) {
|
|
66
|
+
throw new Error("useSecureChat must be used within a <SecureChatProvider>.");
|
|
67
|
+
}
|
|
68
|
+
return ctx;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=secure-chat-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-chat-context.js","sourceRoot":"","sources":["../../../src/context/secure-chat-context.tsx"],"names":[],"mappings":";;AAkEA,gDAiDC;AAQD,sCAMC;;AAjID,+EAA+E;AAC/E,EAAE;AACF,gGAAgG;AAChG,iGAAiG;AACjG,qGAAqG;AACrG,8FAA8F;AAE9F,iCAAqF;AACrF,0CAA8D;AAG9D,4CAAyD;AACzD,gDAA6D;AAiB7D,MAAM,iBAAiB,GAAG,IAAA,qBAAa,EAAgC,IAAI,CAAC,CAAC;AAmB7E;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,SAAS,EACT,WAAW,EACX,cAAc,EACd,OAAO,EACP,SAAS,EACT,QAAQ,GACgB;IACxB,8FAA8F;IAC9F,kEAAkE;IAClE,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAqB,WAAW,CAAC,CAAC;IACzD,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC;IAE/B,MA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G,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export type SecureConversationType = "dm" | "group" | "channel";
|
|
2
|
+
export type SecureMemberRole = "admin" | "member";
|
|
3
|
+
export type SecureHandshakeKind = "welcome" | "commit" | "proposal";
|
|
4
|
+
/** A Welcome targeted at the ONE device whose claimed KeyPackage was consumed. */
|
|
5
|
+
export interface WelcomeEnvelope {
|
|
6
|
+
targetDeviceId: string;
|
|
7
|
+
payload: string;
|
|
8
|
+
epoch: string;
|
|
9
|
+
}
|
|
10
|
+
/** A Commit/Proposal broadcast to the whole group (no target device). */
|
|
11
|
+
export interface HandshakeBlob {
|
|
12
|
+
payload: string;
|
|
13
|
+
epoch: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RegisterDeviceBody {
|
|
16
|
+
deviceId: string;
|
|
17
|
+
displayName?: string | null;
|
|
18
|
+
signaturePublicKey: string;
|
|
19
|
+
credential: string;
|
|
20
|
+
ciphersuite: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PublishKeyPackagesBody {
|
|
23
|
+
keyPackages: {
|
|
24
|
+
keyPackageRef: string;
|
|
25
|
+
keyPackage: string;
|
|
26
|
+
ciphersuite: number;
|
|
27
|
+
expiresAt?: string | null;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
30
|
+
export interface CreateSecureConversationBody {
|
|
31
|
+
type: SecureConversationType;
|
|
32
|
+
mlsGroupId: string;
|
|
33
|
+
spaceId?: string | null;
|
|
34
|
+
name?: string | null;
|
|
35
|
+
memberUserIds?: string[];
|
|
36
|
+
welcomes?: WelcomeEnvelope[];
|
|
37
|
+
}
|
|
38
|
+
export interface AddSecureMemberBody {
|
|
39
|
+
userId: string;
|
|
40
|
+
commit: HandshakeBlob;
|
|
41
|
+
welcomes: WelcomeEnvelope[];
|
|
42
|
+
}
|
|
43
|
+
export interface RemoveSecureMemberBody {
|
|
44
|
+
commit: HandshakeBlob;
|
|
45
|
+
}
|
|
46
|
+
export interface SendSecureMessageBody {
|
|
47
|
+
ciphertext: string;
|
|
48
|
+
epoch: string;
|
|
49
|
+
senderDeviceId: string;
|
|
50
|
+
contentType?: string | null;
|
|
51
|
+
}
|
|
52
|
+
export interface UploadKeyBackupBody {
|
|
53
|
+
deviceId?: string | null;
|
|
54
|
+
blob: string;
|
|
55
|
+
nonce: string;
|
|
56
|
+
kdf: "argon2id" | "pbkdf2";
|
|
57
|
+
kdfParams: Record<string, unknown>;
|
|
58
|
+
cipher: "xchacha20poly1305" | "aes-256-gcm";
|
|
59
|
+
version: number;
|
|
60
|
+
}
|
|
61
|
+
export interface SecureDeviceModel {
|
|
62
|
+
id: string;
|
|
63
|
+
projectId: string;
|
|
64
|
+
userId: string;
|
|
65
|
+
deviceId: string;
|
|
66
|
+
displayName: string | null;
|
|
67
|
+
signaturePublicKey: string;
|
|
68
|
+
credential: string;
|
|
69
|
+
ciphersuite: number;
|
|
70
|
+
revokedAt: string | null;
|
|
71
|
+
lastSeenAt: string | null;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
updatedAt: string;
|
|
74
|
+
}
|
|
75
|
+
export interface SecureKeyPackageClaim {
|
|
76
|
+
deviceId: string;
|
|
77
|
+
keyPackageRef: string;
|
|
78
|
+
keyPackage: string;
|
|
79
|
+
ciphersuite: number;
|
|
80
|
+
}
|
|
81
|
+
export interface SecureConversationMemberModel {
|
|
82
|
+
id: string;
|
|
83
|
+
projectId: string;
|
|
84
|
+
conversationId: string;
|
|
85
|
+
userId: string;
|
|
86
|
+
role: SecureMemberRole;
|
|
87
|
+
isActive: boolean;
|
|
88
|
+
joinedAtEpoch: string | null;
|
|
89
|
+
lastReadAt: string | null;
|
|
90
|
+
leftAt: string | null;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
}
|
|
94
|
+
export interface SecureConversationModel {
|
|
95
|
+
id: string;
|
|
96
|
+
projectId: string;
|
|
97
|
+
type: SecureConversationType;
|
|
98
|
+
mlsGroupId: string;
|
|
99
|
+
spaceId: string | null;
|
|
100
|
+
currentEpoch: string;
|
|
101
|
+
name: string | null;
|
|
102
|
+
createdById: string | null;
|
|
103
|
+
lastMessageAt: string | null;
|
|
104
|
+
memberCount?: number;
|
|
105
|
+
unreadCount?: number;
|
|
106
|
+
currentMember?: SecureConversationMemberModel;
|
|
107
|
+
createdAt: string;
|
|
108
|
+
updatedAt: string;
|
|
109
|
+
}
|
|
110
|
+
export interface SecureMessageModel {
|
|
111
|
+
id: string;
|
|
112
|
+
projectId: string;
|
|
113
|
+
conversationId: string;
|
|
114
|
+
senderUserId: string | null;
|
|
115
|
+
senderDeviceId: string | null;
|
|
116
|
+
epoch: string;
|
|
117
|
+
ciphertext: string;
|
|
118
|
+
contentType: string;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
}
|
|
121
|
+
export interface SecureHandshakeModel {
|
|
122
|
+
id: string;
|
|
123
|
+
seq: string;
|
|
124
|
+
kind: SecureHandshakeKind;
|
|
125
|
+
conversationId: string;
|
|
126
|
+
epoch: string;
|
|
127
|
+
payload: string;
|
|
128
|
+
senderDeviceId: string | null;
|
|
129
|
+
targetDeviceId: string | null;
|
|
130
|
+
}
|
|
131
|
+
export interface SecureKeyBackupModel {
|
|
132
|
+
id: string;
|
|
133
|
+
projectId: string;
|
|
134
|
+
userId: string;
|
|
135
|
+
deviceId: string | null;
|
|
136
|
+
blob: string;
|
|
137
|
+
nonce: string;
|
|
138
|
+
kdf: string;
|
|
139
|
+
kdfParams: Record<string, unknown>;
|
|
140
|
+
cipher: string;
|
|
141
|
+
version: number;
|
|
142
|
+
createdAt: string;
|
|
143
|
+
updatedAt: string;
|
|
144
|
+
}
|
|
145
|
+
/** Standard error envelope: `{ error, code, field? }` with `secure-chat/*` codes. */
|
|
146
|
+
export interface SecureChatErrorBody {
|
|
147
|
+
error: string;
|
|
148
|
+
code: string;
|
|
149
|
+
field?: string;
|
|
150
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Secure-chat wire contract — stand-in for @agora/contract (the Apache-2.0 server contract).
|
|
3
|
+
//
|
|
4
|
+
// Mirrors the response models + request bodies of agora-server's
|
|
5
|
+
// `packages/contract/src/secure-chat.ts`. That package is the source of truth (zod + TS); the
|
|
6
|
+
// client only needs the TypeScript shapes, so this copy is types-only.
|
|
7
|
+
//
|
|
8
|
+
// ⚠️ Keep this byte-faithful to the server contract. The arrow is SDK → contract: once
|
|
9
|
+
// `@agora/contract` is published, DELETE this file and `import type { ... } from "@agora/contract"`.
|
|
10
|
+
// Do NOT publish a separate `@agora-sdk/secure-chat-contract` (that would invert the dependency —
|
|
11
|
+
// see STATUS.md). Do not let this copy drift in the meantime.
|
|
12
|
+
//
|
|
13
|
+
// Wire conventions: every binary value is **base64** (the server stores/relays opaque blobs and
|
|
14
|
+
// never parses them); MLS epochs are **decimal strings** (u64 exceeds JS safe-int range).
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":";AAAA,6FAA6F;AAC7F,EAAE;AACF,iEAAiE;AACjE,8FAA8F;AAC9F,uEAAuE;AACvE,EAAE;AACF,uFAAuF;AACvF,qGAAqG;AACrG,kGAAkG;AAClG,8DAA8D;AAC9D,EAAE;AACF,gGAAgG;AAChG,0FAA0F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SecureConversationModel } from "../contract";
|
|
2
|
+
/** The state and actions returned by {@link useSecureConversations}. */
|
|
3
|
+
export interface UseSecureConversationsValues {
|
|
4
|
+
/** The loaded conversations, newest activity first. */
|
|
5
|
+
conversations: SecureConversationModel[];
|
|
6
|
+
/** True while a page load or refresh is in flight. */
|
|
7
|
+
loading: boolean;
|
|
8
|
+
/** Whether more pages remain to {@link UseSecureConversationsValues.loadMore}. */
|
|
9
|
+
hasMore: boolean;
|
|
10
|
+
/** The last error thrown by loading or conversation creation, or `null`. */
|
|
11
|
+
error: unknown;
|
|
12
|
+
/** Append the next page of older conversations. No-op when already loading or exhausted. */
|
|
13
|
+
loadMore: () => Promise<void>;
|
|
14
|
+
/** Reload from the top, replacing the current list. */
|
|
15
|
+
refresh: () => Promise<void>;
|
|
16
|
+
/** Start (or surface) a 1:1 conversation with another user across all their devices. */
|
|
17
|
+
createDirectConversation: (peerUserId: string) => Promise<SecureConversationModel>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* List the caller's secure conversations and start new direct messages.
|
|
21
|
+
*
|
|
22
|
+
* Refreshes on mount and on `secure:member:joined` / `secure:member:left` signals.
|
|
23
|
+
* {@link UseSecureConversationsValues.createDirectConversation} claims one KeyPackage per peer
|
|
24
|
+
* device, builds the MLS group locally, and registers it on the blind DS with targeted Welcomes —
|
|
25
|
+
* the group secrets never leave the client.
|
|
26
|
+
*
|
|
27
|
+
* @returns {@link UseSecureConversationsValues} — the conversation list, paging state, and actions.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const { conversations, createDirectConversation } = useSecureConversations();
|
|
32
|
+
* await createDirectConversation(peerUserId);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useSecureConversations(): UseSecureConversationsValues;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// useSecureConversations — list the caller's secure conversations and start new DMs.
|
|
3
|
+
//
|
|
4
|
+
// Starting a DM (server spec §14.3): claim each peer device's KeyPackage → createGroup locally →
|
|
5
|
+
// POST /conversations with the Welcomes targeted to each peer device. The MLS group secrets stay on
|
|
6
|
+
// the client; the server only stores ciphertext metadata.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.useSecureConversations = useSecureConversations;
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const base64_1 = require("../util/base64");
|
|
11
|
+
const secure_chat_context_1 = require("../context/secure-chat-context");
|
|
12
|
+
/**
|
|
13
|
+
* List the caller's secure conversations and start new direct messages.
|
|
14
|
+
*
|
|
15
|
+
* Refreshes on mount and on `secure:member:joined` / `secure:member:left` signals.
|
|
16
|
+
* {@link UseSecureConversationsValues.createDirectConversation} claims one KeyPackage per peer
|
|
17
|
+
* device, builds the MLS group locally, and registers it on the blind DS with targeted Welcomes —
|
|
18
|
+
* the group secrets never leave the client.
|
|
19
|
+
*
|
|
20
|
+
* @returns {@link UseSecureConversationsValues} — the conversation list, paging state, and actions.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { conversations, createDirectConversation } = useSecureConversations();
|
|
25
|
+
* await createDirectConversation(peerUserId);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function useSecureConversations() {
|
|
29
|
+
const { rest, crypto, socket } = (0, secure_chat_context_1.useSecureChat)();
|
|
30
|
+
const [conversations, setConversations] = (0, react_1.useState)([]);
|
|
31
|
+
const [cursor, setCursor] = (0, react_1.useState)(undefined);
|
|
32
|
+
const [hasMore, setHasMore] = (0, react_1.useState)(true);
|
|
33
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
34
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
35
|
+
const load = (0, react_1.useCallback)(async (reset) => {
|
|
36
|
+
setLoading(true);
|
|
37
|
+
setError(null);
|
|
38
|
+
try {
|
|
39
|
+
const page = await rest.listConversations({
|
|
40
|
+
cursor: reset ? undefined : cursor,
|
|
41
|
+
limit: 30,
|
|
42
|
+
});
|
|
43
|
+
const last = page.conversations[page.conversations.length - 1];
|
|
44
|
+
setCursor(last ? last.lastMessageAt ?? last.createdAt : cursor);
|
|
45
|
+
setHasMore(page.hasMore);
|
|
46
|
+
setConversations((prev) => (reset ? page.conversations : [...prev, ...page.conversations]));
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
setError(err);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setLoading(false);
|
|
53
|
+
}
|
|
54
|
+
}, [rest, cursor]);
|
|
55
|
+
const refresh = (0, react_1.useCallback)(async () => {
|
|
56
|
+
setCursor(undefined);
|
|
57
|
+
await load(true);
|
|
58
|
+
}, [load]);
|
|
59
|
+
const loadMore = (0, react_1.useCallback)(async () => {
|
|
60
|
+
if (!hasMore || loading)
|
|
61
|
+
return;
|
|
62
|
+
await load(false);
|
|
63
|
+
}, [hasMore, loading, load]);
|
|
64
|
+
const createDirectConversation = (0, react_1.useCallback)(async (peerUserId) => {
|
|
65
|
+
// 1. Discover the peer's active devices and claim one KeyPackage per device.
|
|
66
|
+
const peerDevices = await rest.listDevices(peerUserId);
|
|
67
|
+
if (peerDevices.length === 0) {
|
|
68
|
+
throw new Error("Peer has no registered secure-chat devices.");
|
|
69
|
+
}
|
|
70
|
+
const initialMembers = await Promise.all(peerDevices.map(async (d) => {
|
|
71
|
+
const claim = await rest.claimKeyPackage(d.id);
|
|
72
|
+
return { deviceId: d.id, keyPackage: (0, base64_1.fromBase64)(claim.keyPackage) };
|
|
73
|
+
}));
|
|
74
|
+
// 2. Create the MLS group locally; the crypto layer holds the secrets.
|
|
75
|
+
const { group, welcomes } = await crypto.createGroup({ initialMembers });
|
|
76
|
+
// 3. Register the conversation on the blind DS, relaying the targeted Welcomes.
|
|
77
|
+
const conversation = await rest.createConversation({
|
|
78
|
+
type: "dm",
|
|
79
|
+
mlsGroupId: (0, base64_1.toBase64)(group.mlsGroupId),
|
|
80
|
+
memberUserIds: [peerUserId],
|
|
81
|
+
welcomes: welcomes.map((w) => ({
|
|
82
|
+
targetDeviceId: w.targetDeviceId,
|
|
83
|
+
payload: (0, base64_1.toBase64)(w.payload),
|
|
84
|
+
epoch: group.epoch.toString(),
|
|
85
|
+
})),
|
|
86
|
+
});
|
|
87
|
+
setConversations((prev) => [conversation, ...prev.filter((c) => c.id !== conversation.id)]);
|
|
88
|
+
return conversation;
|
|
89
|
+
}, [rest, crypto]);
|
|
90
|
+
(0, react_1.useEffect)(() => {
|
|
91
|
+
refresh();
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
}, []);
|
|
94
|
+
// Light realtime refresh on membership changes (metadata-only signals).
|
|
95
|
+
(0, react_1.useEffect)(() => {
|
|
96
|
+
const offJoined = socket.on("secure:member:joined", () => {
|
|
97
|
+
refresh().catch(setError);
|
|
98
|
+
});
|
|
99
|
+
const offLeft = socket.on("secure:member:left", () => {
|
|
100
|
+
refresh().catch(setError);
|
|
101
|
+
});
|
|
102
|
+
return () => {
|
|
103
|
+
offJoined();
|
|
104
|
+
offLeft();
|
|
105
|
+
};
|
|
106
|
+
}, [socket, refresh]);
|
|
107
|
+
return { conversations, loading, hasMore, error, loadMore, refresh, createDirectConversation };
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=useSecureConversations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSecureConversations.js","sourceRoot":"","sources":["../../../src/hooks/useSecureConversations.tsx"],"names":[],"mappings":";AAAA,qFAAqF;AACrF,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,0DAA0D;;AAyC1D,wDAgGC;AAvID,iCAAyD;AAEzD,2CAAsD;AACtD,wEAA+D;AAoB/D;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,sBAAsB;IACpC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,mCAAa,GAAE,CAAC;IAEjD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAA4B,EAAE,CAAC,CAAC;IAClF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAqB,SAAS,CAA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