@minecraft/server-net 1.0.0-beta.1.26.3-stable → 1.0.0-beta.1.26.30-preview.21

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.
Files changed (3) hide show
  1. package/README.md +8 -8
  2. package/index.d.ts +455 -49
  3. package/package.json +20 -20
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # `@minecraft/server-net`
2
-
3
- The `@minecraft/server-net` module contains types for executing HTTP-based requests. This module can only be used on Bedrock Dedicated Server. These APIs do not function within the Minecraft game client or within Minecraft Realms.
4
-
5
- ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
6
-
7
- See full documentation for this module here:
8
-
1
+ # `@minecraft/server-net`
2
+
3
+ The `@minecraft/server-net` module contains types for executing HTTP-based requests. This module can only be used on Bedrock Dedicated Server. These APIs do not function within the Minecraft game client or within Minecraft Realms.
4
+
5
+ ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
6
+
7
+ See full documentation for this module here:
8
+
9
9
  https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-net/minecraft-server-net
package/index.d.ts CHANGED
@@ -51,6 +51,14 @@ export enum HttpRequestMethod {
51
51
  *
52
52
  */
53
53
  Head = 'Head',
54
+ /**
55
+ * @remarks
56
+ * Represents the method for an HTTP PATCH request. PATCH
57
+ * requests are commonly used to apply partial modifications to
58
+ * a resource.
59
+ *
60
+ */
61
+ Patch = 'Patch',
54
62
  /**
55
63
  * @remarks
56
64
  * Represents the method for an HTTP POST request. POST
@@ -69,6 +77,73 @@ export enum HttpRequestMethod {
69
77
  Put = 'Put',
70
78
  }
71
79
 
80
+ export enum HttpStatusCode {
81
+ Continue = 100,
82
+ SwitchingProtocols = 101,
83
+ Processing = 102,
84
+ OK = 200,
85
+ Created = 201,
86
+ Accepted = 202,
87
+ NonAuthoritativeInformation = 203,
88
+ NoContent = 204,
89
+ ResetContent = 205,
90
+ PartialContent = 206,
91
+ MultiStatus = 207,
92
+ AlreadyReported = 208,
93
+ IMUsed = 226,
94
+ MultipleChoices = 300,
95
+ MovedPermanently = 301,
96
+ Found = 302,
97
+ SeeOther = 303,
98
+ NotModified = 304,
99
+ UseProxy = 305,
100
+ TemporaryRedirect = 307,
101
+ PermanentRedirect = 308,
102
+ BadRequest = 400,
103
+ Unauthorized = 401,
104
+ PaymentRequired = 402,
105
+ Forbidden = 403,
106
+ NotFound = 404,
107
+ MethodNotAllowed = 405,
108
+ NotAcceptable = 406,
109
+ ProxyAuthenticationRequired = 407,
110
+ RequestTimeout = 408,
111
+ Conflict = 409,
112
+ Gone = 410,
113
+ LengthRequired = 411,
114
+ PreconditionFailed = 412,
115
+ PayloadTooLarge = 413,
116
+ RequestURITooLong = 414,
117
+ UnsupportedMediaType = 415,
118
+ RequestedRangeNotSatisfiable = 416,
119
+ ExpectationFailed = 417,
120
+ MisdirectedRequest = 421,
121
+ UnprocessableEntity = 422,
122
+ Locked = 423,
123
+ FailedDependency = 424,
124
+ TooEarly = 425,
125
+ UpgradeRequired = 426,
126
+ PreconditionRequired = 428,
127
+ TooManyRequests = 429,
128
+ RequestHeaderFieldsTooLarge = 431,
129
+ ConnectionClosedWithoutResponse = 444,
130
+ UnavailableForLegalReasons = 451,
131
+ ClientRequestTimeout = 498,
132
+ ClientClosedRequest = 499,
133
+ InternalServerError = 500,
134
+ NotImplemented = 501,
135
+ BadGateway = 502,
136
+ ServiceUnavailable = 503,
137
+ GatewayTimeout = 504,
138
+ HttpVersionNotSupported = 505,
139
+ VariantAlsoNegotiates = 506,
140
+ InsufficientStorage = 507,
141
+ LoopDetected = 508,
142
+ NotExtended = 510,
143
+ NetworkAuthenticationRequired = 511,
144
+ NetworkConnectionTimeoutError = 599,
145
+ }
146
+
72
147
  /**
73
148
  * Represents the unique type of network packet.
74
149
  */
@@ -107,15 +182,17 @@ export enum PacketId {
107
182
  ChangeDimensionPacket = 'ChangeDimensionPacket',
108
183
  ChangeMobPropertyPacket = 'ChangeMobPropertyPacket',
109
184
  ChunkRadiusUpdatedPacket = 'ChunkRadiusUpdatedPacket',
185
+ ClientboundAttributeLayerSyncPacket = 'ClientboundAttributeLayerSyncPacket',
110
186
  ClientboundCloseFormPacket = 'ClientboundCloseFormPacket',
111
187
  ClientboundControlSchemeSetPacket = 'ClientboundControlSchemeSetPacket',
112
- ClientboundDataDrivenUICloseAllScreensPacket = 'ClientboundDataDrivenUICloseAllScreensPacket',
188
+ ClientboundDataDrivenUICloseScreenPacket = 'ClientboundDataDrivenUICloseScreenPacket',
113
189
  ClientboundDataDrivenUIReloadPacket = 'ClientboundDataDrivenUIReloadPacket',
114
190
  ClientboundDataDrivenUIShowScreenPacket = 'ClientboundDataDrivenUIShowScreenPacket',
115
191
  ClientboundDataStorePacket = 'ClientboundDataStorePacket',
116
192
  ClientboundDebugRendererPacket = 'ClientboundDebugRendererPacket',
117
193
  ClientboundMapItemDataPacket = 'ClientboundMapItemDataPacket',
118
194
  ClientboundTextureShiftPacket = 'ClientboundTextureShiftPacket',
195
+ ClientboundUpdateSoundDataPacket = 'ClientboundUpdateSoundDataPacket',
119
196
  ClientCacheBlobStatusPacket = 'ClientCacheBlobStatusPacket',
120
197
  ClientCacheMissResponsePacket = 'ClientCacheMissResponsePacket',
121
198
  ClientCacheStatusPacket = 'ClientCacheStatusPacket',
@@ -138,7 +215,6 @@ export enum PacketId {
138
215
  CreativeContentPacket = 'CreativeContentPacket',
139
216
  CurrentStructureFeaturePacket = 'CurrentStructureFeaturePacket',
140
217
  DeathInfoPacket = 'DeathInfoPacket',
141
- DebugDrawerPacket = 'DebugDrawerPacket',
142
218
  DebugInfoPacket = 'DebugInfoPacket',
143
219
  DimensionDataPacket = 'DimensionDataPacket',
144
220
  DisconnectPacket = 'DisconnectPacket',
@@ -170,6 +246,7 @@ export enum PacketId {
170
246
  LevelEventGenericPacket = 'LevelEventGenericPacket',
171
247
  LevelEventPacket = 'LevelEventPacket',
172
248
  LevelSoundEventPacket = 'LevelSoundEventPacket',
249
+ LocatorBarPacket = 'LocatorBarPacket',
173
250
  LoginPacket = 'LoginPacket',
174
251
  MapCreateLockedCopyPacket = 'MapCreateLockedCopyPacket',
175
252
  MapInfoRequestPacket = 'MapInfoRequestPacket',
@@ -192,6 +269,8 @@ export enum PacketId {
192
269
  OnScreenTextureAnimationPacket = 'OnScreenTextureAnimationPacket',
193
270
  OpenSignPacket = 'OpenSignPacket',
194
271
  PacketViolationWarningPacket = 'PacketViolationWarningPacket',
272
+ PartyChangedPacket = 'PartyChangedPacket',
273
+ PartyDestinationCookieResponsePacket = 'PartyDestinationCookieResponsePacket',
195
274
  PhotoTransferPacket = 'PhotoTransferPacket',
196
275
  PlayerActionPacket = 'PlayerActionPacket',
197
276
  PlayerArmorDamagePacket = 'PlayerArmorDamagePacket',
@@ -209,6 +288,7 @@ export enum PacketId {
209
288
  PlayStatusPacket = 'PlayStatusPacket',
210
289
  PositionTrackingDBClientRequestPacket = 'PositionTrackingDBClientRequestPacket',
211
290
  PositionTrackingDBServerBroadcastPacket = 'PositionTrackingDBServerBroadcastPacket',
291
+ PrimitiveShapesPacket = 'PrimitiveShapesPacket',
212
292
  PurchaseReceiptPacket = 'PurchaseReceiptPacket',
213
293
  RefreshEntitlementsPacket = 'RefreshEntitlementsPacket',
214
294
  RemoveActorPacket = 'RemoveActorPacket',
@@ -223,17 +303,22 @@ export enum PacketId {
223
303
  ResourcePackClientResponsePacket = 'ResourcePackClientResponsePacket',
224
304
  ResourcePackDataInfoPacket = 'ResourcePackDataInfoPacket',
225
305
  ResourcePacksInfoPacket = 'ResourcePacksInfoPacket',
306
+ ResourcePacksReadyForValidationPacket = 'ResourcePacksReadyForValidationPacket',
226
307
  ResourcePackStackPacket = 'ResourcePackStackPacket',
227
308
  RespawnPacket = 'RespawnPacket',
228
309
  ScriptMessagePacket = 'ScriptMessagePacket',
310
+ SendPartyDestinationCookiePacket = 'SendPartyDestinationCookiePacket',
311
+ ServerboundDataDrivenScreenClosedPacket = 'ServerboundDataDrivenScreenClosedPacket',
229
312
  ServerboundDataStorePacket = 'ServerboundDataStorePacket',
230
313
  ServerboundDiagnosticsPacket = 'ServerboundDiagnosticsPacket',
231
314
  ServerboundLoadingScreenPacket = 'ServerboundLoadingScreenPacket',
232
315
  ServerboundPackSettingChangePacket = 'ServerboundPackSettingChangePacket',
233
316
  ServerPlayerPostMovePositionPacket = 'ServerPlayerPostMovePositionPacket',
317
+ ServerPresenceInfoPacket = 'ServerPresenceInfoPacket',
234
318
  ServerSettingsRequestPacket = 'ServerSettingsRequestPacket',
235
319
  ServerSettingsResponsePacket = 'ServerSettingsResponsePacket',
236
320
  ServerStatsPacket = 'ServerStatsPacket',
321
+ ServerStoreInfoPacket = 'ServerStoreInfoPacket',
237
322
  ServerToClientHandshakePacket = 'ServerToClientHandshakePacket',
238
323
  SetActorDataPacket = 'SetActorDataPacket',
239
324
  SetActorLinkPacket = 'SetActorLinkPacket',
@@ -270,6 +355,7 @@ export enum PacketId {
270
355
  SubChunkRequestPacket = 'SubChunkRequestPacket',
271
356
  SubClientLoginPacket = 'SubClientLoginPacket',
272
357
  SyncActorPropertyPacket = 'SyncActorPropertyPacket',
358
+ SyncWorldClocksPacket = 'SyncWorldClocksPacket',
273
359
  TakeItemActorPacket = 'TakeItemActorPacket',
274
360
  TextPacket = 'TextPacket',
275
361
  TickingAreasLoadStatusPacket = 'TickingAreasLoadStatusPacket',
@@ -292,25 +378,65 @@ export enum PacketId {
292
378
  VoxelShapesPacket = 'VoxelShapesPacket',
293
379
  }
294
380
 
381
+ export enum WebSocketClientCloseReasons {
382
+ /**
383
+ * @remarks
384
+ * The server has closed the socket.
385
+ *
386
+ */
387
+ ClosedByServer = 0,
388
+ /**
389
+ * @remarks
390
+ * The client has closed the socket.
391
+ *
392
+ */
393
+ ClosedByClient = 1,
394
+ /**
395
+ * @remarks
396
+ * The client has received payloads whose body exceeds the
397
+ * configured maximum size allowed per tick so the client has
398
+ * closed the socket.
399
+ *
400
+ */
401
+ IncomingPayloadsTooLarge = 2,
402
+ }
403
+
404
+ export class CloseAfterEventSignal {
405
+ private constructor();
406
+ /**
407
+ * @remarks
408
+ * This function can't be called in restricted-execution mode.
409
+ *
410
+ * This function can be called in early-execution mode.
411
+ *
412
+ */
413
+ subscribe(callback: (arg0: WebSocketClientCloseAfterEvent) => void): (arg0: WebSocketClientCloseAfterEvent) => void;
414
+ /**
415
+ * @remarks
416
+ * This function can't be called in restricted-execution mode.
417
+ *
418
+ * This function can be called in early-execution mode.
419
+ *
420
+ */
421
+ unsubscribe(callback: (arg0: WebSocketClientCloseAfterEvent) => void): void;
422
+ }
423
+
295
424
  /**
296
425
  * @example simpleHttpRequest.ts
297
426
  * ```typescript
298
427
  * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
299
428
  *
300
429
  * async function updateScore() {
301
- * const req = new HttpRequest('http://localhost:3000/updateScore');
430
+ * const req = new HttpRequest('http://localhost:3000/updateScore');
302
431
  *
303
- * req.body = JSON.stringify({
304
- * score: 22,
305
- * });
432
+ * req.body = JSON.stringify({
433
+ * score: 22,
434
+ * });
306
435
  *
307
- * req.method = HttpRequestMethod.Post;
308
- * req.headers = [
309
- * new HttpHeader('Content-Type', 'application/json'),
310
- * new HttpHeader('auth', 'my-auth-token'),
311
- * ];
436
+ * req.method = HttpRequestMethod.Post;
437
+ * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')];
312
438
  *
313
- * await http.request(req);
439
+ * await http.request(req);
314
440
  * }
315
441
  * ```
316
442
  */
@@ -352,19 +478,16 @@ export class HttpClient {
352
478
  * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
353
479
  *
354
480
  * async function updateScore() {
355
- * const req = new HttpRequest('http://localhost:3000/updateScore');
481
+ * const req = new HttpRequest('http://localhost:3000/updateScore');
356
482
  *
357
- * req.body = JSON.stringify({
358
- * score: 22,
359
- * });
483
+ * req.body = JSON.stringify({
484
+ * score: 22,
485
+ * });
360
486
  *
361
- * req.method = HttpRequestMethod.Post;
362
- * req.headers = [
363
- * new HttpHeader('Content-Type', 'application/json'),
364
- * new HttpHeader('auth', 'my-auth-token'),
365
- * ];
487
+ * req.method = HttpRequestMethod.Post;
488
+ * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')];
366
489
  *
367
- * await http.request(req);
490
+ * await http.request(req);
368
491
  * }
369
492
  * ```
370
493
  */
@@ -379,19 +502,16 @@ export class HttpClient {
379
502
  * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
380
503
  *
381
504
  * async function updateScore() {
382
- * const req = new HttpRequest('http://localhost:3000/updateScore');
505
+ * const req = new HttpRequest('http://localhost:3000/updateScore');
383
506
  *
384
- * req.body = JSON.stringify({
385
- * score: 22,
386
- * });
507
+ * req.body = JSON.stringify({
508
+ * score: 22,
509
+ * });
387
510
  *
388
- * req.method = HttpRequestMethod.Post;
389
- * req.headers = [
390
- * new HttpHeader('Content-Type', 'application/json'),
391
- * new HttpHeader('auth', 'my-auth-token'),
392
- * ];
511
+ * req.method = HttpRequestMethod.Post;
512
+ * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')];
393
513
  *
394
- * await http.request(req);
514
+ * await http.request(req);
395
515
  * }
396
516
  * ```
397
517
  */
@@ -422,19 +542,16 @@ export class HttpHeader {
422
542
  * import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
423
543
  *
424
544
  * async function updateScore() {
425
- * const req = new HttpRequest('http://localhost:3000/updateScore');
545
+ * const req = new HttpRequest('http://localhost:3000/updateScore');
426
546
  *
427
- * req.body = JSON.stringify({
428
- * score: 22,
429
- * });
547
+ * req.body = JSON.stringify({
548
+ * score: 22,
549
+ * });
430
550
  *
431
- * req.method = HttpRequestMethod.Post;
432
- * req.headers = [
433
- * new HttpHeader('Content-Type', 'application/json'),
434
- * new HttpHeader('auth', 'my-auth-token'),
435
- * ];
551
+ * req.method = HttpRequestMethod.Post;
552
+ * req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', 'my-auth-token')];
436
553
  *
437
- * await http.request(req);
554
+ * await http.request(req);
438
555
  * }
439
556
  * ```
440
557
  */
@@ -518,8 +635,13 @@ export class HttpRequest {
518
635
  setMethod(method: HttpRequestMethod): HttpRequest;
519
636
  /**
520
637
  * @remarks
638
+ * Sets the maximum amount of time, in seconds, before the
639
+ * request times out and is cancelled.
640
+ *
521
641
  * This function can be called in early-execution mode.
522
642
  *
643
+ * @param timeout
644
+ * The timeout value, in seconds.
523
645
  */
524
646
  setTimeout(timeout: number): HttpRequest;
525
647
  }
@@ -559,6 +681,28 @@ export class HttpResponse {
559
681
  readonly status: number;
560
682
  }
561
683
 
684
+ export class MessageAfterEventSignal {
685
+ private constructor();
686
+ /**
687
+ * @remarks
688
+ * This function can't be called in restricted-execution mode.
689
+ *
690
+ * This function can be called in early-execution mode.
691
+ *
692
+ */
693
+ subscribe(
694
+ callback: (arg0: WebSocketClientReceiveAfterEvent) => void,
695
+ ): (arg0: WebSocketClientReceiveAfterEvent) => void;
696
+ /**
697
+ * @remarks
698
+ * This function can't be called in restricted-execution mode.
699
+ *
700
+ * This function can be called in early-execution mode.
701
+ *
702
+ */
703
+ unsubscribe(callback: (arg0: WebSocketClientReceiveAfterEvent) => void): void;
704
+ }
705
+
562
706
  export class NetworkBeforeEvents {
563
707
  private constructor();
564
708
  /**
@@ -683,6 +827,98 @@ export class PacketSendBeforeEventSignal {
683
827
  unsubscribe(callback: (arg0: PacketSendBeforeEvent) => void): void;
684
828
  }
685
829
 
830
+ /**
831
+ * Used to manage WebSocket connections.
832
+ */
833
+ export class WebSocket {
834
+ private constructor();
835
+ /**
836
+ * @remarks
837
+ * Attempts to connect a WebSocket client.
838
+ *
839
+ * This function can't be called in restricted-execution mode.
840
+ *
841
+ * @param uri
842
+ * URL to make connection to.
843
+ * @returns
844
+ * An awaitable promise that contains the WebSocket client that
845
+ * was connected.
846
+ */
847
+ connect(uri: string, headers?: HttpHeader[]): Promise<WebSocketClient>;
848
+ }
849
+
850
+ /**
851
+ * An active WebSocket client.
852
+ */
853
+ export class WebSocketClient {
854
+ private constructor();
855
+ /**
856
+ * @remarks
857
+ * Contains a set of events related to this WebSocket client.
858
+ *
859
+ */
860
+ readonly afterEvents: WebSocketClientAfterEvents;
861
+ /**
862
+ * @remarks
863
+ * Set to true if the socket is current connected to the
864
+ * server.
865
+ *
866
+ */
867
+ readonly isOpen: boolean;
868
+ /**
869
+ * @remarks
870
+ * Closes the connection with the server.
871
+ *
872
+ * This function can't be called in restricted-execution mode.
873
+ *
874
+ * @throws This function can throw errors.
875
+ *
876
+ * {@link WebSocketNotConnectedError}
877
+ */
878
+ close(): void;
879
+ /**
880
+ * @remarks
881
+ * Sends the provided payload to the server.
882
+ *
883
+ * This function can't be called in restricted-execution mode.
884
+ *
885
+ * @param payload
886
+ * The payload that will be included in the network packet.
887
+ * @throws This function can throw errors.
888
+ *
889
+ * {@link RequestBodyTooLargeError}
890
+ *
891
+ * {@link WebSocketNotConnectedError}
892
+ */
893
+ send(payload: string): void;
894
+ }
895
+
896
+ export class WebSocketClientAfterEvents {
897
+ private constructor();
898
+ /**
899
+ * @remarks
900
+ * This property can be read in early-execution mode.
901
+ *
902
+ */
903
+ readonly close: CloseAfterEventSignal;
904
+ /**
905
+ * @remarks
906
+ * This property can be read in early-execution mode.
907
+ *
908
+ */
909
+ readonly message: MessageAfterEventSignal;
910
+ }
911
+
912
+ export class WebSocketClientCloseAfterEvent {
913
+ private constructor();
914
+ readonly reason: WebSocketClientCloseReasons;
915
+ }
916
+
917
+ export class WebSocketClientReceiveAfterEvent {
918
+ private constructor();
919
+ readonly message: string;
920
+ }
921
+
686
922
  /**
687
923
  * Options for events triggered by network packets.
688
924
  */
@@ -703,6 +939,31 @@ export interface PacketEventOptions {
703
939
  monitoredPacketIds?: PacketId[];
704
940
  }
705
941
 
942
+ /**
943
+ * An error thrown when the maximum number of concurrent HTTP
944
+ * requests has been reached.
945
+ */
946
+ // @ts-ignore Class inheritance allowed for native defined classes
947
+ export class HttpRequestLimitExceededError extends Error {
948
+ private constructor();
949
+ /**
950
+ * @remarks
951
+ * Number of requests already in flight when rejected.
952
+ *
953
+ * This property can be read in early-execution mode.
954
+ *
955
+ */
956
+ readonly inFlightRequests: number;
957
+ /**
958
+ * @remarks
959
+ * Configured maximum concurrent HTTP requests.
960
+ *
961
+ * This property can be read in early-execution mode.
962
+ *
963
+ */
964
+ readonly maxConcurrentRequests: number;
965
+ }
966
+
706
967
  /**
707
968
  * An error thrown when a platform-level HTTP error occurs.
708
969
  * Information provided in this class may be useful for
@@ -714,30 +975,175 @@ export class InternalHttpRequestError extends Error {
714
975
  private constructor();
715
976
  /**
716
977
  * @remarks
717
- * The platform-provided numeric error code for the error.
978
+ * This property can be read in early-execution mode.
718
979
  *
980
+ */
981
+ readonly errorCode: number;
982
+ /**
983
+ * @remarks
719
984
  * This property can be read in early-execution mode.
720
985
  *
721
986
  */
722
- code: number;
987
+ readonly errorMessage: string;
988
+ }
989
+
990
+ /**
991
+ * An error thrown when a platform-level WebSocket error
992
+ * occurs. Information provided in this class may be useful
993
+ * for diagnostics purposes but will differ from platform to
994
+ * platform.
995
+ */
996
+ // @ts-ignore Class inheritance allowed for native defined classes
997
+ export class InternalWebSocketError extends Error {
998
+ private constructor();
723
999
  /**
724
1000
  * @remarks
725
- * The platform-provided message for the error.
1001
+ * This property can be read in early-execution mode.
726
1002
  *
1003
+ */
1004
+ readonly errorCode: number;
1005
+ /**
1006
+ * @remarks
727
1007
  * This property can be read in early-execution mode.
728
1008
  *
729
1009
  */
730
- message: string;
1010
+ readonly errorMessage: string;
1011
+ }
1012
+
1013
+ /**
1014
+ * An error thrown when a malformed URI is used.
1015
+ */
1016
+ // @ts-ignore Class inheritance allowed for native defined classes
1017
+ export class MalformedUriError extends Error {
1018
+ private constructor();
731
1019
  }
732
1020
 
733
1021
  /**
734
- * An error thrown when a malformed HTTP request is attempted
735
- * to be sent.
1022
+ * An error thrown when an network request body exceeds the
1023
+ * configured size limit.
736
1024
  */
737
1025
  // @ts-ignore Class inheritance allowed for native defined classes
738
- export class MalformedHttpRequestError extends Error {
1026
+ export class RequestBodyTooLargeError extends Error {
1027
+ private constructor();
1028
+ /**
1029
+ * @remarks
1030
+ * Configured maximum body size in bytes.
1031
+ *
1032
+ * This property can be read in early-execution mode.
1033
+ *
1034
+ */
1035
+ readonly maxBytes: number;
1036
+ /**
1037
+ * @remarks
1038
+ * Request body size in bytes.
1039
+ *
1040
+ * This property can be read in early-execution mode.
1041
+ *
1042
+ */
1043
+ readonly providedBytes: number;
1044
+ }
1045
+
1046
+ /**
1047
+ * An error thrown when secure URI scheme is required but a
1048
+ * non-secure URI was provided.
1049
+ */
1050
+ // @ts-ignore Class inheritance allowed for native defined classes
1051
+ export class TLSOnlyError extends Error {
1052
+ private constructor();
1053
+ /**
1054
+ * @remarks
1055
+ * URI that was rejected for not using secure scheme.
1056
+ *
1057
+ * This property can be read in early-execution mode.
1058
+ *
1059
+ */
1060
+ readonly uri: string;
1061
+ }
1062
+
1063
+ /**
1064
+ * An error thrown when a network request targets a URI that is
1065
+ * not in the configured allow list.
1066
+ */
1067
+ // @ts-ignore Class inheritance allowed for native defined classes
1068
+ export class UriNotAllowedError extends Error {
1069
+ private constructor();
1070
+ /**
1071
+ * @remarks
1072
+ * URI that was rejected because it is not allowed.
1073
+ *
1074
+ * This property can be read in early-execution mode.
1075
+ *
1076
+ */
1077
+ readonly uri: string;
1078
+ }
1079
+
1080
+ /**
1081
+ * An error thrown when the connection with the WebSocket
1082
+ * server has failed.
1083
+ */
1084
+ // @ts-ignore Class inheritance allowed for native defined classes
1085
+ export class WebSocketConnectionFailedError extends Error {
1086
+ private constructor();
1087
+ /**
1088
+ * @remarks
1089
+ * The error code received when attempting to connect with the
1090
+ * server.
1091
+ *
1092
+ * This property can be read in early-execution mode.
1093
+ *
1094
+ */
1095
+ readonly errorCode: HttpStatusCode;
1096
+ /**
1097
+ * @remarks
1098
+ * The URI provided to make this connection attempt that
1099
+ * failed.
1100
+ *
1101
+ * This property can be read in early-execution mode.
1102
+ *
1103
+ */
1104
+ readonly uri: string;
1105
+ }
1106
+
1107
+ /**
1108
+ * An error that is thrown when the maximum number of connected
1109
+ * WebSockets is reached.
1110
+ */
1111
+ // @ts-ignore Class inheritance allowed for native defined classes
1112
+ export class WebSocketLimitExceededError extends Error {
1113
+ private constructor();
1114
+ /**
1115
+ * @remarks
1116
+ * Number of WebSocket connections already active when
1117
+ * rejected.
1118
+ *
1119
+ * This property can be read in early-execution mode.
1120
+ *
1121
+ */
1122
+ readonly connectedSockets: number;
1123
+ /**
1124
+ * @remarks
1125
+ * Configured maximum active WebSocket connections.
1126
+ *
1127
+ * This property can be read in early-execution mode.
1128
+ *
1129
+ */
1130
+ readonly maxConcurrentConnections: number;
1131
+ }
1132
+
1133
+ /**
1134
+ * An error thrown when attempting to use a WebSocket while the
1135
+ * socket is not connected to a server.
1136
+ */
1137
+ // @ts-ignore Class inheritance allowed for native defined classes
1138
+ export class WebSocketNotConnectedError extends Error {
739
1139
  private constructor();
740
1140
  }
741
1141
 
742
1142
  export const beforeEvents: NetworkBeforeEvents;
743
1143
  export const http: HttpClient;
1144
+ /**
1145
+ * @remarks
1146
+ * Used to manage WebSocket connections.
1147
+ *
1148
+ */
1149
+ export const websocket: WebSocket;
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "name": "@minecraft/server-net",
3
- "version": "1.0.0-beta.1.26.3-stable",
4
- "description": "",
5
- "contributors": [
6
- {
7
- "name": "Jake Shirley",
8
- "email": "jake@xbox.com"
9
- },
10
- {
11
- "name": "Mike Ammerlaan",
12
- "email": "mikeam@microsoft.com"
13
- }
14
- ],
15
- "peerDependencies": {
16
- "@minecraft/common": "^1.0.0",
17
- "@minecraft/server": "^1.17.0 || ^2.0.0",
18
- "@minecraft/server-admin": "^1.0.0-beta.1.26.3-stable"
19
- },
20
- "license": "MIT"
1
+ {
2
+ "name": "@minecraft/server-net",
3
+ "version": "1.0.0-beta.1.26.30-preview.21",
4
+ "description": "",
5
+ "contributors": [
6
+ {
7
+ "name": "Jake Shirley",
8
+ "email": "jake@xbox.com"
9
+ },
10
+ {
11
+ "name": "Mike Ammerlaan",
12
+ "email": "mikeam@microsoft.com"
13
+ }
14
+ ],
15
+ "peerDependencies": {
16
+ "@minecraft/common": "^1.0.0",
17
+ "@minecraft/server": "^1.17.0 || ^2.0.0",
18
+ "@minecraft/server-admin": "^1.0.0-beta.1.26.30-preview.21"
19
+ },
20
+ "license": "MIT"
21
21
  }