@graygate/bot-sdk 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.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Generated from protocol/src/ws.ts in the graygate monorepo — do not edit by hand.
3
+ * Only the declarations the bot SDK needs are here; the rest of that module stays private.
4
+ */
5
+ import { z } from 'zod';
6
+ export declare const msgNewPayload: z.ZodObject<{
7
+ id: z.ZodString;
8
+ roomId: z.ZodString;
9
+ senderId: z.ZodString;
10
+ keyVersion: z.ZodNumber;
11
+ kind: z.ZodEnum<["text", "media"]>;
12
+ ciphertext: z.ZodObject<{
13
+ ciphertext: z.ZodString;
14
+ iv: z.ZodString;
15
+ mac: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ ciphertext: string;
18
+ iv: string;
19
+ mac: string;
20
+ }, {
21
+ ciphertext: string;
22
+ iv: string;
23
+ mac: string;
24
+ }>;
25
+ mediaId: z.ZodOptional<z.ZodString>;
26
+ createdAt: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ ciphertext: {
29
+ ciphertext: string;
30
+ iv: string;
31
+ mac: string;
32
+ };
33
+ id: string;
34
+ roomId: string;
35
+ senderId: string;
36
+ keyVersion: number;
37
+ kind: "text" | "media";
38
+ createdAt: string;
39
+ mediaId?: string | undefined;
40
+ }, {
41
+ ciphertext: {
42
+ ciphertext: string;
43
+ iv: string;
44
+ mac: string;
45
+ };
46
+ id: string;
47
+ roomId: string;
48
+ senderId: string;
49
+ keyVersion: number;
50
+ kind: "text" | "media";
51
+ createdAt: string;
52
+ mediaId?: string | undefined;
53
+ }>;
54
+ export declare const envelopeNewPayload: z.ZodObject<{
55
+ id: z.ZodString;
56
+ roomId: z.ZodString;
57
+ keyVersion: z.ZodNumber;
58
+ purpose: z.ZodEnum<["invite", "rotation"]>;
59
+ ciphertext: z.ZodString;
60
+ createdBy: z.ZodString;
61
+ }, "strip", z.ZodTypeAny, {
62
+ ciphertext: string;
63
+ id: string;
64
+ roomId: string;
65
+ keyVersion: number;
66
+ purpose: "invite" | "rotation";
67
+ createdBy: string;
68
+ }, {
69
+ ciphertext: string;
70
+ id: string;
71
+ roomId: string;
72
+ keyVersion: number;
73
+ purpose: "invite" | "rotation";
74
+ createdBy: string;
75
+ }>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Generated from protocol/src/ws.ts in the graygate monorepo — do not edit by hand.
4
+ * Only the declarations the bot SDK needs are here; the rest of that module stays private.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.envelopeNewPayload = exports.msgNewPayload = void 0;
8
+ const body_1 = require("./body");
9
+ const zod_1 = require("zod");
10
+ const uuid = zod_1.z.string().uuid();
11
+ exports.msgNewPayload = zod_1.z.object({
12
+ id: uuid,
13
+ roomId: uuid,
14
+ senderId: uuid,
15
+ keyVersion: zod_1.z.number().int().positive(),
16
+ kind: zod_1.z.enum(['text', 'media']),
17
+ ciphertext: body_1.encryptedPayloadSchema,
18
+ mediaId: uuid.optional(),
19
+ createdAt: zod_1.z.string().datetime(),
20
+ });
21
+ exports.envelopeNewPayload = zod_1.z.object({
22
+ id: uuid,
23
+ roomId: uuid,
24
+ keyVersion: zod_1.z.number().int().positive(),
25
+ purpose: zod_1.z.enum(['invite', 'rotation']),
26
+ ciphertext: zod_1.z.string().min(1), // RSA-OAEP base64
27
+ createdBy: uuid,
28
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The wire format the bot speaks — message bodies, webhook items, and the crypto around them.
3
+ * Generated from the graygate monorepo (see scripts/export-public.mjs there); do not edit.
4
+ */
5
+ export * from './constants';
6
+ export * from './body';
7
+ export * from './events';
8
+ export * from './webhook';
9
+ export * from './crypto';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * The wire format the bot speaks — message bodies, webhook items, and the crypto around them.
19
+ * Generated from the graygate monorepo (see scripts/export-public.mjs there); do not edit.
20
+ */
21
+ __exportStar(require("./constants"), exports);
22
+ __exportStar(require("./body"), exports);
23
+ __exportStar(require("./events"), exports);
24
+ __exportStar(require("./webhook"), exports);
25
+ __exportStar(require("./crypto"), exports);
@@ -0,0 +1,569 @@
1
+ /**
2
+ * Generated from protocol/src/rest.ts in the graygate monorepo — do not edit by hand.
3
+ * Only the declarations the bot SDK needs are here; the rest of that module stays private.
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * The webhook body a bot receives. Each item has **the same shape** as the payload the WebSocket
8
+ * pushes to a phone.
9
+ *
10
+ * What leaves is ciphertext, so a webhook delivered to the wrong address leaks the metadata around
11
+ * a message — room id, sender id, timestamp — and not what was said.
12
+ */
13
+ export declare const botWebhookItem: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
14
+ type: z.ZodLiteral<"msg.new">;
15
+ payload: z.ZodObject<{
16
+ id: z.ZodString;
17
+ roomId: z.ZodString;
18
+ senderId: z.ZodString;
19
+ keyVersion: z.ZodNumber;
20
+ kind: z.ZodEnum<["text", "media"]>;
21
+ ciphertext: z.ZodObject<{
22
+ ciphertext: z.ZodString;
23
+ iv: z.ZodString;
24
+ mac: z.ZodString;
25
+ }, "strip", z.ZodTypeAny, {
26
+ ciphertext: string;
27
+ iv: string;
28
+ mac: string;
29
+ }, {
30
+ ciphertext: string;
31
+ iv: string;
32
+ mac: string;
33
+ }>;
34
+ mediaId: z.ZodOptional<z.ZodString>;
35
+ createdAt: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ ciphertext: {
38
+ ciphertext: string;
39
+ iv: string;
40
+ mac: string;
41
+ };
42
+ id: string;
43
+ roomId: string;
44
+ senderId: string;
45
+ keyVersion: number;
46
+ kind: "text" | "media";
47
+ createdAt: string;
48
+ mediaId?: string | undefined;
49
+ }, {
50
+ ciphertext: {
51
+ ciphertext: string;
52
+ iv: string;
53
+ mac: string;
54
+ };
55
+ id: string;
56
+ roomId: string;
57
+ senderId: string;
58
+ keyVersion: number;
59
+ kind: "text" | "media";
60
+ createdAt: string;
61
+ mediaId?: string | undefined;
62
+ }>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ type: "msg.new";
65
+ payload: {
66
+ ciphertext: {
67
+ ciphertext: string;
68
+ iv: string;
69
+ mac: string;
70
+ };
71
+ id: string;
72
+ roomId: string;
73
+ senderId: string;
74
+ keyVersion: number;
75
+ kind: "text" | "media";
76
+ createdAt: string;
77
+ mediaId?: string | undefined;
78
+ };
79
+ }, {
80
+ type: "msg.new";
81
+ payload: {
82
+ ciphertext: {
83
+ ciphertext: string;
84
+ iv: string;
85
+ mac: string;
86
+ };
87
+ id: string;
88
+ roomId: string;
89
+ senderId: string;
90
+ keyVersion: number;
91
+ kind: "text" | "media";
92
+ createdAt: string;
93
+ mediaId?: string | undefined;
94
+ };
95
+ }>, z.ZodObject<{
96
+ type: z.ZodLiteral<"envelope.new">;
97
+ payload: z.ZodObject<{
98
+ id: z.ZodString;
99
+ roomId: z.ZodString;
100
+ keyVersion: z.ZodNumber;
101
+ purpose: z.ZodEnum<["invite", "rotation"]>;
102
+ ciphertext: z.ZodString;
103
+ createdBy: z.ZodString;
104
+ }, "strip", z.ZodTypeAny, {
105
+ ciphertext: string;
106
+ id: string;
107
+ roomId: string;
108
+ keyVersion: number;
109
+ purpose: "invite" | "rotation";
110
+ createdBy: string;
111
+ }, {
112
+ ciphertext: string;
113
+ id: string;
114
+ roomId: string;
115
+ keyVersion: number;
116
+ purpose: "invite" | "rotation";
117
+ createdBy: string;
118
+ }>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ type: "envelope.new";
121
+ payload: {
122
+ ciphertext: string;
123
+ id: string;
124
+ roomId: string;
125
+ keyVersion: number;
126
+ purpose: "invite" | "rotation";
127
+ createdBy: string;
128
+ };
129
+ }, {
130
+ type: "envelope.new";
131
+ payload: {
132
+ ciphertext: string;
133
+ id: string;
134
+ roomId: string;
135
+ keyVersion: number;
136
+ purpose: "invite" | "rotation";
137
+ createdBy: string;
138
+ };
139
+ }>, z.ZodObject<{
140
+ type: z.ZodLiteral<"member.joined">;
141
+ payload: z.ZodObject<{
142
+ roomId: z.ZodString;
143
+ userId: z.ZodString;
144
+ }, "strip", z.ZodTypeAny, {
145
+ roomId: string;
146
+ userId: string;
147
+ }, {
148
+ roomId: string;
149
+ userId: string;
150
+ }>;
151
+ }, "strip", z.ZodTypeAny, {
152
+ type: "member.joined";
153
+ payload: {
154
+ roomId: string;
155
+ userId: string;
156
+ };
157
+ }, {
158
+ type: "member.joined";
159
+ payload: {
160
+ roomId: string;
161
+ userId: string;
162
+ };
163
+ }>, z.ZodObject<{
164
+ type: z.ZodLiteral<"member.left">;
165
+ payload: z.ZodObject<{
166
+ roomId: z.ZodString;
167
+ userId: z.ZodString;
168
+ }, "strip", z.ZodTypeAny, {
169
+ roomId: string;
170
+ userId: string;
171
+ }, {
172
+ roomId: string;
173
+ userId: string;
174
+ }>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ type: "member.left";
177
+ payload: {
178
+ roomId: string;
179
+ userId: string;
180
+ };
181
+ }, {
182
+ type: "member.left";
183
+ payload: {
184
+ roomId: string;
185
+ userId: string;
186
+ };
187
+ }>, z.ZodObject<{
188
+ type: z.ZodLiteral<"member.key_changed">;
189
+ payload: z.ZodObject<{
190
+ roomId: z.ZodString;
191
+ userId: z.ZodString;
192
+ keyUpdatedAt: z.ZodString;
193
+ }, "strip", z.ZodTypeAny, {
194
+ roomId: string;
195
+ userId: string;
196
+ keyUpdatedAt: string;
197
+ }, {
198
+ roomId: string;
199
+ userId: string;
200
+ keyUpdatedAt: string;
201
+ }>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ type: "member.key_changed";
204
+ payload: {
205
+ roomId: string;
206
+ userId: string;
207
+ keyUpdatedAt: string;
208
+ };
209
+ }, {
210
+ type: "member.key_changed";
211
+ payload: {
212
+ roomId: string;
213
+ userId: string;
214
+ keyUpdatedAt: string;
215
+ };
216
+ }>, z.ZodObject<{
217
+ type: z.ZodLiteral<"room.deleted">;
218
+ payload: z.ZodObject<{
219
+ roomId: z.ZodString;
220
+ }, "strip", z.ZodTypeAny, {
221
+ roomId: string;
222
+ }, {
223
+ roomId: string;
224
+ }>;
225
+ }, "strip", z.ZodTypeAny, {
226
+ type: "room.deleted";
227
+ payload: {
228
+ roomId: string;
229
+ };
230
+ }, {
231
+ type: "room.deleted";
232
+ payload: {
233
+ roomId: string;
234
+ };
235
+ }>]>;
236
+ export type BotWebhookItem = z.infer<typeof botWebhookItem>;
237
+ export declare const botWebhookBody: z.ZodObject<{
238
+ botId: z.ZodString;
239
+ items: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
240
+ type: z.ZodLiteral<"msg.new">;
241
+ payload: z.ZodObject<{
242
+ id: z.ZodString;
243
+ roomId: z.ZodString;
244
+ senderId: z.ZodString;
245
+ keyVersion: z.ZodNumber;
246
+ kind: z.ZodEnum<["text", "media"]>;
247
+ ciphertext: z.ZodObject<{
248
+ ciphertext: z.ZodString;
249
+ iv: z.ZodString;
250
+ mac: z.ZodString;
251
+ }, "strip", z.ZodTypeAny, {
252
+ ciphertext: string;
253
+ iv: string;
254
+ mac: string;
255
+ }, {
256
+ ciphertext: string;
257
+ iv: string;
258
+ mac: string;
259
+ }>;
260
+ mediaId: z.ZodOptional<z.ZodString>;
261
+ createdAt: z.ZodString;
262
+ }, "strip", z.ZodTypeAny, {
263
+ ciphertext: {
264
+ ciphertext: string;
265
+ iv: string;
266
+ mac: string;
267
+ };
268
+ id: string;
269
+ roomId: string;
270
+ senderId: string;
271
+ keyVersion: number;
272
+ kind: "text" | "media";
273
+ createdAt: string;
274
+ mediaId?: string | undefined;
275
+ }, {
276
+ ciphertext: {
277
+ ciphertext: string;
278
+ iv: string;
279
+ mac: string;
280
+ };
281
+ id: string;
282
+ roomId: string;
283
+ senderId: string;
284
+ keyVersion: number;
285
+ kind: "text" | "media";
286
+ createdAt: string;
287
+ mediaId?: string | undefined;
288
+ }>;
289
+ }, "strip", z.ZodTypeAny, {
290
+ type: "msg.new";
291
+ payload: {
292
+ ciphertext: {
293
+ ciphertext: string;
294
+ iv: string;
295
+ mac: string;
296
+ };
297
+ id: string;
298
+ roomId: string;
299
+ senderId: string;
300
+ keyVersion: number;
301
+ kind: "text" | "media";
302
+ createdAt: string;
303
+ mediaId?: string | undefined;
304
+ };
305
+ }, {
306
+ type: "msg.new";
307
+ payload: {
308
+ ciphertext: {
309
+ ciphertext: string;
310
+ iv: string;
311
+ mac: string;
312
+ };
313
+ id: string;
314
+ roomId: string;
315
+ senderId: string;
316
+ keyVersion: number;
317
+ kind: "text" | "media";
318
+ createdAt: string;
319
+ mediaId?: string | undefined;
320
+ };
321
+ }>, z.ZodObject<{
322
+ type: z.ZodLiteral<"envelope.new">;
323
+ payload: z.ZodObject<{
324
+ id: z.ZodString;
325
+ roomId: z.ZodString;
326
+ keyVersion: z.ZodNumber;
327
+ purpose: z.ZodEnum<["invite", "rotation"]>;
328
+ ciphertext: z.ZodString;
329
+ createdBy: z.ZodString;
330
+ }, "strip", z.ZodTypeAny, {
331
+ ciphertext: string;
332
+ id: string;
333
+ roomId: string;
334
+ keyVersion: number;
335
+ purpose: "invite" | "rotation";
336
+ createdBy: string;
337
+ }, {
338
+ ciphertext: string;
339
+ id: string;
340
+ roomId: string;
341
+ keyVersion: number;
342
+ purpose: "invite" | "rotation";
343
+ createdBy: string;
344
+ }>;
345
+ }, "strip", z.ZodTypeAny, {
346
+ type: "envelope.new";
347
+ payload: {
348
+ ciphertext: string;
349
+ id: string;
350
+ roomId: string;
351
+ keyVersion: number;
352
+ purpose: "invite" | "rotation";
353
+ createdBy: string;
354
+ };
355
+ }, {
356
+ type: "envelope.new";
357
+ payload: {
358
+ ciphertext: string;
359
+ id: string;
360
+ roomId: string;
361
+ keyVersion: number;
362
+ purpose: "invite" | "rotation";
363
+ createdBy: string;
364
+ };
365
+ }>, z.ZodObject<{
366
+ type: z.ZodLiteral<"member.joined">;
367
+ payload: z.ZodObject<{
368
+ roomId: z.ZodString;
369
+ userId: z.ZodString;
370
+ }, "strip", z.ZodTypeAny, {
371
+ roomId: string;
372
+ userId: string;
373
+ }, {
374
+ roomId: string;
375
+ userId: string;
376
+ }>;
377
+ }, "strip", z.ZodTypeAny, {
378
+ type: "member.joined";
379
+ payload: {
380
+ roomId: string;
381
+ userId: string;
382
+ };
383
+ }, {
384
+ type: "member.joined";
385
+ payload: {
386
+ roomId: string;
387
+ userId: string;
388
+ };
389
+ }>, z.ZodObject<{
390
+ type: z.ZodLiteral<"member.left">;
391
+ payload: z.ZodObject<{
392
+ roomId: z.ZodString;
393
+ userId: z.ZodString;
394
+ }, "strip", z.ZodTypeAny, {
395
+ roomId: string;
396
+ userId: string;
397
+ }, {
398
+ roomId: string;
399
+ userId: string;
400
+ }>;
401
+ }, "strip", z.ZodTypeAny, {
402
+ type: "member.left";
403
+ payload: {
404
+ roomId: string;
405
+ userId: string;
406
+ };
407
+ }, {
408
+ type: "member.left";
409
+ payload: {
410
+ roomId: string;
411
+ userId: string;
412
+ };
413
+ }>, z.ZodObject<{
414
+ type: z.ZodLiteral<"member.key_changed">;
415
+ payload: z.ZodObject<{
416
+ roomId: z.ZodString;
417
+ userId: z.ZodString;
418
+ keyUpdatedAt: z.ZodString;
419
+ }, "strip", z.ZodTypeAny, {
420
+ roomId: string;
421
+ userId: string;
422
+ keyUpdatedAt: string;
423
+ }, {
424
+ roomId: string;
425
+ userId: string;
426
+ keyUpdatedAt: string;
427
+ }>;
428
+ }, "strip", z.ZodTypeAny, {
429
+ type: "member.key_changed";
430
+ payload: {
431
+ roomId: string;
432
+ userId: string;
433
+ keyUpdatedAt: string;
434
+ };
435
+ }, {
436
+ type: "member.key_changed";
437
+ payload: {
438
+ roomId: string;
439
+ userId: string;
440
+ keyUpdatedAt: string;
441
+ };
442
+ }>, z.ZodObject<{
443
+ type: z.ZodLiteral<"room.deleted">;
444
+ payload: z.ZodObject<{
445
+ roomId: z.ZodString;
446
+ }, "strip", z.ZodTypeAny, {
447
+ roomId: string;
448
+ }, {
449
+ roomId: string;
450
+ }>;
451
+ }, "strip", z.ZodTypeAny, {
452
+ type: "room.deleted";
453
+ payload: {
454
+ roomId: string;
455
+ };
456
+ }, {
457
+ type: "room.deleted";
458
+ payload: {
459
+ roomId: string;
460
+ };
461
+ }>]>, "many">;
462
+ }, "strip", z.ZodTypeAny, {
463
+ botId: string;
464
+ items: ({
465
+ type: "msg.new";
466
+ payload: {
467
+ ciphertext: {
468
+ ciphertext: string;
469
+ iv: string;
470
+ mac: string;
471
+ };
472
+ id: string;
473
+ roomId: string;
474
+ senderId: string;
475
+ keyVersion: number;
476
+ kind: "text" | "media";
477
+ createdAt: string;
478
+ mediaId?: string | undefined;
479
+ };
480
+ } | {
481
+ type: "envelope.new";
482
+ payload: {
483
+ ciphertext: string;
484
+ id: string;
485
+ roomId: string;
486
+ keyVersion: number;
487
+ purpose: "invite" | "rotation";
488
+ createdBy: string;
489
+ };
490
+ } | {
491
+ type: "member.joined";
492
+ payload: {
493
+ roomId: string;
494
+ userId: string;
495
+ };
496
+ } | {
497
+ type: "member.left";
498
+ payload: {
499
+ roomId: string;
500
+ userId: string;
501
+ };
502
+ } | {
503
+ type: "member.key_changed";
504
+ payload: {
505
+ roomId: string;
506
+ userId: string;
507
+ keyUpdatedAt: string;
508
+ };
509
+ } | {
510
+ type: "room.deleted";
511
+ payload: {
512
+ roomId: string;
513
+ };
514
+ })[];
515
+ }, {
516
+ botId: string;
517
+ items: ({
518
+ type: "msg.new";
519
+ payload: {
520
+ ciphertext: {
521
+ ciphertext: string;
522
+ iv: string;
523
+ mac: string;
524
+ };
525
+ id: string;
526
+ roomId: string;
527
+ senderId: string;
528
+ keyVersion: number;
529
+ kind: "text" | "media";
530
+ createdAt: string;
531
+ mediaId?: string | undefined;
532
+ };
533
+ } | {
534
+ type: "envelope.new";
535
+ payload: {
536
+ ciphertext: string;
537
+ id: string;
538
+ roomId: string;
539
+ keyVersion: number;
540
+ purpose: "invite" | "rotation";
541
+ createdBy: string;
542
+ };
543
+ } | {
544
+ type: "member.joined";
545
+ payload: {
546
+ roomId: string;
547
+ userId: string;
548
+ };
549
+ } | {
550
+ type: "member.left";
551
+ payload: {
552
+ roomId: string;
553
+ userId: string;
554
+ };
555
+ } | {
556
+ type: "member.key_changed";
557
+ payload: {
558
+ roomId: string;
559
+ userId: string;
560
+ keyUpdatedAt: string;
561
+ };
562
+ } | {
563
+ type: "room.deleted";
564
+ payload: {
565
+ roomId: string;
566
+ };
567
+ })[];
568
+ }>;
569
+ export type BotWebhookBody = z.infer<typeof botWebhookBody>;