@casual-simulation/aux-records 3.2.18 → 3.2.19

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.
@@ -1,4 +1,3 @@
1
- import { KnownErrorCodes } from './Utils';
2
1
  import { AuthController } from './AuthController';
3
2
  import { LivekitController } from './LivekitController';
4
3
  import { RecordsController } from './RecordsController';
@@ -8,10 +7,11 @@ import { FileRecordsController } from './FileRecordsController';
8
7
  import { SubscriptionController } from './SubscriptionController';
9
8
  import { z } from 'zod';
10
9
  import { RateLimitController } from './RateLimitController';
10
+ import { Procedure, ProcedureOutput } from '@casual-simulation/aux-common';
11
11
  import { PolicyController } from './PolicyController';
12
12
  import { AIController } from './AIController';
13
13
  import { WebsocketController } from './websockets/WebsocketController';
14
- import { GenericHttpRequest, GenericHttpResponse, GenericWebsocketRequest } from '@casual-simulation/aux-common';
14
+ import { GenericHttpRequest, GenericHttpResponse, GenericWebsocketRequest, KnownErrorCodes } from '@casual-simulation/aux-common';
15
15
  import { ModerationController } from './ModerationController';
16
16
  export declare const NOT_LOGGED_IN_RESULT: {
17
17
  success: false;
@@ -19,7 +19,7 @@ export declare const NOT_LOGGED_IN_RESULT: {
19
19
  errorMessage: "The user is not logged in. A session key must be provided for this operation.";
20
20
  };
21
21
  export declare const UNACCEPTABLE_SESSION_KEY: {
22
- success: boolean;
22
+ success: false;
23
23
  errorCode: "unacceptable_session_key";
24
24
  errorMessage: string;
25
25
  };
@@ -29,37 +29,37 @@ export declare const UNACCEPTABLE_USER_ID: {
29
29
  errorMessage: string;
30
30
  };
31
31
  export declare const INVALID_ORIGIN_RESULT: {
32
- success: boolean;
32
+ success: false;
33
33
  errorCode: "invalid_origin";
34
34
  errorMessage: string;
35
35
  };
36
36
  export declare const OPERATION_NOT_FOUND_RESULT: {
37
- success: boolean;
37
+ success: false;
38
38
  errorCode: "operation_not_found";
39
39
  errorMessage: string;
40
40
  };
41
41
  export declare const UNACCEPTABLE_REQUEST_RESULT_MUST_BE_JSON: {
42
- success: boolean;
42
+ success: false;
43
43
  errorCode: "unacceptable_request";
44
44
  errorMessage: string;
45
45
  };
46
46
  export declare const SUBSCRIPTIONS_NOT_SUPPORTED_RESULT: {
47
- success: boolean;
47
+ success: false;
48
48
  errorCode: "not_supported";
49
49
  errorMessage: string;
50
50
  };
51
51
  export declare const AI_NOT_SUPPORTED_RESULT: {
52
- success: boolean;
52
+ success: false;
53
53
  errorCode: "not_supported";
54
54
  errorMessage: string;
55
55
  };
56
56
  export declare const INSTS_NOT_SUPPORTED_RESULT: {
57
- success: boolean;
57
+ success: false;
58
58
  errorCode: "not_supported";
59
59
  errorMessage: string;
60
60
  };
61
61
  export declare const MODERATION_NOT_SUPPORTED_RESULT: {
62
- success: boolean;
62
+ success: false;
63
63
  errorCode: "not_supported";
64
64
  errorMessage: string;
65
65
  };
@@ -91,16 +91,22 @@ export declare const DISPLAY_NAME_VALIDATION: z.ZodString;
91
91
  export declare const NAME_VALIDATION: z.ZodString;
92
92
  export declare const RECORD_NAME_VALIDATION: z.ZodString;
93
93
  export declare const INSTANCE_VALIDATION: z.ZodString;
94
- export declare const INSTANCES_ARRAY_VALIDATION: z.ZodArray<z.ZodString, "many">;
94
+ export declare const INSTANCES_ARRAY_VALIDATION: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], unknown>;
95
95
  export declare const INSTANCES_QUERY_VALIDATION: z.ZodEffects<z.ZodString, string[], string>;
96
96
  /**
97
97
  * Defines a basic interface for an HTTP route.
98
98
  */
