@4players/odin-common 1.0.6
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/CHANGELOG.md +5 -0
- package/LICENSE +7 -0
- package/README.md +28 -0
- package/lib/cjs/index.js +26 -0
- package/lib/cjs/plugins/api.js +2 -0
- package/lib/cjs/schemas/media.js +23 -0
- package/lib/cjs/schemas/message.js +10 -0
- package/lib/cjs/schemas/peer.js +34 -0
- package/lib/cjs/schemas/room.js +46 -0
- package/lib/cjs/schemas/serialization.js +15 -0
- package/lib/cjs/schemas/token.js +21 -0
- package/lib/cjs/schemas/webrtc.js +23 -0
- package/lib/cjs/streams/commands.js +80 -0
- package/lib/cjs/streams/notifications.js +16 -0
- package/lib/esm/index.js +10 -0
- package/lib/esm/plugins/api.js +1 -0
- package/lib/esm/schemas/media.js +20 -0
- package/lib/esm/schemas/message.js +7 -0
- package/lib/esm/schemas/peer.js +31 -0
- package/lib/esm/schemas/room.js +43 -0
- package/lib/esm/schemas/serialization.js +12 -0
- package/lib/esm/schemas/token.js +17 -0
- package/lib/esm/schemas/webrtc.js +20 -0
- package/lib/esm/streams/commands.js +77 -0
- package/lib/esm/streams/notifications.js +13 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/plugins/api.d.ts +88 -0
- package/lib/types/schemas/media.d.ts +114 -0
- package/lib/types/schemas/message.d.ts +12 -0
- package/lib/types/schemas/peer.d.ts +254 -0
- package/lib/types/schemas/room.d.ts +1213 -0
- package/lib/types/schemas/serialization.d.ts +12 -0
- package/lib/types/schemas/token.d.ts +36 -0
- package/lib/types/schemas/webrtc.d.ts +42 -0
- package/lib/types/streams/commands.d.ts +218 -0
- package/lib/types/streams/notifications.d.ts +779 -0
- package/package.json +40 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ByteArraySchema: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
3
|
+
export type ByteArray = z.infer<typeof ByteArraySchema>;
|
|
4
|
+
declare const LiteralSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
5
|
+
type Literal = z.infer<typeof LiteralSchema>;
|
|
6
|
+
export type Json = Literal | {
|
|
7
|
+
[key: string]: Json;
|
|
8
|
+
} | Json[];
|
|
9
|
+
export declare const JsonSchema: z.ZodType<Json>;
|
|
10
|
+
export declare const MessagePackRpcSchema: z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<0>, z.ZodNumber, z.ZodString, z.ZodUnknown], null>, z.ZodTuple<[z.ZodLiteral<1>, z.ZodNumber, z.ZodNullable<z.ZodString>, z.ZodUnknown], null>, z.ZodTuple<[z.ZodLiteral<2>, z.ZodString, z.ZodUnknown], null>]>;
|
|
11
|
+
export type MessagePackRpc = z.infer<typeof MessagePackRpcSchema>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const TokenSubjectSchema: z.ZodEnum<["connect"]>;
|
|
3
|
+
export declare const TokenAudienceSchema: z.ZodEnum<["sfu", "gateway"]>;
|
|
4
|
+
export declare const TokenClaimsSchema: z.ZodObject<{
|
|
5
|
+
uid: z.ZodString;
|
|
6
|
+
cid: z.ZodOptional<z.ZodString>;
|
|
7
|
+
rid: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
8
|
+
nsp: z.ZodOptional<z.ZodString>;
|
|
9
|
+
adr: z.ZodOptional<z.ZodString>;
|
|
10
|
+
sub: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["connect"]>, z.ZodArray<z.ZodEnum<["connect"]>, "many">]>>;
|
|
11
|
+
aud: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["sfu", "gateway"]>, z.ZodArray<z.ZodEnum<["sfu", "gateway"]>, "many">]>>;
|
|
12
|
+
exp: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
nbf: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
uid: string;
|
|
16
|
+
rid: (string | string[]) & (string | string[] | undefined);
|
|
17
|
+
cid?: string | undefined;
|
|
18
|
+
nsp?: string | undefined;
|
|
19
|
+
adr?: string | undefined;
|
|
20
|
+
sub?: "connect" | "connect"[] | undefined;
|
|
21
|
+
aud?: "sfu" | "gateway" | ("sfu" | "gateway")[] | undefined;
|
|
22
|
+
exp?: number | undefined;
|
|
23
|
+
nbf?: number | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
uid: string;
|
|
26
|
+
rid: (string | string[]) & (string | string[] | undefined);
|
|
27
|
+
cid?: string | undefined;
|
|
28
|
+
nsp?: string | undefined;
|
|
29
|
+
adr?: string | undefined;
|
|
30
|
+
sub?: "connect" | "connect"[] | undefined;
|
|
31
|
+
aud?: "sfu" | "gateway" | ("sfu" | "gateway")[] | undefined;
|
|
32
|
+
exp?: number | undefined;
|
|
33
|
+
nbf?: number | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export type TokenClaims = z.infer<typeof TokenClaimsSchema>;
|
|
36
|
+
export declare function oneOrMany<T extends z.ZodTypeAny>(type: T): z.ZodUnion<[T, z.ZodArray<T, "many">]>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const WebRtcUpdateSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
3
|
+
kind: z.ZodLiteral<"Sdp">;
|
|
4
|
+
type: z.ZodEnum<["Answer", "Offer"]>;
|
|
5
|
+
sdp: z.ZodString;
|
|
6
|
+
media_map: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodString], null>, "many">;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
type: "Answer" | "Offer";
|
|
9
|
+
kind: "Sdp";
|
|
10
|
+
sdp: string;
|
|
11
|
+
media_map: [number, string][];
|
|
12
|
+
}, {
|
|
13
|
+
type: "Answer" | "Offer";
|
|
14
|
+
kind: "Sdp";
|
|
15
|
+
sdp: string;
|
|
16
|
+
media_map: [number, string][];
|
|
17
|
+
}>, z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<"Trickle">;
|
|
19
|
+
candidate: z.ZodString;
|
|
20
|
+
spd_mid: z.ZodOptional<z.ZodString>;
|
|
21
|
+
spd_mline_index: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
username_fragment: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
kind: "Trickle";
|
|
25
|
+
candidate: string;
|
|
26
|
+
spd_mid?: string | undefined;
|
|
27
|
+
spd_mline_index?: number | undefined;
|
|
28
|
+
username_fragment?: string | null | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
kind: "Trickle";
|
|
31
|
+
candidate: string;
|
|
32
|
+
spd_mid?: string | undefined;
|
|
33
|
+
spd_mline_index?: number | undefined;
|
|
34
|
+
username_fragment?: string | null | undefined;
|
|
35
|
+
}>, z.ZodObject<{
|
|
36
|
+
kind: z.ZodLiteral<"TrickleFinished">;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
kind: "TrickleFinished";
|
|
39
|
+
}, {
|
|
40
|
+
kind: "TrickleFinished";
|
|
41
|
+
}>]>;
|
|
42
|
+
export type WebRtcUpdate = z.infer<typeof WebRtcUpdateSchema>;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const MainCommands: {
|
|
3
|
+
JoinRoom: {
|
|
4
|
+
request: z.ZodObject<{
|
|
5
|
+
token: z.ZodString;
|
|
6
|
+
room_id: z.ZodString;
|
|
7
|
+
user_data: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
8
|
+
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
user_data: Uint8Array;
|
|
11
|
+
token: string;
|
|
12
|
+
room_id: string;
|
|
13
|
+
position: [number, number, number] | [number, number];
|
|
14
|
+
}, {
|
|
15
|
+
user_data: Uint8Array;
|
|
16
|
+
token: string;
|
|
17
|
+
room_id: string;
|
|
18
|
+
position: [number, number, number] | [number, number];
|
|
19
|
+
}>;
|
|
20
|
+
response: z.ZodObject<{
|
|
21
|
+
peer_id: z.ZodNumber;
|
|
22
|
+
stream_id: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
token: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
peer_id: number;
|
|
26
|
+
stream_id?: number | undefined;
|
|
27
|
+
token?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
peer_id: number;
|
|
30
|
+
stream_id?: number | undefined;
|
|
31
|
+
token?: string | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
WebRtcUpdate: {
|
|
35
|
+
request: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
36
|
+
kind: z.ZodLiteral<"Sdp">;
|
|
37
|
+
type: z.ZodEnum<["Answer", "Offer"]>;
|
|
38
|
+
sdp: z.ZodString;
|
|
39
|
+
media_map: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodString], null>, "many">;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
type: "Answer" | "Offer";
|
|
42
|
+
kind: "Sdp";
|
|
43
|
+
sdp: string;
|
|
44
|
+
media_map: [number, string][];
|
|
45
|
+
}, {
|
|
46
|
+
type: "Answer" | "Offer";
|
|
47
|
+
kind: "Sdp";
|
|
48
|
+
sdp: string;
|
|
49
|
+
media_map: [number, string][];
|
|
50
|
+
}>, z.ZodObject<{
|
|
51
|
+
kind: z.ZodLiteral<"Trickle">;
|
|
52
|
+
candidate: z.ZodString;
|
|
53
|
+
spd_mid: z.ZodOptional<z.ZodString>;
|
|
54
|
+
spd_mline_index: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
username_fragment: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
kind: "Trickle";
|
|
58
|
+
candidate: string;
|
|
59
|
+
spd_mid?: string | undefined;
|
|
60
|
+
spd_mline_index?: number | undefined;
|
|
61
|
+
username_fragment?: string | null | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
kind: "Trickle";
|
|
64
|
+
candidate: string;
|
|
65
|
+
spd_mid?: string | undefined;
|
|
66
|
+
spd_mline_index?: number | undefined;
|
|
67
|
+
username_fragment?: string | null | undefined;
|
|
68
|
+
}>, z.ZodObject<{
|
|
69
|
+
kind: z.ZodLiteral<"TrickleFinished">;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
kind: "TrickleFinished";
|
|
72
|
+
}, {
|
|
73
|
+
kind: "TrickleFinished";
|
|
74
|
+
}>]>;
|
|
75
|
+
response: z.ZodNull;
|
|
76
|
+
};
|
|
77
|
+
RequestReconnectToken: {
|
|
78
|
+
request: z.ZodObject<{
|
|
79
|
+
peer_id: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
peer_id?: number | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
peer_id?: number | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
response: z.ZodString;
|
|
86
|
+
};
|
|
87
|
+
Ping: {
|
|
88
|
+
request: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
89
|
+
response: z.ZodNull;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export declare const RoomCommands: {
|
|
93
|
+
UpdatePeer: {
|
|
94
|
+
request: z.ZodObject<{
|
|
95
|
+
user_data: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
user_data: Uint8Array;
|
|
98
|
+
}, {
|
|
99
|
+
user_data: Uint8Array;
|
|
100
|
+
}>;
|
|
101
|
+
response: z.ZodNull;
|
|
102
|
+
};
|
|
103
|
+
StartMedia: {
|
|
104
|
+
request: z.ZodObject<{
|
|
105
|
+
media_id: z.ZodNumber;
|
|
106
|
+
properties: z.ZodUnion<[z.ZodObject<{
|
|
107
|
+
kind: z.ZodOptional<z.ZodLiteral<"audio">>;
|
|
108
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
kind?: "audio" | undefined;
|
|
111
|
+
uid?: string | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
kind?: "audio" | undefined;
|
|
114
|
+
uid?: string | undefined;
|
|
115
|
+
}>, z.ZodObject<{
|
|
116
|
+
kind: z.ZodOptional<z.ZodLiteral<"video">>;
|
|
117
|
+
codec: z.ZodOptional<z.ZodString>;
|
|
118
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
kind?: "video" | undefined;
|
|
121
|
+
codec?: string | undefined;
|
|
122
|
+
uid?: string | undefined;
|
|
123
|
+
}, {
|
|
124
|
+
kind?: "video" | undefined;
|
|
125
|
+
codec?: string | undefined;
|
|
126
|
+
uid?: string | undefined;
|
|
127
|
+
}>]>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
properties: ({
|
|
130
|
+
kind?: "audio" | undefined;
|
|
131
|
+
uid?: string | undefined;
|
|
132
|
+
} | {
|
|
133
|
+
kind?: "video" | undefined;
|
|
134
|
+
codec?: string | undefined;
|
|
135
|
+
uid?: string | undefined;
|
|
136
|
+
}) & ({
|
|
137
|
+
kind?: "audio" | undefined;
|
|
138
|
+
uid?: string | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
kind?: "video" | undefined;
|
|
141
|
+
codec?: string | undefined;
|
|
142
|
+
uid?: string | undefined;
|
|
143
|
+
} | undefined);
|
|
144
|
+
media_id: number;
|
|
145
|
+
}, {
|
|
146
|
+
properties: ({
|
|
147
|
+
kind?: "audio" | undefined;
|
|
148
|
+
uid?: string | undefined;
|
|
149
|
+
} | {
|
|
150
|
+
kind?: "video" | undefined;
|
|
151
|
+
codec?: string | undefined;
|
|
152
|
+
uid?: string | undefined;
|
|
153
|
+
}) & ({
|
|
154
|
+
kind?: "audio" | undefined;
|
|
155
|
+
uid?: string | undefined;
|
|
156
|
+
} | {
|
|
157
|
+
kind?: "video" | undefined;
|
|
158
|
+
codec?: string | undefined;
|
|
159
|
+
uid?: string | undefined;
|
|
160
|
+
} | undefined);
|
|
161
|
+
media_id: number;
|
|
162
|
+
}>;
|
|
163
|
+
response: z.ZodNull;
|
|
164
|
+
};
|
|
165
|
+
StopMedia: {
|
|
166
|
+
request: z.ZodObject<{
|
|
167
|
+
media_id: z.ZodNumber;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
media_id: number;
|
|
170
|
+
}, {
|
|
171
|
+
media_id: number;
|
|
172
|
+
}>;
|
|
173
|
+
response: z.ZodNull;
|
|
174
|
+
};
|
|
175
|
+
PauseMedia: {
|
|
176
|
+
request: z.ZodObject<{
|
|
177
|
+
media_id: z.ZodNumber;
|
|
178
|
+
}, "strip", z.ZodTypeAny, {
|
|
179
|
+
media_id: number;
|
|
180
|
+
}, {
|
|
181
|
+
media_id: number;
|
|
182
|
+
}>;
|
|
183
|
+
response: z.ZodNull;
|
|
184
|
+
};
|
|
185
|
+
ResumeMedia: {
|
|
186
|
+
request: z.ZodObject<{
|
|
187
|
+
media_id: z.ZodNumber;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
media_id: number;
|
|
190
|
+
}, {
|
|
191
|
+
media_id: number;
|
|
192
|
+
}>;
|
|
193
|
+
response: z.ZodNull;
|
|
194
|
+
};
|
|
195
|
+
SetPeerPosition: {
|
|
196
|
+
request: z.ZodObject<{
|
|
197
|
+
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
|
199
|
+
position: [number, number, number] | [number, number];
|
|
200
|
+
}, {
|
|
201
|
+
position: [number, number, number] | [number, number];
|
|
202
|
+
}>;
|
|
203
|
+
response: z.ZodNull;
|
|
204
|
+
};
|
|
205
|
+
SendMessage: {
|
|
206
|
+
request: z.ZodObject<{
|
|
207
|
+
target_peer_ids: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
208
|
+
message: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
209
|
+
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
message: Uint8Array;
|
|
211
|
+
target_peer_ids?: number[] | undefined;
|
|
212
|
+
}, {
|
|
213
|
+
message: Uint8Array;
|
|
214
|
+
target_peer_ids?: number[] | undefined;
|
|
215
|
+
}>;
|
|
216
|
+
response: z.ZodNull;
|
|
217
|
+
};
|
|
218
|
+
};
|