@darco2903/altv-web-api 0.0.0-stage → 1.0.0-pre

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/README.md CHANGED
@@ -1,3 +1,25 @@
1
- # Temporary Holding Version
1
+ # Authentification API
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Description
4
+
5
+ This API is a TypeScript client for the Darco2903 authentication service.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install auth-api-<version>.tgz
11
+ npm install @ts-rest/core zod@3.22.3
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Create an instance of the API
17
+
18
+ ```ts
19
+ import { initClient } from "@ts-rest/core";
20
+ import { contract } from "auth-api";
21
+
22
+ const api = initClient(contract, {
23
+ baseUrl: "https://api.example.com",
24
+ });
25
+ ```
@@ -0,0 +1,498 @@
1
+ import { Socket } from "socket.io-client";
2
+ export * from "./common.js";
3
+ import type { ClientToServerEvents, ServerToClientEvents } from "./socket/index.js";
4
+ export declare function createClient(origin: string): {
5
+ youtube: {
6
+ getLink: (args: {
7
+ params: {
8
+ videoId: string;
9
+ };
10
+ cache?: RequestCache | undefined;
11
+ extraHeaders?: Record<string, string | undefined> | undefined;
12
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
13
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
14
+ query?: {
15
+ filter?: "audio" | "audioandvideo" | "audioonly" | "video" | "videoandaudio" | "videoonly" | undefined;
16
+ quality?: "highest" | "highestaudio" | "highestvideo" | "lowest" | "lowestaudio" | "lowestvideo" | undefined;
17
+ } | undefined;
18
+ }) => Promise<{
19
+ status: 200;
20
+ body: {
21
+ url: string;
22
+ };
23
+ headers: Headers;
24
+ } | {
25
+ status: 400;
26
+ body: {
27
+ name: "ZodError";
28
+ issues: import("zod").objectOutputType<{
29
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
30
+ message: import("zod").ZodOptional<import("zod").ZodString>;
31
+ code: import("zod").ZodNativeEnum<{
32
+ invalid_type: "invalid_type";
33
+ invalid_literal: "invalid_literal";
34
+ custom: "custom";
35
+ invalid_union: "invalid_union";
36
+ invalid_union_discriminator: "invalid_union_discriminator";
37
+ invalid_enum_value: "invalid_enum_value";
38
+ unrecognized_keys: "unrecognized_keys";
39
+ invalid_arguments: "invalid_arguments";
40
+ invalid_return_type: "invalid_return_type";
41
+ invalid_date: "invalid_date";
42
+ invalid_string: "invalid_string";
43
+ too_small: "too_small";
44
+ too_big: "too_big";
45
+ invalid_intersection_types: "invalid_intersection_types";
46
+ not_multiple_of: "not_multiple_of";
47
+ not_finite: "not_finite";
48
+ }>;
49
+ }, import("zod").ZodAny, "strip">[];
50
+ } | {
51
+ code: "INVALID_VIDEO_ID";
52
+ error: "The provided video ID is invalid";
53
+ name: "APIError";
54
+ };
55
+ headers: Headers;
56
+ } | {
57
+ status: 500;
58
+ body: {
59
+ code: "INTERNAL_SERVER_ERROR";
60
+ error: string;
61
+ name: "APIError";
62
+ };
63
+ headers: Headers;
64
+ } | {
65
+ status: 404 | 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
66
+ body: unknown;
67
+ headers: Headers;
68
+ }>;
69
+ };
70
+ sync: (args: {
71
+ body: {
72
+ clientTime: number;
73
+ };
74
+ cache?: RequestCache | undefined;
75
+ extraHeaders?: Record<string, string | undefined> | undefined;
76
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
77
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
78
+ }) => Promise<{
79
+ status: 200;
80
+ body: {
81
+ clientTime: number;
82
+ serverTime: number;
83
+ };
84
+ headers: Headers;
85
+ } | {
86
+ status: 400;
87
+ body: {
88
+ name: "ZodError";
89
+ issues: import("zod").objectOutputType<{
90
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
91
+ message: import("zod").ZodOptional<import("zod").ZodString>;
92
+ code: import("zod").ZodNativeEnum<{
93
+ invalid_type: "invalid_type";
94
+ invalid_literal: "invalid_literal";
95
+ custom: "custom";
96
+ invalid_union: "invalid_union";
97
+ invalid_union_discriminator: "invalid_union_discriminator";
98
+ invalid_enum_value: "invalid_enum_value";
99
+ unrecognized_keys: "unrecognized_keys";
100
+ invalid_arguments: "invalid_arguments";
101
+ invalid_return_type: "invalid_return_type";
102
+ invalid_date: "invalid_date";
103
+ invalid_string: "invalid_string";
104
+ too_small: "too_small";
105
+ too_big: "too_big";
106
+ invalid_intersection_types: "invalid_intersection_types";
107
+ not_multiple_of: "not_multiple_of";
108
+ not_finite: "not_finite";
109
+ }>;
110
+ }, import("zod").ZodAny, "strip">[];
111
+ };
112
+ headers: Headers;
113
+ } | {
114
+ status: 500 | 404 | 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
115
+ body: unknown;
116
+ headers: Headers;
117
+ }>;
118
+ time: (args?: {
119
+ cache?: RequestCache | undefined;
120
+ extraHeaders?: Record<string, string | undefined> | undefined;
121
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
122
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
123
+ } | undefined) => Promise<{
124
+ status: 200;
125
+ body: {
126
+ serverTime: number;
127
+ };
128
+ headers: Headers;
129
+ } | {
130
+ status: 400 | 500 | 404 | 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
131
+ body: unknown;
132
+ headers: Headers;
133
+ }>;
134
+ mediaStream: {
135
+ init: (args: {
136
+ body: {
137
+ videoId: string;
138
+ };
139
+ cache?: RequestCache | undefined;
140
+ extraHeaders?: Record<string, string | undefined> | undefined;
141
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
142
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
143
+ }) => Promise<{
144
+ status: 200;
145
+ body: {
146
+ streamId: string;
147
+ };
148
+ headers: Headers;
149
+ } | {
150
+ status: 400;
151
+ body: {
152
+ name: "ZodError";
153
+ issues: import("zod").objectOutputType<{
154
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
155
+ message: import("zod").ZodOptional<import("zod").ZodString>;
156
+ code: import("zod").ZodNativeEnum<{
157
+ invalid_type: "invalid_type";
158
+ invalid_literal: "invalid_literal";
159
+ custom: "custom";
160
+ invalid_union: "invalid_union";
161
+ invalid_union_discriminator: "invalid_union_discriminator";
162
+ invalid_enum_value: "invalid_enum_value";
163
+ unrecognized_keys: "unrecognized_keys";
164
+ invalid_arguments: "invalid_arguments";
165
+ invalid_return_type: "invalid_return_type";
166
+ invalid_date: "invalid_date";
167
+ invalid_string: "invalid_string";
168
+ too_small: "too_small";
169
+ too_big: "too_big";
170
+ invalid_intersection_types: "invalid_intersection_types";
171
+ not_multiple_of: "not_multiple_of";
172
+ not_finite: "not_finite";
173
+ }>;
174
+ }, import("zod").ZodAny, "strip">[];
175
+ } | {
176
+ code: "INVALID_VIDEO_ID";
177
+ error: "The provided video ID is invalid";
178
+ name: "APIError";
179
+ };
180
+ headers: Headers;
181
+ } | {
182
+ status: 500;
183
+ body: {
184
+ code: "INTERNAL_SERVER_ERROR";
185
+ error: string;
186
+ name: "APIError";
187
+ };
188
+ headers: Headers;
189
+ } | {
190
+ status: 404 | 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
191
+ body: unknown;
192
+ headers: Headers;
193
+ }>;
194
+ get: (args: {
195
+ params: {
196
+ streamId: string;
197
+ };
198
+ cache?: RequestCache | undefined;
199
+ extraHeaders?: Record<string, string | undefined> | undefined;
200
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
201
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
202
+ }) => Promise<{
203
+ status: 200;
204
+ body: {
205
+ streamId: string;
206
+ startTime: number;
207
+ duration: number;
208
+ url: string;
209
+ paused: boolean;
210
+ };
211
+ headers: Headers;
212
+ } | {
213
+ status: 400;
214
+ body: {
215
+ name: "ZodError";
216
+ issues: import("zod").objectOutputType<{
217
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
218
+ message: import("zod").ZodOptional<import("zod").ZodString>;
219
+ code: import("zod").ZodNativeEnum<{
220
+ invalid_type: "invalid_type";
221
+ invalid_literal: "invalid_literal";
222
+ custom: "custom";
223
+ invalid_union: "invalid_union";
224
+ invalid_union_discriminator: "invalid_union_discriminator";
225
+ invalid_enum_value: "invalid_enum_value";
226
+ unrecognized_keys: "unrecognized_keys";
227
+ invalid_arguments: "invalid_arguments";
228
+ invalid_return_type: "invalid_return_type";
229
+ invalid_date: "invalid_date";
230
+ invalid_string: "invalid_string";
231
+ too_small: "too_small";
232
+ too_big: "too_big";
233
+ invalid_intersection_types: "invalid_intersection_types";
234
+ not_multiple_of: "not_multiple_of";
235
+ not_finite: "not_finite";
236
+ }>;
237
+ }, import("zod").ZodAny, "strip">[];
238
+ } | {
239
+ code: "INVALID_STREAM_ID";
240
+ error: "The provided stream ID is invalid";
241
+ name: "APIError";
242
+ };
243
+ headers: Headers;
244
+ } | {
245
+ status: 500;
246
+ body: {
247
+ code: "INTERNAL_SERVER_ERROR";
248
+ error: string;
249
+ name: "APIError";
250
+ };
251
+ headers: Headers;
252
+ } | {
253
+ status: 404 | 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
254
+ body: unknown;
255
+ headers: Headers;
256
+ }>;
257
+ play: (args: {
258
+ params: {
259
+ streamId: string;
260
+ };
261
+ cache?: RequestCache | undefined;
262
+ extraHeaders?: Record<string, string | undefined> | undefined;
263
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
264
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
265
+ }) => Promise<{
266
+ status: 200;
267
+ body: undefined;
268
+ headers: Headers;
269
+ } | {
270
+ status: 400;
271
+ body: {
272
+ name: "ZodError";
273
+ issues: import("zod").objectOutputType<{
274
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
275
+ message: import("zod").ZodOptional<import("zod").ZodString>;
276
+ code: import("zod").ZodNativeEnum<{
277
+ invalid_type: "invalid_type";
278
+ invalid_literal: "invalid_literal";
279
+ custom: "custom";
280
+ invalid_union: "invalid_union";
281
+ invalid_union_discriminator: "invalid_union_discriminator";
282
+ invalid_enum_value: "invalid_enum_value";
283
+ unrecognized_keys: "unrecognized_keys";
284
+ invalid_arguments: "invalid_arguments";
285
+ invalid_return_type: "invalid_return_type";
286
+ invalid_date: "invalid_date";
287
+ invalid_string: "invalid_string";
288
+ too_small: "too_small";
289
+ too_big: "too_big";
290
+ invalid_intersection_types: "invalid_intersection_types";
291
+ not_multiple_of: "not_multiple_of";
292
+ not_finite: "not_finite";
293
+ }>;
294
+ }, import("zod").ZodAny, "strip">[];
295
+ } | {
296
+ code: "INVALID_STREAM_ID";
297
+ error: "The provided stream ID is invalid";
298
+ name: "APIError";
299
+ };
300
+ headers: Headers;
301
+ } | {
302
+ status: 500;
303
+ body: {
304
+ code: "INTERNAL_SERVER_ERROR";
305
+ error: string;
306
+ name: "APIError";
307
+ };
308
+ headers: Headers;
309
+ } | {
310
+ status: 404;
311
+ body: {
312
+ code: "STREAM_NOT_FOUND";
313
+ error: "The requested stream was not found";
314
+ name: "APIError";
315
+ };
316
+ headers: Headers;
317
+ } | {
318
+ status: 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
319
+ body: unknown;
320
+ headers: Headers;
321
+ }>;
322
+ pause: (args: {
323
+ params: {
324
+ streamId: string;
325
+ };
326
+ cache?: RequestCache | undefined;
327
+ extraHeaders?: Record<string, string | undefined> | undefined;
328
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
329
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
330
+ }) => Promise<{
331
+ status: 200;
332
+ body: undefined;
333
+ headers: Headers;
334
+ } | {
335
+ status: 400;
336
+ body: {
337
+ name: "ZodError";
338
+ issues: import("zod").objectOutputType<{
339
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
340
+ message: import("zod").ZodOptional<import("zod").ZodString>;
341
+ code: import("zod").ZodNativeEnum<{
342
+ invalid_type: "invalid_type";
343
+ invalid_literal: "invalid_literal";
344
+ custom: "custom";
345
+ invalid_union: "invalid_union";
346
+ invalid_union_discriminator: "invalid_union_discriminator";
347
+ invalid_enum_value: "invalid_enum_value";
348
+ unrecognized_keys: "unrecognized_keys";
349
+ invalid_arguments: "invalid_arguments";
350
+ invalid_return_type: "invalid_return_type";
351
+ invalid_date: "invalid_date";
352
+ invalid_string: "invalid_string";
353
+ too_small: "too_small";
354
+ too_big: "too_big";
355
+ invalid_intersection_types: "invalid_intersection_types";
356
+ not_multiple_of: "not_multiple_of";
357
+ not_finite: "not_finite";
358
+ }>;
359
+ }, import("zod").ZodAny, "strip">[];
360
+ } | {
361
+ code: "INVALID_STREAM_ID";
362
+ error: "The provided stream ID is invalid";
363
+ name: "APIError";
364
+ };
365
+ headers: Headers;
366
+ } | {
367
+ status: 500;
368
+ body: {
369
+ code: "INTERNAL_SERVER_ERROR";
370
+ error: string;
371
+ name: "APIError";
372
+ };
373
+ headers: Headers;
374
+ } | {
375
+ status: 404;
376
+ body: {
377
+ code: "STREAM_NOT_FOUND";
378
+ error: "The requested stream was not found";
379
+ name: "APIError";
380
+ };
381
+ headers: Headers;
382
+ } | {
383
+ status: 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
384
+ body: unknown;
385
+ headers: Headers;
386
+ }>;
387
+ seek: (args: {
388
+ params: {
389
+ streamId: string;
390
+ };
391
+ query: {
392
+ time: number;
393
+ };
394
+ cache?: RequestCache | undefined;
395
+ extraHeaders?: Record<string, string | undefined> | undefined;
396
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
397
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
398
+ }) => Promise<{
399
+ status: 200;
400
+ body: undefined;
401
+ headers: Headers;
402
+ } | {
403
+ status: 400;
404
+ body: {
405
+ name: "ZodError";
406
+ issues: import("zod").objectOutputType<{
407
+ path: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodNumber]>, "many">;
408
+ message: import("zod").ZodOptional<import("zod").ZodString>;
409
+ code: import("zod").ZodNativeEnum<{
410
+ invalid_type: "invalid_type";
411
+ invalid_literal: "invalid_literal";
412
+ custom: "custom";
413
+ invalid_union: "invalid_union";
414
+ invalid_union_discriminator: "invalid_union_discriminator";
415
+ invalid_enum_value: "invalid_enum_value";
416
+ unrecognized_keys: "unrecognized_keys";
417
+ invalid_arguments: "invalid_arguments";
418
+ invalid_return_type: "invalid_return_type";
419
+ invalid_date: "invalid_date";
420
+ invalid_string: "invalid_string";
421
+ too_small: "too_small";
422
+ too_big: "too_big";
423
+ invalid_intersection_types: "invalid_intersection_types";
424
+ not_multiple_of: "not_multiple_of";
425
+ not_finite: "not_finite";
426
+ }>;
427
+ }, import("zod").ZodAny, "strip">[];
428
+ } | {
429
+ code: "INVALID_STREAM_ID";
430
+ error: "The provided stream ID is invalid";
431
+ name: "APIError";
432
+ };
433
+ headers: Headers;
434
+ } | {
435
+ status: 500;
436
+ body: {
437
+ code: "INTERNAL_SERVER_ERROR";
438
+ error: string;
439
+ name: "APIError";
440
+ };
441
+ headers: Headers;
442
+ } | {
443
+ status: 404;
444
+ body: {
445
+ code: "STREAM_NOT_FOUND";
446
+ error: "The requested stream was not found";
447
+ name: "APIError";
448
+ };
449
+ headers: Headers;
450
+ } | {
451
+ status: 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
452
+ body: unknown;
453
+ headers: Headers;
454
+ }>;
455
+ stream: (args: {
456
+ params: {
457
+ streamId: string;
458
+ };
459
+ cache?: RequestCache | undefined;
460
+ extraHeaders?: Record<string, string | undefined> | undefined;
461
+ fetchOptions?: import("@ts-rest/core").FetchOptions | undefined;
462
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs> | undefined;
463
+ }) => Promise<{
464
+ status: 200;
465
+ body: any;
466
+ headers: Headers;
467
+ } | {
468
+ status: 400;
469
+ body: {
470
+ code: "INVALID_VIDEO_ID";
471
+ error: "The provided video ID is invalid";
472
+ name: "APIError";
473
+ };
474
+ headers: Headers;
475
+ } | {
476
+ status: 500;
477
+ body: {
478
+ code: "INTERNAL_SERVER_ERROR";
479
+ error: string;
480
+ name: "APIError";
481
+ };
482
+ headers: Headers;
483
+ } | {
484
+ status: 404;
485
+ body: {
486
+ code: "STREAM_NOT_FOUND";
487
+ error: "The requested stream was not found";
488
+ name: "APIError";
489
+ };
490
+ headers: Headers;
491
+ } | {
492
+ status: 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 401 | 402 | 403 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
493
+ body: unknown;
494
+ headers: Headers;
495
+ }>;
496
+ };
497
+ };
498
+ export declare function createSocket(origin: string): Socket<ServerToClientEvents, ClientToServerEvents>;
package/dist/client.js ADDED
@@ -0,0 +1,15 @@
1
+ import { io } from "socket.io-client";
2
+ export * from "./common.js";
3
+ import { initClient } from "@ts-rest/core";
4
+ import contract from "./contract/index.js";
5
+ export function createClient(origin) {
6
+ return initClient(contract, {
7
+ baseUrl: origin,
8
+ credentials: "include",
9
+ });
10
+ }
11
+ export function createSocket(origin) {
12
+ return io(origin, {
13
+ autoConnect: true,
14
+ });
15
+ }
@@ -0,0 +1,9 @@
1
+ export { default as contract } from "./contract/index.js";
2
+ export * from "./types/index.js";
3
+ export * from "./consts.js";
4
+ export type TimeSync = {
5
+ RTT: number;
6
+ oneWayDelay: number;
7
+ offset: number;
8
+ };
9
+ export declare function timeSyncOffset(t1: number, t2: number, t4: number): TimeSync;
package/dist/common.js ADDED
@@ -0,0 +1,9 @@
1
+ export { default as contract } from "./contract/index.js";
2
+ export * from "./types/index.js";
3
+ export * from "./consts.js";
4
+ export function timeSyncOffset(t1, t2, t4) {
5
+ const RTT = t4 - t1;
6
+ const oneWayDelay = RTT / 2;
7
+ const offset = t2 - (t1 + oneWayDelay);
8
+ return { RTT, oneWayDelay, offset };
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/consts.js ADDED
@@ -0,0 +1 @@
1
+ export {};