99
- export interface Route {
99
+ export interface Route<T> {
100
100
  /**
101
101
  * The path that the route must match.
102
102
  */
103
103
  path: string;
104
+ /**
105
+ * The schema that should be used for the route.
106
+ * If the method can contain a request body, then the schema applies to the body.
107
+ * Otherwise, it will apply to the query parameters.
108
+ */
109
+ schema?: z.ZodType<T, z.ZodTypeDef, any>;
104
110
  /**
105
111
  * The method for the route.
106
112
  */
@@ -108,8 +114,17 @@ export interface Route {
108
114
  /**
109
115
  * The handler that should be called when the route is matched.
110
116
  * @param request The request.
117
+ * @param data The data that was parsed from the request.
111
118
  */
112
- handler: (request: GenericHttpRequest) => Promise<GenericHttpResponse>;
119
+ handler: (request: GenericHttpRequest, data?: T) => Promise<GenericHttpResponse>;
120
+ /**
121
+ * The set of origins that are allowed for the route.
122
+ * If true, then all origins are allowed.
123
+ * If 'account', then only the configured account origins are allowed.
124
+ * If 'api', then only the configured API origins are allowed.
125
+ * If omitted, then it is up to the handler to determine if the origin is allowed.
126
+ */
127
+ allowedOrigins?: Set<string> | true | 'account' | 'api';
113
128
  }
114
129
  /**
115
130
  * Defines a class that represents a generic HTTP server suitable for Records HTTP Requests.
@@ -141,6 +156,7 @@ export declare class RecordsServer {
141
156
  * The map of paths to routes that they match.
142
157
  */
143
158
  private _routes;
159
+ private _procedures;
144
160
  /**
145
161
  * The set of origins that are allowed for account management requests.
146
162
  */
@@ -149,11 +165,724 @@ export declare class RecordsServer {
149
165
  * The set of origins that are allowed for API requests.
150
166
  */
151
167
  get allowedApiOrigins(): Set<string>;
168
+ /**
169
+ * The set of procedures that the server has.
170
+ */
171
+ get procedures(): {
172
+ isEmailValid: Procedure<{
173
+ email?: string;
174
+ }, import("./AuthController").IsValidEmailAddressResult>;
175
+ isDisplayNameValid: Procedure<{
176
+ displayName?: string;
177
+ name?: string;
178
+ }, import("./AuthController").IsValidDisplayNameResult>;
179
+ listSessions: Procedure<{
180
+ expireTimeMs?: number;
181
+ }, import("./AuthController").ListSessionsResult | {
182
+ success: false;
183
+ errorCode: "not_logged_in";
184
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
185
+ }>;
186
+ replaceSession: Procedure<void, import("./AuthController").ReplaceSessionResult | {
187
+ success: false;
188
+ errorCode: "not_logged_in";
189
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
190
+ }>;
191
+ revokeAllSessions: Procedure<{
192
+ userId?: string;
193
+ }, import("./AuthController").RevokeAllSessionsResult | {
194
+ success: false;
195
+ errorCode: "not_logged_in";
196
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
197
+ }>;
198
+ revokeSession: Procedure<{
199
+ userId?: string;
200
+ sessionId?: string;
201
+ sessionKey?: string;
202
+ }, import("./AuthController").RevokeSessionResult | {
203
+ success: false;
204
+ errorCode: "not_logged_in";
205
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
206
+ }>;
207
+ completeLogin: Procedure<{
208
+ userId?: string;
209
+ requestId?: string;
210
+ code?: string;
211
+ }, import("./AuthController").CompleteLoginResult>;
212
+ requestLogin: Procedure<{
213
+ address?: string;
214
+ addressType?: "email" | "phone";
215
+ }, import("./AuthController").LoginRequestResult>;
216
+ requestPrivoLogin: Procedure<{}, import("./AuthController").OpenIDLoginRequestResult>;
217
+ processOAuthCode: Procedure<{
218
+ code?: string;
219
+ state?: string;
220
+ }, import("./AuthController").ProcessOpenIDAuthorizationCodeResult>;
221
+ completeOAuthLogin: Procedure<{
222
+ requestId?: string;
223
+ }, import("./AuthController").CompleteOpenIDLoginResult>;
224
+ requestPrivoSignUp: Procedure<{
225
+ email?: string;
226
+ parentEmail?: string;
227
+ name?: string;
228
+ dateOfBirth?: Date;
229
+ displayName?: string;
230
+ }, import("./AuthController").PrivoSignUpRequestResult>;
231
+ getWebAuthnRegistrationOptions: Procedure<void, import("./AuthController").RequestWebAuthnRegistrationResult | import("./AuthController").ValidateSessionKeyFailure>;
232
+ registerWebAuthn: Procedure<{
233
+ response?: {
234
+ id?: string;
235
+ rawId?: string;
236
+ response?: {
237
+ clientDataJSON?: string;
238
+ attestationObject?: string;
239
+ authenticatorData?: string;
240
+ transports?: string[];
241
+ publicKeyAlgorithm?: number;
242
+ publicKey?: string;
243
+ };
244
+ authenticatorAttachment?: "cross-platform" | "platform";
245
+ clientExtensionResults?: {
246
+ appid?: boolean;
247
+ credProps?: {
248
+ rk?: boolean;
249
+ };
250
+ hmacCreateSecret?: boolean;
251
+ };
252
+ type?: "public-key";
253
+ };
254
+ }, import("./AuthController").CompleteWebAuthnRegistrationResult | import("./AuthController").ValidateSessionKeyFailure>;
255
+ getWebAuthnLoginOptions: Procedure<void, import("./AuthController").RequestWebAuthnLoginResult>;
256
+ completeWebAuthnLogin: Procedure<{
257
+ requestId?: string;
258
+ response?: {
259
+ id?: string;
260
+ rawId?: string;
261
+ response?: {
262
+ clientDataJSON?: string;
263
+ authenticatorData?: string;
264
+ signature?: string;
265
+ userHandle?: string;
266
+ };
267
+ authenticatorAttachment?: "cross-platform" | "platform";
268
+ clientExtensionResults?: {
269
+ appid?: boolean;
270
+ credProps?: {
271
+ rk?: boolean;
272
+ };
273
+ hmacCreateSecret?: boolean;
274
+ };
275
+ type?: "public-key";
276
+ };
277
+ }, import("./AuthController").CompleteWebAuthnLoginResult>;
278
+ listUserAuthenticators: Procedure<void, import("./AuthController").ListUserAuthenticatorsResult | import("./AuthController").ValidateSessionKeyFailure>;
279
+ deleteUserAuthenticator: Procedure<{
280
+ authenticatorId?: string;
281
+ }, import("./AuthController").DeleteUserAuthenticatorResult | import("./AuthController").ValidateSessionKeyFailure>;
282
+ createMeetToken: Procedure<{
283
+ roomName?: string;
284
+ userName?: string;
285
+ }, import("./LivekitEvents").IssueMeetTokenResult>;
286
+ createRecord: Procedure<{
287
+ recordName?: string;
288
+ ownerId?: string;
289
+ studioId?: string;
290
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").CreateRecordResult>;
291
+ addEventCount: Procedure<{
292
+ recordKey?: string;
293
+ eventName?: string;
294
+ count?: number;
295
+ instances?: string[];
296
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./EventRecordsController").AddCountResult>;
297
+ getEventCount: Procedure<{
298
+ recordName?: string;
299
+ eventName?: string;
300
+ instances?: string[];
301
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./EventRecordsController").GetCountResult>;
302
+ listEvents: Procedure<{
303
+ recordName?: string;
304
+ eventName?: string;
305
+ instances?: string[];
306
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./EventRecordsController").ListEventsResult>;
307
+ updateEvent: Procedure<{
308
+ recordKey?: string;
309
+ eventName?: string;
310
+ count?: number;
311
+ markers?: [string, ...string[]];
312
+ instances?: string[];
313
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./EventRecordsController").UpdateEventRecordResult>;
314
+ deleteManualData: Procedure<{
315
+ recordKey?: string;
316
+ address?: string;
317
+ instances?: string[];
318
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").EraseDataSuccess | import("./DataRecordsController").EraseDataFailure | {
319
+ readonly success: false;
320
+ readonly errorCode: "unacceptable_request";
321
+ readonly errorMessage: "recordKey is required and must be a string.";
322
+ } | {
323
+ readonly success: false;
324
+ readonly errorCode: "unacceptable_request";
325
+ readonly errorMessage: "address is required and must be a string.";
326
+ }>;
327
+ getManualData: Procedure<{
328
+ recordName?: string;
329
+ address?: string;
330
+ instances?: string[];
331
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").GetDataSuccess | import("./DataRecordsController").GetDataFailure | {
332
+ readonly success: false;
333
+ readonly errorCode: "unacceptable_request";
334
+ readonly errorMessage: "recordName is required and must be a string.";
335
+ } | {
336
+ readonly success: false;
337
+ readonly errorCode: "unacceptable_request";
338
+ readonly errorMessage: "address is required and must be a string.";
339
+ }>;
340
+ recordManualData: Procedure<{
341
+ recordKey?: string;
342
+ address?: string;
343
+ data?: any;
344
+ updatePolicy?: true | string[];
345
+ deletePolicy?: true | string[];
346
+ markers?: [string, ...string[]];
347
+ instances?: string[];
348
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").RecordDataSuccess | import("./DataRecordsController").RecordDataFailure | {
349
+ readonly success: false;
350
+ readonly errorCode: "unacceptable_request";
351
+ readonly errorMessage: "recordKey is required and must be a string.";
352
+ } | {
353
+ readonly success: false;
354
+ readonly errorCode: "unacceptable_request";
355
+ readonly errorMessage: "address is required and must be a string.";
356
+ } | {
357
+ readonly success: false;
358
+ readonly errorCode: "unacceptable_request";
359
+ readonly errorMessage: "data is required.";
360
+ }>;
361
+ getFile: Procedure<{
362
+ recordName?: string;
363
+ fileName?: string;
364
+ fileUrl?: string;
365
+ instances?: string[];
366
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./FileRecordsStore").GetFileNameFromUrlFailure | import("./FileRecordsController").ReadFileSuccess | import("./FileRecordsController").ReadFileFailure | {
367
+ readonly success: false;
368
+ readonly errorCode: "unacceptable_request";
369
+ readonly errorMessage: string;
370
+ }>;
371
+ listFiles: Procedure<{
372
+ recordName?: string;
373
+ fileName?: string;
374
+ instances?: string[];
375
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./FileRecordsController").ListFilesSuccess | import("./FileRecordsController").ListFilesFailure | {
376
+ readonly success: false;
377
+ readonly errorCode: "unacceptable_request";
378
+ readonly errorMessage: "recordName must be a string.";
379
+ } | {
380
+ readonly success: false;
381
+ readonly errorCode: "unacceptable_request";
382
+ readonly errorMessage: "fileName must be a string.";
383
+ }>;
384
+ eraseFile: Procedure<{
385
+ recordKey?: string;
386
+ fileUrl?: string;
387
+ instances?: string[];
388
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./FileRecordsStore").GetFileNameFromUrlSuccess | import("./FileRecordsStore").GetFileNameFromUrlFailure | import("./FileRecordsController").EraseFileFailure | {
389
+ readonly success: false;
390
+ readonly errorCode: "unacceptable_request";
391
+ readonly errorMessage: "recordKey is required and must be a string.";
392
+ } | {
393
+ readonly success: false;
394
+ readonly errorCode: "unacceptable_request";
395
+ readonly errorMessage: "fileUrl is required and must be a string.";
396
+ }>;
397
+ recordFile: Procedure<{
398
+ recordKey?: string;
399
+ fileSha256Hex?: string;
400
+ fileByteLength?: number;
401
+ fileMimeType?: string;
402
+ fileDescription?: string;
403
+ markers?: [string, ...string[]];
404
+ instances?: string[];
405
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./FileRecordsController").RecordFileSuccess | import("./FileRecordsController").RecordFileFailure | {
406
+ readonly success: false;
407
+ readonly errorCode: "unacceptable_request";
408
+ readonly errorMessage: "recordKey is required and must be a string.";
409
+ } | {
410
+ readonly success: false;
411
+ readonly errorCode: "unacceptable_request";
412
+ readonly errorMessage: "fileSha256Hex is required and must be a string.";
413
+ } | {
414
+ readonly success: false;
415
+ readonly errorCode: "unacceptable_request";
416
+ readonly errorMessage: "fileByteLength is required and must be a number.";
417
+ } | {
418
+ readonly success: false;
419
+ readonly errorCode: "unacceptable_request";
420
+ readonly errorMessage: "fileMimeType is required and must be a string.";
421
+ } | {
422
+ readonly success: false;
423
+ readonly errorCode: "unacceptable_request";
424
+ readonly errorMessage: "fileDescription must be a string.";
425
+ }>;
426
+ updateFile: Procedure<{
427
+ recordKey?: string;
428
+ fileUrl?: string;
429
+ markers?: [string, ...string[]];
430
+ instances?: string[];
431
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./FileRecordsStore").GetFileNameFromUrlFailure | import("./FileRecordsController").UpdateFileRecordSuccess | import("./FileRecordsController").UpdateFileRecordFailure>;
432
+ eraseData: Procedure<{
433
+ recordKey?: string;
434
+ address?: string;
435
+ instances?: string[];
436
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").EraseDataSuccess | import("./DataRecordsController").EraseDataFailure | {
437
+ readonly success: false;
438
+ readonly errorCode: "unacceptable_request";
439
+ readonly errorMessage: "recordKey is required and must be a string.";
440
+ } | {
441
+ readonly success: false;
442
+ readonly errorCode: "unacceptable_request";
443
+ readonly errorMessage: "address is required and must be a string.";
444
+ }>;
445
+ getData: Procedure<{
446
+ recordName?: string;
447
+ address?: string;
448
+ instances?: string[];
449
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").GetDataSuccess | import("./DataRecordsController").GetDataFailure | {
450
+ readonly success: false;
451
+ readonly errorCode: "unacceptable_request";
452
+ readonly errorMessage: "recordName is required and must be a string.";
453
+ } | {
454
+ readonly success: false;
455
+ readonly errorCode: "unacceptable_request";
456
+ readonly errorMessage: "address is required and must be a string.";
457
+ }>;
458
+ listData: Procedure<{
459
+ recordName?: string;
460
+ address?: string;
461
+ marker?: string;
462
+ sort?: "ascending" | "descending";
463
+ instances?: string[];
464
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").ListDataSuccess | import("./DataRecordsController").ListDataFailure | {
465
+ readonly success: false;
466
+ readonly errorCode: "unacceptable_request";
467
+ readonly errorMessage: "recordName is required and must be a string.";
468
+ } | {
469
+ readonly success: false;
470
+ readonly errorCode: "unacceptable_request";
471
+ readonly errorMessage: "address must be null or a string.";
472
+ }>;
473
+ recordData: Procedure<{
474
+ recordKey?: string;
475
+ address?: string;
476
+ data?: any;
477
+ updatePolicy?: true | string[];
478
+ deletePolicy?: true | string[];
479
+ markers?: [string, ...string[]];
480
+ instances?: string[];
481
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./DataRecordsController").RecordDataSuccess | import("./DataRecordsController").RecordDataFailure | {
482
+ readonly success: false;
483
+ readonly errorCode: "unacceptable_request";
484
+ readonly errorMessage: "recordKey is required and must be a string.";
485
+ } | {
486
+ readonly success: false;
487
+ readonly errorCode: "unacceptable_request";
488
+ readonly errorMessage: "address is required and must be a string.";
489
+ } | {
490
+ readonly success: false;
491
+ readonly errorCode: "unacceptable_request";
492
+ readonly errorMessage: "data is required.";
493
+ }>;
494
+ listRecords: Procedure<{
495
+ studioId?: string;
496
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").ListRecordsResult>;
497
+ createRecordKey: Procedure<{
498
+ recordName?: string;
499
+ policy?: string;
500
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").CreatePublicRecordKeyResult | {
501
+ success: false;
502
+ errorCode: "not_logged_in";
503
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
504
+ }>;
505
+ grantPermission: Procedure<{
506
+ recordName?: string;
507
+ permission?: {
508
+ marker?: string;
509
+ subjectType?: "user" | "role" | "inst";
510
+ subjectId?: string;
511
+ resourceId?: string;
512
+ expireTimeMs?: number;
513
+ resourceKind?: "data";
514
+ action?: "create" | "read" | "update" | "delete" | "list";
515
+ } | {
516
+ marker?: string;
517
+ subjectType?: "user" | "role" | "inst";
518
+ subjectId?: string;
519
+ resourceId?: string;
520
+ expireTimeMs?: number;
521
+ resourceKind?: "file";
522
+ action?: "create" | "read" | "update" | "delete" | "list";
523
+ options?: {
524
+ maxFileSizeInBytes?: number;
525
+ allowedMimeTypes?: true | string[];
526
+ };
527
+ } | {
528
+ marker?: string;
529
+ subjectType?: "user" | "role" | "inst";
530
+ subjectId?: string;
531
+ expireTimeMs?: number;
532
+ resourceKind?: "event";
533
+ resourceId?: string;
534
+ action?: "update" | "increment" | "count" | "list";
535
+ } | {
536
+ marker?: string;
537
+ subjectType?: "user" | "role" | "inst";
538
+ subjectId?: string;
539
+ resourceId?: string;
540
+ expireTimeMs?: number;
541
+ resourceKind?: "marker";
542
+ action?: "read" | "assign" | "unassign" | "grantPermission" | "revokePermission";
543
+ } | {
544
+ marker?: string;
545
+ subjectType?: "user" | "role" | "inst";
546
+ subjectId?: string;
547
+ resourceId?: string;
548
+ expireTimeMs?: number;
549
+ resourceKind?: "role";
550
+ action?: "read" | "update" | "list" | "grant" | "revoke";
551
+ options?: {
552
+ maxDurationMs?: number;
553
+ };
554
+ } | {
555
+ marker?: string;
556
+ subjectType?: "user" | "role" | "inst";
557
+ subjectId?: string;
558
+ resourceId?: string;
559
+ expireTimeMs?: number;
560
+ resourceKind?: "inst";
561
+ action?: "create" | "read" | "update" | "delete" | "list" | "sendAction" | "updateData";
562
+ };
563
+ instances?: string[];
564
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").GrantMarkerPermissionSuccess | import("./PolicyController").GrantMarkerPermissionFailure | {
565
+ readonly success: false;
566
+ readonly errorCode: "unacceptable_request";
567
+ readonly errorMessage: "The given permission must have either a marker or a resourceId.";
568
+ }>;
569
+ revokePermission: Procedure<{
570
+ permissionId?: string;
571
+ instances?: string[];
572
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").RevokePermissionResult>;
573
+ listPermissions: Procedure<{
574
+ recordName?: string;
575
+ marker?: string;
576
+ resourceKind?: "data" | "role" | "event" | "inst" | "file" | "marker";
577
+ resourceId?: string;
578
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").ListPermissionsFailure | import("./PolicyController").ListPermissionsForMarkerSuccess | import("./PolicyController").ListPermissionsForResourceSuccess>;
579
+ listUserRoles: Procedure<{
580
+ recordName?: string;
581
+ userId?: string;
582
+ instances?: string[];
583
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").ListAssignedUserRolesResult>;
584
+ listInstRoles: Procedure<{
585
+ recordName?: string;
586
+ inst?: string;
587
+ instances?: string[];
588
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").ListAssignedInstRolesResult>;
589
+ listRoleAssignments: Procedure<{
590
+ recordName?: string;
591
+ startingRole?: string;
592
+ role?: string;
593
+ instances?: string[];
594
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").ListRoleAssignmentsResult>;
595
+ grantRole: Procedure<{
596
+ recordName?: string;
597
+ userId?: string;
598
+ inst?: string;
599
+ role?: string;
600
+ expireTimeMs?: number;
601
+ instances?: string[];
602
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").GrantRoleResult>;
603
+ revokeRole: Procedure<{
604
+ recordName?: string;
605
+ userId?: string;
606
+ inst?: string;
607
+ role?: string;
608
+ instances?: string[];
609
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./PolicyController").RevokeRoleResult>;
610
+ aiChat: Procedure<{
611
+ model?: string;
612
+ messages?: [{
613
+ role?: "function" | "system" | "user" | "assistant";
614
+ content?: string | ({
615
+ text?: string;
616
+ } | {
617
+ base64?: string;
618
+ mimeType?: string;
619
+ } | {
620
+ url?: string;
621
+ })[];
622
+ author?: string;
623
+ }, ...{
624
+ role?: "function" | "system" | "user" | "assistant";
625
+ content?: string | ({
626
+ text?: string;
627
+ } | {
628
+ base64?: string;
629
+ mimeType?: string;
630
+ } | {
631
+ url?: string;
632
+ })[];
633
+ author?: string;
634
+ }[]];
635
+ instances?: string[];
636
+ temperature?: number;
637
+ topP?: number;
638
+ presencePenalty?: number;
639
+ frequencyPenalty?: number;
640
+ stopWords?: string[];
641
+ }, import("./AIController").AIChatResponse | import("./AuthController").ValidateSessionKeyFailure | {
642
+ success: false;
643
+ errorCode: "not_logged_in";
644
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
645
+ } | {
646
+ success: false;
647
+ errorCode: "not_supported";
648
+ errorMessage: string;
649
+ }>;
650
+ createAiSkybox: Procedure<{
651
+ prompt?: string;
652
+ negativePrompt?: string;
653
+ blockadeLabs?: {
654
+ skyboxStyleId?: number;
655
+ remixImagineId?: number;
656
+ seed?: number;
657
+ };
658
+ instances?: string[];
659
+ }, import("./AIController").AIGenerateSkyboxResponse | import("./AuthController").ValidateSessionKeyFailure | {
660
+ success: false;
661
+ errorCode: "not_logged_in";
662
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
663
+ } | {
664
+ success: false;
665
+ errorCode: "not_supported";
666
+ errorMessage: string;
667
+ }>;
668
+ getAiSkybox: Procedure<{
669
+ skyboxId?: string;
670
+ instances?: string[];
671
+ }, import("./AIController").AIGetSkyboxResponse | import("./AuthController").ValidateSessionKeyFailure | {
672
+ success: false;
673
+ errorCode: "not_logged_in";
674
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
675
+ } | {
676
+ success: false;
677
+ errorCode: "not_supported";
678
+ errorMessage: string;
679
+ }>;
680
+ createAiImage: Procedure<{
681
+ prompt?: string;
682
+ model?: string;
683
+ negativePrompt?: string;
684
+ width?: number;
685
+ height?: number;
686
+ seed?: number;
687
+ numberOfImages?: number;
688
+ steps?: number;
689
+ sampler?: string;
690
+ cfgScale?: number;
691
+ clipGuidancePreset?: string;
692
+ stylePreset?: string;
693
+ instances?: string[];
694
+ }, import("./AIController").AIGenerateImageResponse | import("./AuthController").ValidateSessionKeyFailure | {
695
+ success: false;
696
+ errorCode: "not_logged_in";
697
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
698
+ } | {
699
+ success: false;
700
+ errorCode: "not_supported";
701
+ errorMessage: string;
702
+ }>;
703
+ getStudio: Procedure<{
704
+ studioId?: string;
705
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").GetStudioResult>;
706
+ createStudio: Procedure<{
707
+ displayName?: string;
708
+ ownerStudioComId?: string;
709
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").CreateStudioSuccess | import("./RecordsController").CreateStudioInComIdFailure>;
710
+ updateStudio: Procedure<{
711
+ id?: string;
712
+ displayName?: string;
713
+ logoUrl?: string;
714
+ comIdConfig?: {
715
+ allowedStudioCreators?: "anyone" | "only-members";
716
+ };
717
+ playerConfig?: {
718
+ ab1BootstrapURL?: string;
719
+ arcGisApiKey?: string;
720
+ jitsiAppName?: string;
721
+ what3WordsApiKey?: string;
722
+ allowedBiosOptions?: ("studio" | "enter join code" | "join inst" | "static inst" | "local inst" | "local" | "public inst" | "private inst" | "free inst" | "free" | "studio inst" | "sign in" | "sign up" | "sign out")[];
723
+ defaultBiosOption?: "studio" | "enter join code" | "join inst" | "static inst" | "local inst" | "local" | "public inst" | "private inst" | "free inst" | "free" | "studio inst" | "sign in" | "sign up" | "sign out";
724
+ automaticBiosOption?: "studio" | "enter join code" | "join inst" | "static inst" | "local inst" | "local" | "public inst" | "private inst" | "free inst" | "free" | "studio inst" | "sign in" | "sign up" | "sign out";
725
+ };
726
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").UpdateStudioResult>;
727
+ requestStudioComId: Procedure<{
728
+ studioId?: string;
729
+ comId?: string;
730
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").ComIdRequestResult | {
731
+ success: false;
732
+ errorCode: "not_logged_in";
733
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
734
+ }>;
735
+ listStudios: Procedure<{
736
+ comId?: string;
737
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").ListStudiosResult>;
738
+ listStudioMembers: Procedure<{
739
+ studioId?: string;
740
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").ListStudioMembersResult>;
741
+ addStudioMember: Procedure<{
742
+ studioId?: string;
743
+ addedUserId?: string;
744
+ addedEmail?: string;
745
+ addedPhoneNumber?: string;
746
+ role?: "admin" | "member";
747
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").AddStudioMemberResult>;
748
+ removeStudioMember: Procedure<{
749
+ studioId?: string;
750
+ removedUserId?: string;
751
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./RecordsController").RemoveStudioMemberResult>;
752
+ getPlayerConfig: Procedure<{
753
+ comId?: string;
754
+ }, import("./RecordsController").GetPlayerConfigResult>;
755
+ getSubscriptions: Procedure<{
756
+ studioId?: string;
757
+ userId?: string;
758
+ }, import("./SubscriptionController").GetSubscriptionStatusSuccess | import("./SubscriptionController").GetSubscriptionStatusFailure | {
759
+ success: false;
760
+ errorCode: "not_logged_in";
761
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
762
+ } | {
763
+ readonly success: true;
764
+ readonly publishableKey: string;
765
+ readonly subscriptions: {
766
+ active: boolean;
767
+ statusCode: "active" | "trialing" | "canceled" | "ended" | "past_due" | "unpaid" | "incomplete" | "incomplete_expired" | "paused";
768
+ productName: string;
769
+ startDate: number;
770
+ endedDate: number;
771
+ cancelDate: number;
772
+ canceledDate: number;
773
+ currentPeriodStart: number;
774
+ currentPeriodEnd: number;
775
+ renewalInterval: "year" | "month" | "day" | "week";
776
+ intervalLength: number;
777
+ intervalCost: number;
778
+ currency: string;
779
+ featureList: string[];
780
+ }[];
781
+ readonly purchasableSubscriptions: {
782
+ id: string;
783
+ name: string;
784
+ description: string;
785
+ featureList: string[];
786
+ prices: {
787
+ id: string;
788
+ interval: "year" | "month" | "day" | "week";
789
+ intervalLength: number;
790
+ currency: string;
791
+ cost: number;
792
+ }[];
793
+ defaultSubscription: boolean;
794
+ }[];
795
+ }>;
796
+ getManageSubscriptionLink: Procedure<{
797
+ userId?: string;
798
+ studioId?: string;
799
+ subscriptionId?: string;
800
+ expectedPrice?: {
801
+ currency?: string;
802
+ cost?: number;
803
+ interval?: "year" | "month" | "day" | "week";
804
+ intervalLength?: number;
805
+ };
806
+ }, import("./SubscriptionController").CreateManageSubscriptionResult | {
807
+ success: false;
808
+ errorCode: "not_logged_in";
809
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
810
+ }>;
811
+ listInsts: Procedure<{
812
+ recordName?: string;
813
+ inst?: string;
814
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./websockets/WebsocketController").ListInstsResult | {
815
+ success: false;
816
+ errorCode: "not_logged_in";
817
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
818
+ } | {
819
+ success: false;
820
+ errorCode: "not_supported";
821
+ errorMessage: string;
822
+ } | NoSessionKeyResult>;
823
+ deleteInst: Procedure<{
824
+ recordKey?: string;
825
+ recordName?: string;
826
+ inst?: string;
827
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./websockets/WebsocketController").EraseInstResult | {
828
+ success: false;
829
+ errorCode: "not_logged_in";
830
+ errorMessage: "The user is not logged in. A session key must be provided for this operation.";
831
+ } | {
832
+ success: false;
833
+ errorCode: "not_supported";
834
+ errorMessage: string;
835
+ } | NoSessionKeyResult>;
836
+ reportInst: Procedure<{
837
+ recordName?: string;
838
+ inst?: string;
839
+ automaticReport?: boolean;
840
+ reportReason?: "poor-performance" | "spam" | "harassment" | "copyright-infringement" | "obscene" | "illegal" | "other";
841
+ reportReasonText?: string;
842
+ reportedUrl?: string;
843
+ reportedPermalink?: string;
844
+ }, import("./AuthController").ValidateSessionKeyFailure | import("./ModerationController").ReportInstResult | {
845
+ success: false;
846
+ errorCode: "not_supported";
847
+ errorMessage: string;
848
+ }>;
849
+ getInstData: Procedure<{
850
+ recordName?: string;
851
+ inst?: string;
852
+ branch?: string;
853
+ }, import("./AuthController").ValidateSessionKeyFailure | {
854
+ success: true;
855
+ data: import("@casual-simulation/aux-common").StoredAux;
856
+ } | {
857
+ success: false;
858
+ errorCode: "server_error" | "invalid_record_key" | "unacceptable_request" | "record_not_found" | "not_authorized" | "action_not_supported" | "not_logged_in" | "subscription_limit_reached" | "inst_not_found";
859
+ errorMessage: string;
860
+ reason?: import("@casual-simulation/aux-common").DenialReason;
861
+ }>;
862
+ };
152
863
  constructor(allowedAccountOrigins: Set<string>, allowedApiOrigins: Set<string>, authController: AuthController, livekitController: LivekitController, recordsController: RecordsController, eventsController: EventRecordsController, dataController: DataRecordsController, manualDataController: DataRecordsController, filesController: FileRecordsController, subscriptionController: SubscriptionController | null, rateLimitController: RateLimitController, policyController: PolicyController, aiController: AIController | null, websocketController: WebsocketController | null, moderationController: ModerationController | null, websocketRateLimitController?: RateLimitController | null);
864
+ private _createProcedures;
865
+ private _setupRoutes;
866
+ /**
867
+ * Adds the given procedure to the server.
868
+ * @param name The name of the procedure.
869
+ * @param procedure The procedure that should be added.
870
+ */
871
+ addProcedure<TInput, TOutput extends ProcedureOutput>(name: string, procedure: Procedure<TInput, TOutput>): void;
872
+ /**
873
+ * Adds the given procedural route to the server.
874
+ * @param route The route that should be added.
875
+ */
876
+ private _addProcedureRoute;
153
877
  /**
154
878
  * Adds the given route to the server.
155
879
  */
156
- addRoute(route: Route): void;
880
+ addRoute<T>(route: Route<T>): void;
881
+ /**
882
+ * Forcefully adds the given route to the server, overwriting any routes that already exist.
883
+ * @param route The route that should be added.
884
+ */
885
+ overrideRoute<T>(route: Route<T>): void;
157
886
  /**
158
887
  * Handles the given request and returns the specified response.
159
888
  * @param request The request that should be handled.
@@ -169,34 +898,7 @@ export declare class RecordsServer {
169
898
  private _processWebsocketDownload;
170
899
  private _processWebsocketUploadRequest;
171
900
  private _stripeWebhook;
172
- private _isEmailValid;
173
- private _isDisplayNameValid;
174
901
  private _handleOptions;
175
- private _listRecords;
176
- private _createRecord;
177
- private _createRecordKey;
178
- private _grantPermission;
179
- private _revokePermission;
180
- private _listPermissions;
181
- private _roleUserList;
182
- private _roleInstList;
183
- private _roleAssignmentsList;
184
- private _roleGrant;
185
- private _roleRevoke;
186
- private _aiChat;
187
- private _aiSkybox;
188
- private _aiGetSkybox;
189
- private _aiGenerateImage;
190
- private _getStudio;
191
- private _postStudio;
192
- private _updateStudio;
193
- private _requestComId;
194
- private _listStudios;
195
- private _listStudioMembers;
196
- private _addStudioMember;
197
- private _removeStudioMember;
198
- private _getPlayerConfig;
199
- private _listData;
200
902
  private _handleRecordFileOptions;
201
903
  private _recordFile;
202
904
  private _updateFile;
@@ -204,49 +906,18 @@ export declare class RecordsServer {
204
906
  private _listFiles;
205
907
  private _eraseFile;
206
908
  private _baseRecordData;
207
- private _recordData;
208
- private _manualRecordData;
209
909
  private _baseGetRecordData;
210
- private _getData;
211
- private _getManualRecordData;
212
910
  private _baseEraseRecordData;
213
- private _eraseData;
214
- private _eraseManualRecordData;
215
- private _getRecordsEventsCount;
216
- private _postRecordsEventsCount;
217
- private _listEvents;
218
- private _postRecordsEvents;
219
- private _postMeetToken;
220
- private _postLogin;
221
- private _privoLogin;
222
- private _oauthProvideCode;
223
- private _oauthCompleteLogin;
224
- private _registerPrivo;
225
- private _webAuthnRegisterOptions;
226
- private _webAuthnRegister;
227
- private _webAuthnLoginOptions;
228
- private _webAuthnLogin;
229
- private _listWebAuthnAuthenticators;
230
- private _deleteWebAuthnAuthenticator;
231
- private _postCompleteLogin;
232
- private _postRevokeSession;
233
- private _postRevokeAllSessions;
234
911
  private _postReplaceSession;
235
- private _getSessions;
236
912
  private _getSubscriptionInfo;
237
- private _getSubscriptionInfoV2;
238
913
  private _manageSubscription;
239
- private _manageSubscriptionV2;
240
- private _listInsts;
241
- private _deleteInst;
242
- private _reportInst;
243
- private _getInstData;
244
914
  /**
245
915
  * Endpoint to retrieve info about a user.
246
916
  * @param request The request.
247
917
  */
248
918
  private _getUserInfo;
249
919
  private _putUserInfo;
920
+ private _validateHttpSessionKey;
250
921
  private _validateSessionKey;
251
922
  }
252
923
  export declare function returnResult<T extends {