@rpgjs/server 5.0.0-alpha.41 → 5.0.0-alpha.43

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/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { i as isMapUpdateAuthorized, M as MAP_UPDATE_TOKEN_HEADER, a as MAP_UPDATE_TOKEN_ENV } from './map-D4T2_hc-.js';
2
+
1
3
  function dset(obj, keys, val) {
2
4
  keys.split && (keys=keys.split('.'));
3
5
  var i=0, l=keys.length, t=obj, x, k;
@@ -27940,7 +27942,17 @@ const MapUpdateSchema = object({
27940
27942
  /** Width of the map in pixels (required) */
27941
27943
  width: number(),
27942
27944
  /** Height of the map in pixels (required) */
27943
- height: number()
27945
+ height: number(),
27946
+ /** Map events to spawn (optional) */
27947
+ events: array(any()).optional(),
27948
+ /** Optional static hitboxes (custom maps) */
27949
+ hitboxes: array(any()).optional(),
27950
+ /** Parsed tiled map payload (optional) */
27951
+ parsedMap: any().optional(),
27952
+ /** Raw map source payload (optional) */
27953
+ data: any().optional(),
27954
+ /** Optional map params payload */
27955
+ params: any().optional()
27944
27956
  });
27945
27957
  const SAFE_MAP_WIDTH = 1e3;
27946
27958
  const SAFE_MAP_HEIGHT = 1e3;
@@ -28624,6 +28636,17 @@ let RpgMap = class extends RpgCommonMap {
28624
28636
  return await BaseRoom.prototype.listSaveSlots(player, value);
28625
28637
  }
28626
28638
  async updateMap(request) {
28639
+ if (!isMapUpdateAuthorized(request.headers)) {
28640
+ return new Response(JSON.stringify({
28641
+ error: "Unauthorized map update",
28642
+ message: `Provide ${MAP_UPDATE_TOKEN_HEADER} or Authorization: Bearer <token> to call /map/update when ${MAP_UPDATE_TOKEN_ENV} is set.`
28643
+ }), {
28644
+ status: 401,
28645
+ headers: {
28646
+ "Content-Type": "application/json"
28647
+ }
28648
+ });
28649
+ }
28627
28650
  const map = await request.json();
28628
28651
  this.data.set(map);
28629
28652
  this.globalConfig = map.config;