@hytopia.com/server-protocol 1.4.20 → 1.4.22-webtransport

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.20",
3
+ "version": "1.4.22-webtransport",
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",
@@ -41,6 +41,7 @@ export enum PacketId {
41
41
  LIGHTS = 44,
42
42
  PLAYERS = 45,
43
43
  PARTICLE_EMITTERS = 46,
44
+ NOTIFICATION_PERMISSION_REQUEST = 47,
44
45
 
45
46
  // Standard Bi-Directional Packet Types: 116 - 127 range
46
47
  CONNECTION = 116,
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { notificationPermissionRequestSchema } from '../../schemas/NotificationPermissionRequest';
4
+ import type { NotificationPermissionRequestSchema } from '../../schemas/NotificationPermissionRequest';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type NotificationPermissionRequestPacket = IPacket<typeof PacketId.NOTIFICATION_PERMISSION_REQUEST, NotificationPermissionRequestSchema> & [WorldTick];
8
+
9
+ export const notificationPermissionRequestPacketDefinition = definePacket(
10
+ PacketId.NOTIFICATION_PERMISSION_REQUEST,
11
+ notificationPermissionRequestSchema,
12
+ );
@@ -6,6 +6,7 @@ export * from './ChatMessages';
6
6
  export * from './Chunks';
7
7
  export * from './Entities';
8
8
  export * from './Lights';
9
+ export * from './NotificationPermissionRequest';
9
10
  export * from './ParticleEmitters';
10
11
  export * from './PhysicsDebugRender';
11
12
  export * from './PhysicsDebugRaycasts';
@@ -1,190 +1,23 @@
1
- import * as mediasoup from 'mediasoup';
2
1
  import { JSONSchemaType } from 'ajv';
3
2
 
4
3
  /**
5
4
  * Types
6
5
  */
7
6
 
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
7
  export type ConnectionSchema = {
39
8
  i?: string; // connection id | server -> client | on initial WS connection
40
9
  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
10
  };
47
11
 
48
12
  /**
49
13
  * Schemas
50
14
  */
51
15
 
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,
176
- };
177
-
178
16
  export const connectionSchema: JSONSchemaType<ConnectionSchema> = {
179
17
  type: 'object',
180
18
  properties: {
181
19
  i: { type: 'string', nullable: true },
182
20
  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 },
188
21
  },
189
22
  additionalProperties: false,
190
23
  };
@@ -0,0 +1,8 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+
3
+ export type NotificationPermissionRequestSchema = null;
4
+
5
+ export const notificationPermissionRequestSchema: JSONSchemaType<NotificationPermissionRequestSchema> = {
6
+ type: 'null',
7
+ nullable: true,
8
+ }
package/schemas/index.ts CHANGED
@@ -19,6 +19,7 @@ export * from './Input';
19
19
  export * from './Light';
20
20
  export * from './Lights';
21
21
  export * from './ModelNodeOverride';
22
+ export * from './NotificationPermissionRequest';
22
23
  export * from './ParticleEmitter';
23
24
  export * from './ParticleEmitters';
24
25
  export * from './PhysicsDebugRaycast';