@agora-server/contract 0.9.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASyD,CAAC;AAEzF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;EAQ9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;EAOwD,CAAC;AAIzF,eAAO,MAAM,cAAc;;;;;;EAEzB,CAAC;AAKH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAQjB,CAAC;AAIb,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBjB,CAAC;AAMb,eAAO,MAAM,uBAAuB,0DAA2D,CAAC;AAChG,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI3E,eAAO,MAAM,uBAAuB,+BAAgC,CAAC;AACrE,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAG5E,eAAO,MAAM,0BAA0B,4DAA6D,CAAC;AACrG,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAClF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAIpB,CAAC;AACb,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,mBA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I9B,CAAC;AAKH,eAAO,MAAM,6BAA6B,+MAehC,CAAC;AAUX,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC;AAKH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAMlC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;EAK/B,CAAC;AAGH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;EAOnC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKmD,CAAC;AAQzF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKqD,CAAC;AAEpF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;EAE0D,CAAC;AAEzF,eAAO,MAAM,qBAAqB;;;;;;EAEhC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;EAG9B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;EAGtC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;EAE/B,CAAC;AAGH,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC"}
@@ -0,0 +1,330 @@
1
+ // Zod request schemas for the Agora API. Pure zod — no server/Errors coupling.
2
+ // The server's parseBody(schema, raw) wraps these to throw a Replyke-shaped 400.
3
+ import { z } from "zod";
4
+ import { REACTION_TYPES } from "./reactions.js";
5
+ // .nullish() (= nullable + optional): SDK clients commonly send absent fields as `null`
6
+ // rather than omitting them. Accepting null avoids spurious 400s; handlers coerce null →
7
+ // undefined for columns that have NOT NULL defaults.
8
+ const mentions = z.array(z.unknown()).nullish();
9
+ const metadata = z.record(z.string(), z.unknown()).nullish();
10
+ export const createEntitySchema = z.object({
11
+ title: z.string().nullish(),
12
+ content: z.string().nullish(),
13
+ foreignId: z.string().nullish(),
14
+ sourceId: z.string().nullish(),
15
+ spaceId: z.string().uuid().nullish(),
16
+ keywords: z.array(z.string()).nullish(),
17
+ mentions,
18
+ attachments: z.array(z.unknown()).nullish(),
19
+ metadata,
20
+ isDraft: z.boolean().nullish(),
21
+ });
22
+ export const updateEntitySchema = z
23
+ .object({
24
+ title: z.string().nullable().optional(),
25
+ content: z.string().nullable().optional(),
26
+ keywords: z.array(z.string()).optional(),
27
+ mentions,
28
+ attachments: z.array(z.unknown()).optional(),
29
+ metadata,
30
+ })
31
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
32
+ export const createCommentSchema = z.object({
33
+ entityId: z.string().uuid(),
34
+ parentId: z.string().uuid().nullish(),
35
+ content: z.string().nullish(),
36
+ gif: z.unknown().nullish(),
37
+ foreignId: z.string().nullish(),
38
+ mentions,
39
+ metadata,
40
+ });
41
+ export const updateCommentSchema = z
42
+ .object({
43
+ content: z.string().nullable().optional(),
44
+ gif: z.unknown().optional(),
45
+ mentions,
46
+ metadata,
47
+ })
48
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
49
+ // The SDK posts `{ reactionType }` to /entities/:id/reactions and /comments/:id/reactions
50
+ // (see @agora-sdk useAddReaction). The field name is part of the contract — match it exactly.
51
+ export const reactionSchema = z.object({
52
+ reactionType: z.enum(REACTION_TYPES),
53
+ });
54
+ // ─── feed ranking ─────────────────────────────────────────────────────────────
55
+ // Per-request numeric overrides for the ranking algorithm (the `rankParams` query scalar). Every
56
+ // field is finite + range-clamped so only safe numbers ever reach a `sql` template (see ranking.ts).
57
+ export const rankParamsSchema = z
58
+ .object({
59
+ halfLifeHours: z.number().finite().min(0.1).max(8760),
60
+ gravity: z.number().finite().min(0.1).max(5),
61
+ z: z.number().finite().min(0).max(10),
62
+ C: z.number().finite().min(0).max(1_000_000),
63
+ m: z.number().finite().min(0).max(1),
64
+ })
65
+ .partial();
66
+ // PATCH body for /settings/feed (admin). defaultAlgorithm is a free string here (membership is
67
+ // enforced in feed-config.ts, which falls back to "hot") to avoid a validation↔ranking import cycle.
68
+ export const feedConfigSchema = z
69
+ .object({
70
+ defaultAlgorithm: z.string().max(40).nullish(),
71
+ decayMode: z.enum(["stored", "query-time"]).nullish(),
72
+ halfLifeHours: z.number().finite().min(0.1).max(8760).nullish(),
73
+ gravity: z.number().finite().min(0.1).max(5).nullish(),
74
+ z: z.number().finite().min(0).max(10).nullish(),
75
+ C: z.number().finite().min(0).max(1_000_000).nullish(),
76
+ m: z.number().finite().min(0).max(1).nullish(),
77
+ reactionWeights: z.record(z.enum(REACTION_TYPES), z.number().finite().min(0).max(100)).nullish(),
78
+ diversity: z.object({ perAuthorCap: z.number().int().min(1).max(50) }).nullish(),
79
+ rerankWebhook: z
80
+ .object({
81
+ url: z.string().url().nullish(),
82
+ secret: z.string().min(1).max(512).nullish(),
83
+ timeoutMs: z.number().int().min(100).max(30_000).nullish(),
84
+ overFetch: z.number().int().min(1).max(50).nullish(),
85
+ })
86
+ .nullish(),
87
+ })
88
+ .partial();
89
+ // ─── stewardship ──────────────────────────────────────────────────────────────
90
+ // Who gets notified about a steward conflict-resolution case (project setting; admin Settings →
91
+ // Stewardship). power-aware (default): complainant every stage, respondent only on content removal;
92
+ // symmetric: both every stage; resolution-only: only at close. See lib/steward-config.ts.
93
+ export const STEWARD_NOTIFY_POLICIES = ["power-aware", "symmetric", "resolution-only"];
94
+ // How mediation channels are run for a case. caucus: per-party private channels only (steward bridges,
95
+ // fully preserves the respondent-anonymity guarantee). hybrid (default): caucus channels PLUS an optional
96
+ // joint room when both parties consent and the case isn't flagged targeting. See lib/mediation.ts.
97
+ export const STEWARD_MEDIATION_MODES = ["caucus", "hybrid"];
98
+ // What happens to a case's mediation channels when the case closes. archive-read-only (default): lock
99
+ // posting, keep history. lock-leave: lock + drop parties (steward keeps read access). leave-open: noop.
100
+ export const STEWARD_MEDIATION_ON_CLOSE = ["archive-read-only", "lock-leave", "leave-open"];
101
+ export const stewardConfigSchema = z.object({
102
+ notifyPolicy: z.enum(STEWARD_NOTIFY_POLICIES),
103
+ mediationMode: z.enum(STEWARD_MEDIATION_MODES),
104
+ mediationOnClose: z.enum(STEWARD_MEDIATION_ON_CLOSE),
105
+ }).partial();
106
+ // ─── users / profiles ────────────────────────────────────────────────────────
107
+ export const updateProfileSchema = z
108
+ .object({
109
+ name: z.string().max(120).nullable().optional(),
110
+ username: z.string().min(1).max(60).nullable().optional(),
111
+ avatar: z.string().url().nullable().optional(),
112
+ bio: z.string().max(300).nullable().optional(),
113
+ metadata,
114
+ })
115
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
116
+ // ─── spaces ────────────────────────────────────────────────────────────────
117
+ const readingPerm = z.enum(["anyone", "members"]);
118
+ const postingPerm = z.enum(["anyone", "members", "admins"]);
119
+ export const createSpaceSchema = z.object({
120
+ name: z.string().min(1).max(120),
121
+ slug: z.string().min(1).max(120).optional(),
122
+ description: z.string().max(2000).optional(),
123
+ readingPermission: readingPerm.optional(),
124
+ postingPermission: postingPerm.optional(),
125
+ requireJoinApproval: z.boolean().optional(),
126
+ parentSpaceId: z.string().uuid().optional(),
127
+ metadata,
128
+ });
129
+ export const updateSpaceSchema = z
130
+ .object({
131
+ name: z.string().min(1).max(120).optional(),
132
+ slug: z.string().min(1).max(120).nullable().optional(),
133
+ description: z.string().max(2000).nullable().optional(),
134
+ readingPermission: readingPerm.optional(),
135
+ postingPermission: postingPerm.optional(),
136
+ requireJoinApproval: z.boolean().optional(),
137
+ parentSpaceId: z.string().uuid().nullable().optional(), // reparent; null = make top-level
138
+ metadata,
139
+ })
140
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
141
+ export const createRuleSchema = z.object({
142
+ title: z.string().min(1).max(200),
143
+ description: z.string().max(2000).optional(),
144
+ order: z.number().int().optional(),
145
+ });
146
+ export const updateRuleSchema = z
147
+ .object({
148
+ title: z.string().min(1).max(200).optional(),
149
+ description: z.string().max(2000).nullable().optional(),
150
+ order: z.number().int().optional(),
151
+ })
152
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
153
+ export const reorderRulesSchema = z.object({
154
+ order: z.array(z.string().uuid()).min(1), // rule ids in desired order
155
+ });
156
+ export const memberRoleSchema = z.object({
157
+ role: z.enum(["admin", "moderator", "member"]),
158
+ });
159
+ export const moderationSchema = z.object({
160
+ status: z.enum(["approved", "removed"]),
161
+ reason: z.string().max(500).optional(),
162
+ });
163
+ // ─── collections ─────────────────────────────────────────────────────────────
164
+ export const createCollectionSchema = z.object({
165
+ name: z.string().min(1).max(120),
166
+ parentId: z.string().uuid().optional(),
167
+ });
168
+ export const addEntitySchema = z.object({
169
+ entityId: z.string().uuid(),
170
+ });
171
+ // ─── reports ─────────────────────────────────────────────────────────────────
172
+ export const createReportSchema = z.object({
173
+ targetType: z.enum(["entity", "comment"]),
174
+ targetId: z.string().uuid(),
175
+ reason: z.string().min(1).max(100),
176
+ details: z.string().max(2000).optional(),
177
+ spaceId: z.string().uuid().optional(),
178
+ });
179
+ // ─── auth ──────────────────────────────────────────────────────────────────
180
+ export const signUpSchema = z.object({
181
+ email: z.string().email(),
182
+ password: z.string().min(8).max(128),
183
+ name: z.string().max(120).optional(),
184
+ username: z.string().min(1).max(60).optional(),
185
+ });
186
+ export const signInSchema = z.object({
187
+ email: z.string().email(),
188
+ password: z.string().min(1),
189
+ });
190
+ export const refreshSchema = z.object({
191
+ refreshToken: z.string().min(1),
192
+ });
193
+ export const signOutSchema = z.object({
194
+ refreshToken: z.string().min(1).optional(),
195
+ });
196
+ export const changePasswordSchema = z.object({
197
+ currentPassword: z.string().min(1),
198
+ newPassword: z.string().min(8).max(128),
199
+ });
200
+ export const emailSchema = z.object({
201
+ email: z.string().email(),
202
+ });
203
+ export const verifyEmailSchema = z.object({
204
+ tokenHash: z.string().min(1),
205
+ type: z.enum(["signup", "email", "recovery"]).optional(),
206
+ });
207
+ export const externalUserSchema = z
208
+ .object({
209
+ // The SDK posts `userJwt`; `token` kept as a legacy alias.
210
+ userJwt: z.string().min(1).optional(),
211
+ token: z.string().min(1).optional(),
212
+ })
213
+ .refine((v) => !!(v.userJwt || v.token), { message: "userJwt is required", path: ["userJwt"] });
214
+ export const signTestingJwtSchema = z.object({
215
+ // Dev-only: the client sends its OWN external-auth private key (PKCS8 PEM) to sign a test JWT.
216
+ privateKey: z.string().min(1),
217
+ userData: z.object({ id: z.union([z.string(), z.number()]) }).passthrough(),
218
+ projectId: z.string().optional(), // SDK includes it; we sign with the path projectId
219
+ });
220
+ export const webhookConfigSchema = z.object({
221
+ url: z.string().url().nullish(), // null clears it
222
+ secret: z.string().min(1).nullish(),
223
+ events: z.array(z.string()).nullish(), // null/absent → unchanged; [] disables all
224
+ });
225
+ // The starting category taxonomy the moderator steers the LLM toward. Seeded into a project's
226
+ // `moderator_config.categories` if none exist, then editable in admin Settings → Agent moderation.
227
+ // The moderator pulls the per-project list (falling back to this) and lists them in its system prompt.
228
+ export const DEFAULT_MODERATION_CATEGORIES = [
229
+ "fake-news",
230
+ "conspiracy",
231
+ "racism",
232
+ "alcohol-promotion",
233
+ "drug-promotion",
234
+ "foul-language",
235
+ "harassment",
236
+ "hate-promotion",
237
+ "sexual",
238
+ "violence-promotion",
239
+ "self-harm",
240
+ "spam",
241
+ "illicit",
242
+ "pii",
243
+ ];
244
+ // The @agora/moderator integration (PATCH /settings/moderator). Groups everything about automated
245
+ // moderation for one project:
246
+ // - the internal notifier the API fans content `*.complete` events to (url + write-only secret) —
247
+ // separate from the project's (external) webhook notifier;
248
+ // - the block/review auto-action thresholds + LLM-provider tuning the moderator overlays on its env defaults;
249
+ // - the per-project moderation category list (`categories`).
250
+ // Every field is nullish: omit to leave unchanged, null to clear (→ the moderator's env default /
251
+ // the seed categories). `secret` and `llmApiKey` are write-only (GET exposes only hasSecret / hasLlmApiKey).
252
+ export const moderatorConfigSchema = z.object({
253
+ url: z.string().url().nullish(),
254
+ secret: z.string().min(1).nullish(),
255
+ blockAutoActionThreshold: z.number().min(0).max(1).nullish(),
256
+ reviewAutoActionThreshold: z.number().min(0).max(1).nullish(),
257
+ llmProvider: z.enum(["openai", "anthropic"]).nullish(),
258
+ llmBaseUrl: z.string().url().nullish(),
259
+ llmApiKey: z.string().min(1).nullish(),
260
+ llmModel: z.string().min(1).nullish(),
261
+ llmMaxTokens: z.number().int().positive().nullish(),
262
+ categories: z.array(z.string().trim().min(1).max(64)).max(100).nullish(),
263
+ });
264
+ // ─── automated moderation (@agora/moderator) ────────────────────────────────
265
+ // Body for the moderator's on-demand POST /moderation/analyze (admin "Re-analyze"). The admin
266
+ // already has the content loaded, so it passes the text directly along with what's being judged.
267
+ export const moderationAnalyzeSchema = z.object({
268
+ targetType: z.enum(["entity", "comment", "message"]),
269
+ targetId: z.string().uuid(),
270
+ spaceId: z.string().uuid().nullish(),
271
+ text: z.string().min(1).max(40000),
272
+ context: z.string().max(40000).optional(), // optional surrounding context (e.g. parent entity)
273
+ });
274
+ export const oauthAuthorizeSchema = z.object({
275
+ provider: z.string().min(1), // e.g. "google", "github", "apple" — passed through to Supabase
276
+ // Where to send the browser after auth completes (default: the SDK sends window.location.href).
277
+ // Not .url() so mobile deep links (myapp://) are allowed.
278
+ redirectAfterAuth: z.string().min(1),
279
+ });
280
+ // ─── chat ──────────────────────────────────────────────────────────────────
281
+ export const createConversationSchema = z.object({
282
+ type: z.enum(["group", "space"]).optional(),
283
+ name: z.string().max(120).optional(),
284
+ description: z.string().max(2000).optional(),
285
+ spaceId: z.string().uuid().optional(),
286
+ memberIds: z.array(z.string().uuid()).optional(),
287
+ postingPermission: z.enum(["members", "admins"]).optional(),
288
+ });
289
+ export const directConversationSchema = z.object({
290
+ userId: z.string().uuid(), // the other participant
291
+ });
292
+ export const updateConversationSchema = z
293
+ .object({
294
+ name: z.string().max(120).nullable().optional(),
295
+ description: z.string().max(2000).nullable().optional(),
296
+ })
297
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
298
+ const messageBody = {
299
+ content: z.string().max(10000).optional(),
300
+ gif: z.unknown().optional(),
301
+ mentions,
302
+ metadata,
303
+ };
304
+ export const sendMessageSchema = z.object({
305
+ ...messageBody,
306
+ parentMessageId: z.string().uuid().optional(),
307
+ quotedMessageId: z.string().uuid().optional(),
308
+ localId: z.string().optional(), // client optimistic-reconciliation token, echoed back, not persisted
309
+ }).refine((v) => v.content || v.gif, { message: "Message needs content or a gif" });
310
+ export const editMessageSchema = z
311
+ .object(messageBody)
312
+ .refine((v) => Object.keys(v).length > 0, { message: "No updatable fields provided" });
313
+ export const messageReactionSchema = z.object({
314
+ emoji: z.string().min(1).max(64),
315
+ });
316
+ export const reportMessageSchema = z.object({
317
+ reason: z.string().min(1).max(100),
318
+ details: z.string().max(2000).optional(),
319
+ });
320
+ export const addConversationMemberSchema = z.object({
321
+ userId: z.string().uuid(),
322
+ role: z.enum(["admin", "member"]).optional(),
323
+ });
324
+ export const convMemberRoleSchema = z.object({
325
+ role: z.enum(["admin", "member"]),
326
+ });
327
+ // ─── connections ─────────────────────────────────────────────────────────────
328
+ export const connectionRequestSchema = z.object({
329
+ message: z.string().max(500).optional(),
330
+ });
@@ -0,0 +1,315 @@
1
+ import { z } from "zod";
2
+ export declare const base64: z.ZodString;
3
+ export declare const epochString: z.ZodString;
4
+ export declare const welcomeSchema: z.ZodObject<{
5
+ targetDeviceId: z.ZodString;
6
+ payload: z.ZodString;
7
+ epoch: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ targetDeviceId: string;
10
+ payload: string;
11
+ epoch: string;
12
+ }, {
13
+ targetDeviceId: string;
14
+ payload: string;
15
+ epoch: string;
16
+ }>;
17
+ export declare const handshakeBlobSchema: z.ZodObject<{
18
+ payload: z.ZodString;
19
+ epoch: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ payload: string;
22
+ epoch: string;
23
+ }, {
24
+ payload: string;
25
+ epoch: string;
26
+ }>;
27
+ export declare const registerDeviceSchema: z.ZodObject<{
28
+ deviceId: z.ZodString;
29
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ signaturePublicKey: z.ZodString;
31
+ credential: z.ZodString;
32
+ ciphersuite: z.ZodNumber;
33
+ }, "strip", z.ZodTypeAny, {
34
+ deviceId: string;
35
+ signaturePublicKey: string;
36
+ credential: string;
37
+ ciphersuite: number;
38
+ displayName?: string | null | undefined;
39
+ }, {
40
+ deviceId: string;
41
+ signaturePublicKey: string;
42
+ credential: string;
43
+ ciphersuite: number;
44
+ displayName?: string | null | undefined;
45
+ }>;
46
+ export declare const publishKeyPackagesSchema: z.ZodObject<{
47
+ keyPackages: z.ZodArray<z.ZodObject<{
48
+ keyPackageRef: z.ZodString;
49
+ keyPackage: z.ZodString;
50
+ ciphersuite: z.ZodNumber;
51
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ ciphersuite: number;
54
+ keyPackageRef: string;
55
+ keyPackage: string;
56
+ expiresAt?: string | null | undefined;
57
+ }, {
58
+ ciphersuite: number;
59
+ keyPackageRef: string;
60
+ keyPackage: string;
61
+ expiresAt?: string | null | undefined;
62
+ }>, "many">;
63
+ }, "strip", z.ZodTypeAny, {
64
+ keyPackages: {
65
+ ciphersuite: number;
66
+ keyPackageRef: string;
67
+ keyPackage: string;
68
+ expiresAt?: string | null | undefined;
69
+ }[];
70
+ }, {
71
+ keyPackages: {
72
+ ciphersuite: number;
73
+ keyPackageRef: string;
74
+ keyPackage: string;
75
+ expiresAt?: string | null | undefined;
76
+ }[];
77
+ }>;
78
+ export declare const createSecureConversationSchema: z.ZodObject<{
79
+ type: z.ZodEnum<["dm", "group", "channel"]>;
80
+ mlsGroupId: z.ZodString;
81
+ spaceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ memberUserIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
84
+ welcomes: z.ZodDefault<z.ZodArray<z.ZodObject<{
85
+ targetDeviceId: z.ZodString;
86
+ payload: z.ZodString;
87
+ epoch: z.ZodString;
88
+ }, "strip", z.ZodTypeAny, {
89
+ targetDeviceId: string;
90
+ payload: string;
91
+ epoch: string;
92
+ }, {
93
+ targetDeviceId: string;
94
+ payload: string;
95
+ epoch: string;
96
+ }>, "many">>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ type: "group" | "dm" | "channel";
99
+ mlsGroupId: string;
100
+ memberUserIds: string[];
101
+ welcomes: {
102
+ targetDeviceId: string;
103
+ payload: string;
104
+ epoch: string;
105
+ }[];
106
+ spaceId?: string | null | undefined;
107
+ name?: string | null | undefined;
108
+ }, {
109
+ type: "group" | "dm" | "channel";
110
+ mlsGroupId: string;
111
+ spaceId?: string | null | undefined;
112
+ name?: string | null | undefined;
113
+ memberUserIds?: string[] | undefined;
114
+ welcomes?: {
115
+ targetDeviceId: string;
116
+ payload: string;
117
+ epoch: string;
118
+ }[] | undefined;
119
+ }>;
120
+ export declare const addSecureMemberSchema: z.ZodObject<{
121
+ userId: z.ZodString;
122
+ commit: z.ZodObject<{
123
+ payload: z.ZodString;
124
+ epoch: z.ZodString;
125
+ }, "strip", z.ZodTypeAny, {
126
+ payload: string;
127
+ epoch: string;
128
+ }, {
129
+ payload: string;
130
+ epoch: string;
131
+ }>;
132
+ welcomes: z.ZodArray<z.ZodObject<{
133
+ targetDeviceId: z.ZodString;
134
+ payload: z.ZodString;
135
+ epoch: z.ZodString;
136
+ }, "strip", z.ZodTypeAny, {
137
+ targetDeviceId: string;
138
+ payload: string;
139
+ epoch: string;
140
+ }, {
141
+ targetDeviceId: string;
142
+ payload: string;
143
+ epoch: string;
144
+ }>, "many">;
145
+ }, "strip", z.ZodTypeAny, {
146
+ userId: string;
147
+ welcomes: {
148
+ targetDeviceId: string;
149
+ payload: string;
150
+ epoch: string;
151
+ }[];
152
+ commit: {
153
+ payload: string;
154
+ epoch: string;
155
+ };
156
+ }, {
157
+ userId: string;
158
+ welcomes: {
159
+ targetDeviceId: string;
160
+ payload: string;
161
+ epoch: string;
162
+ }[];
163
+ commit: {
164
+ payload: string;
165
+ epoch: string;
166
+ };
167
+ }>;
168
+ export declare const removeSecureMemberSchema: z.ZodObject<{
169
+ commit: z.ZodObject<{
170
+ payload: z.ZodString;
171
+ epoch: z.ZodString;
172
+ }, "strip", z.ZodTypeAny, {
173
+ payload: string;
174
+ epoch: string;
175
+ }, {
176
+ payload: string;
177
+ epoch: string;
178
+ }>;
179
+ }, "strip", z.ZodTypeAny, {
180
+ commit: {
181
+ payload: string;
182
+ epoch: string;
183
+ };
184
+ }, {
185
+ commit: {
186
+ payload: string;
187
+ epoch: string;
188
+ };
189
+ }>;
190
+ export declare const sendSecureMessageSchema: z.ZodObject<{
191
+ ciphertext: z.ZodString;
192
+ epoch: z.ZodString;
193
+ senderDeviceId: z.ZodString;
194
+ contentType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
195
+ }, "strip", z.ZodTypeAny, {
196
+ epoch: string;
197
+ ciphertext: string;
198
+ senderDeviceId: string;
199
+ contentType?: string | null | undefined;
200
+ }, {
201
+ epoch: string;
202
+ ciphertext: string;
203
+ senderDeviceId: string;
204
+ contentType?: string | null | undefined;
205
+ }>;
206
+ export declare const uploadKeyBackupSchema: z.ZodObject<{
207
+ deviceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
+ blob: z.ZodString;
209
+ nonce: z.ZodString;
210
+ kdf: z.ZodEnum<["argon2id", "pbkdf2"]>;
211
+ kdfParams: z.ZodRecord<z.ZodString, z.ZodUnknown>;
212
+ cipher: z.ZodEnum<["xchacha20poly1305", "aes-256-gcm"]>;
213
+ version: z.ZodNumber;
214
+ }, "strip", z.ZodTypeAny, {
215
+ blob: string;
216
+ nonce: string;
217
+ kdf: "argon2id" | "pbkdf2";
218
+ kdfParams: Record<string, unknown>;
219
+ cipher: "xchacha20poly1305" | "aes-256-gcm";
220
+ version: number;
221
+ deviceId?: string | null | undefined;
222
+ }, {
223
+ blob: string;
224
+ nonce: string;
225
+ kdf: "argon2id" | "pbkdf2";
226
+ kdfParams: Record<string, unknown>;
227
+ cipher: "xchacha20poly1305" | "aes-256-gcm";
228
+ version: number;
229
+ deviceId?: string | null | undefined;
230
+ }>;
231
+ export interface SecureDeviceModel {
232
+ id: string;
233
+ projectId: string;
234
+ userId: string;
235
+ deviceId: string;
236
+ displayName: string | null;
237
+ signaturePublicKey: string;
238
+ credential: string;
239
+ ciphersuite: number;
240
+ revokedAt: string | null;
241
+ lastSeenAt: string | null;
242
+ createdAt: string;
243
+ updatedAt: string;
244
+ }
245
+ export interface SecureKeyPackageClaim {
246
+ deviceId: string;
247
+ keyPackageRef: string;
248
+ keyPackage: string;
249
+ ciphersuite: number;
250
+ }
251
+ export interface SecureConversationMemberModel {
252
+ id: string;
253
+ projectId: string;
254
+ conversationId: string;
255
+ userId: string;
256
+ role: "admin" | "member";
257
+ isActive: boolean;
258
+ joinedAtEpoch: string | null;
259
+ lastReadAt: string | null;
260
+ leftAt: string | null;
261
+ createdAt: string;
262
+ updatedAt: string;
263
+ }
264
+ export interface SecureConversationModel {
265
+ id: string;
266
+ projectId: string;
267
+ type: "dm" | "group" | "channel";
268
+ mlsGroupId: string;
269
+ spaceId: string | null;
270
+ currentEpoch: string;
271
+ name: string | null;
272
+ createdById: string | null;
273
+ lastMessageAt: string | null;
274
+ memberCount?: number;
275
+ unreadCount?: number;
276
+ currentMember?: SecureConversationMemberModel;
277
+ createdAt: string;
278
+ updatedAt: string;
279
+ }
280
+ export interface SecureMessageModel {
281
+ id: string;
282
+ projectId: string;
283
+ conversationId: string;
284
+ senderUserId: string | null;
285
+ senderDeviceId: string | null;
286
+ epoch: string;
287
+ ciphertext: string;
288
+ contentType: string;
289
+ createdAt: string;
290
+ }
291
+ export interface SecureHandshakeModel {
292
+ id: string;
293
+ seq: string;
294
+ kind: "welcome" | "commit" | "proposal";
295
+ conversationId: string;
296
+ epoch: string;
297
+ payload: string;
298
+ senderDeviceId: string | null;
299
+ targetDeviceId: string | null;
300
+ }
301
+ export interface SecureKeyBackupModel {
302
+ id: string;
303
+ projectId: string;
304
+ userId: string;
305
+ deviceId: string | null;
306
+ blob: string;
307
+ nonce: string;
308
+ kdf: string;
309
+ kdfParams: Record<string, unknown>;
310
+ cipher: string;
311
+ version: number;
312
+ createdAt: string;
313
+ updatedAt: string;
314
+ }
315
+ //# sourceMappingURL=secure-chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-chat.d.ts","sourceRoot":"","sources":["../src/secure-chat.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,MAAM,aAIiC,CAAC;AAGrD,eAAO,MAAM,WAAW,aAA2E,CAAC;AAMpG,eAAO,MAAM,aAAa;;;;;;;;;;;;EAIxB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;EAG9B,CAAC;AAGH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;EAM/B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOzC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIhC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAKlC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAQhC,CAAC;AAGH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAA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