@hytopia.com/server-protocol 1.4.23 → 1.4.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.4.23",
3
+ "version": "1.4.26",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -12,8 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@hytopia.com/server-protocol": "^1.1.3",
15
- "ajv": "^8.17.1",
16
- "mediasoup": "^3.15.7"
15
+ "ajv": "^8.17.1"
17
16
  },
18
17
  "repository": {
19
18
  "type": "git",
@@ -6,7 +6,6 @@ export type BlockTypeSchema = {
6
6
  ll?: number; // light level
7
7
  n?: string; // name
8
8
  t?: string; // textureUri
9
- th?: string; // texture hash
10
9
  }
11
10
 
12
11
  export const blockTypeSchema: JSONSchemaType<BlockTypeSchema> = {
@@ -17,7 +16,6 @@ export const blockTypeSchema: JSONSchemaType<BlockTypeSchema> = {
17
16
  ll: { type: 'number', nullable: true },
18
17
  n: { type: 'string', nullable: true },
19
18
  t: { type: 'string', nullable: true },
20
- th: { type: 'string', nullable: true },
21
19
  },
22
20
  required: [ 'i' ],
23
21
  additionalProperties: false,
@@ -1,178 +1,9 @@
1
- import * as mediasoup from 'mediasoup';
2
1
  import { JSONSchemaType } from 'ajv';
3
2
 
4
- /**
5
- * Types
6
- */
7
-
8
- type WrtcConnectAck = {
9
- i: string; // transport id
10
- }
11
-
12
- type WrtcDataChannel = {
13
- i?: string; // data channel id (server -> client channel only)
14
- pi?: string; // data producer id (server -> client channel only)
15
- l: string; // label
16
- s: mediasoup.types.SctpStreamParameters; // sctp stream parameters
17
- }
18
-
19
- type WrtcProduceDataAck = {
20
- i: string; // producer id
21
- l: string; // label, used for client reference of ack
22
- }
23
-
24
- type WrtcTransport = {
25
- i: string; // transport id
26
- f: 'cs' | 'sc'; // data flow (cs: client -> server | sc: server -> client)
27
- d: mediasoup.types.DtlsParameters; // dtls parameters
28
- ic: mediasoup.types.IceCandidate[]; // ice candidates
29
- ip: mediasoup.types.IceParameters; // ice parameters
30
- s: mediasoup.types.SctpParameters; // sctp parameters
31
- }
32
-
33
- type WrtcTransportConnect = {
34
- i: string; // transport id
35
- d: mediasoup.types.DtlsParameters; // dtls parameters
36
- }
37
-
38
3
  export type ConnectionSchema = {
39
- i?: string; // connection id | server -> client | on initial WS connection
40
- k?: boolean // kill connection | server -> client | tells client to close connection & not reconnect
41
- c?: WrtcTransportConnect, // wrtc transport connect | client -> server | 2nd wrtc packet
42
- ca?: WrtcConnectAck, // wrtc connect ack | server -> client | 3rd wrtc packet
43
- d?: WrtcDataChannel[], // wrtc data channels | server <-> client | 1st wrtc packet s->c, 4th wrtc packet c->s
44
- pa?: WrtcProduceDataAck, // wrtc produce data ack | server -> client | 5th wrtc packet
45
- t?: WrtcTransport[], // wrtc transports | server -> client | 1st wrtc packet
46
- };
47
-
48
- /**
49
- * Schemas
50
- */
51
-
52
- const wrtcConnectAckSchema: JSONSchemaType<WrtcConnectAck> = {
53
- type: 'object',
54
- properties: {
55
- i: { type: 'string' },
56
- },
57
- required: [ 'i' ],
58
- additionalProperties: false,
59
- };
60
-
61
- const wrtcDtlsParametersSchema: JSONSchemaType<mediasoup.types.DtlsParameters> = {
62
- type: 'object',
63
- properties: {
64
- role: { type: 'string', enum: [ 'auto', 'client', 'server' ], nullable: true },
65
- fingerprints: {
66
- type: 'array',
67
- items: {
68
- type: 'object',
69
- properties: {
70
- algorithm: { type: 'string', enum: [ 'sha-1', 'sha-224', 'sha-256', 'sha-384', 'sha-512' ] },
71
- value: { type: 'string' },
72
- },
73
- required: [ 'algorithm', 'value' ],
74
- }
75
- },
76
- },
77
- required: [ 'fingerprints' ],
78
- additionalProperties: false,
79
- };
80
-
81
- const wrtcIceCandidateSchema: JSONSchemaType<mediasoup.types.IceCandidate> = {
82
- type: 'object',
83
- properties: {
84
- foundation: { type: 'string' },
85
- priority: { type: 'number' },
86
- ip: { type: 'string' },
87
- address: { type: 'string' },
88
- protocol: { type: 'string', enum: [ 'udp', 'tcp' ] },
89
- port: { type: 'number' },
90
- type: { type: 'string', enum: [ 'host' ] },
91
- tcpType: { type: 'string', enum: [ 'passive' ], nullable: true },
92
- },
93
- required: [ 'foundation', 'priority', 'ip', 'address', 'protocol', 'port', 'type' ],
94
- additionalProperties: false,
95
- };
96
-
97
- const wrtcIceParametersSchema: JSONSchemaType<mediasoup.types.IceParameters> = {
98
- type: 'object',
99
- properties: {
100
- usernameFragment: { type: 'string' },
101
- password: { type: 'string' },
102
- iceLite: { type: 'boolean', nullable: true },
103
- },
104
- required: [ 'usernameFragment', 'password' ],
105
- additionalProperties: false,
106
- };
107
-
108
- const wrtcProduceDataAckSchema: JSONSchemaType<WrtcProduceDataAck> = {
109
- type: 'object',
110
- properties: {
111
- i: { type: 'string' },
112
- l: { type: 'string' },
113
- },
114
- required: [ 'i', 'l' ],
115
- additionalProperties: false,
116
- };
117
-
118
- const wrtcSctpParametersSchema: JSONSchemaType<mediasoup.types.SctpParameters> = {
119
- type: 'object',
120
- properties: {
121
- port: { type: 'number' },
122
- OS: { type: 'number' },
123
- MIS: { type: 'number' },
124
- maxMessageSize: { type: 'number' },
125
- },
126
- required: [ 'port', 'OS', 'MIS', 'maxMessageSize' ],
127
- additionalProperties: true, // May be an SCTPParametersDump
128
- };
129
-
130
- const wrtcSctpStreamParametersSchema: JSONSchemaType<mediasoup.types.SctpStreamParameters> = {
131
- type: 'object',
132
- properties: {
133
- streamId: { type: 'number' },
134
- ordered: { type: 'boolean', nullable: true },
135
- maxPacketLifeTime: { type: 'number', nullable: true },
136
- maxRetransmits: { type: 'number', nullable: true },
137
- },
138
- required: [ 'streamId' ],
139
- additionalProperties: false,
140
- };
141
-
142
- const wrtcTransportSchema: JSONSchemaType<WrtcTransport> = {
143
- type: 'object',
144
- properties: {
145
- i: { type: 'string' },
146
- f: { type: 'string', enum: [ 'cs', 'sc' ] },
147
- ip: wrtcIceParametersSchema,
148
- ic: { type: 'array', items: wrtcIceCandidateSchema },
149
- d: wrtcDtlsParametersSchema,
150
- s: wrtcSctpParametersSchema,
151
- },
152
- required: [ 'i', 'f', 'ip', 'ic', 'd', 's' ],
153
- additionalProperties: false,
154
- };
155
-
156
- const wrtcTransportConnectSchema: JSONSchemaType<WrtcTransportConnect> = {
157
- type: 'object',
158
- properties: {
159
- i: { type: 'string' },
160
- d: wrtcDtlsParametersSchema,
161
- },
162
- required: [ 'i', 'd' ],
163
- additionalProperties: false,
164
- };
165
-
166
- const wrtcDataChannelSchema: JSONSchemaType<WrtcDataChannel> = {
167
- type: 'object',
168
- properties: {
169
- i: { type: 'string', nullable: true },
170
- pi: { type: 'string', nullable: true },
171
- l: { type: 'string' },
172
- s: wrtcSctpStreamParametersSchema,
173
- },
174
- required: [ 'l', 's' ],
175
- additionalProperties: false,
4
+ i?: string; // connection id | server -> client | on initial WS connection
5
+ k?: boolean; // kill connection | server -> client | tells client to close connection & not reconnect
6
+ ts?: string; // transport secret | server -> client | used by the client to upgrade to a WebTransport connection
176
7
  };
177
8
 
178
9
  export const connectionSchema: JSONSchemaType<ConnectionSchema> = {
@@ -180,11 +11,7 @@ export const connectionSchema: JSONSchemaType<ConnectionSchema> = {
180
11
  properties: {
181
12
  i: { type: 'string', nullable: true },
182
13
  k: { type: 'boolean', nullable: true },
183
- c: { ...wrtcTransportConnectSchema, nullable: true },
184
- ca: { ...wrtcConnectAckSchema, nullable: true },
185
- d: { type: 'array', items: { ...wrtcDataChannelSchema }, nullable: true },
186
- pa: { ...wrtcProduceDataAckSchema, nullable: true },
187
- t: { type: 'array', items: { ...wrtcTransportSchema }, nullable: true },
14
+ ts: { type: 'string', nullable: true },
188
15
  },
189
16
  additionalProperties: false,
190
17
  };
package/schemas/Input.ts CHANGED
@@ -38,6 +38,7 @@ export type InputSchema = {
38
38
  mr?: boolean; // mouse right pressed
39
39
  cp?: number; // camera pitch radians
40
40
  cy?: number; // camera yaw radians
41
+ jd?: number; // joystick direction radians
41
42
  sq?: number; // sequence number for UDP inputs
42
43
  }
43
44
 
@@ -81,6 +82,7 @@ export const inputSchema: JSONSchemaType<InputSchema> = {
81
82
  mr: { type: 'boolean', nullable: true },
82
83
  cp: { type: 'number', nullable: true },
83
84
  cy: { type: 'number', nullable: true },
85
+ jd: { type: 'number', nullable: true },
84
86
  sq: { type: 'number', nullable: true },
85
87
  },
86
88
  additionalProperties: false,