@scrypted/server 0.41.0 → 0.44.0

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.

Potentially problematic release.


This version of @scrypted/server might be problematic. Click here for more details.

@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createResponseInterface = void 0;
7
- const rpc_1 = require("./rpc");
8
- const path_1 = require("path");
9
7
  const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = require("path");
9
+ const rpc_1 = require("./rpc");
10
10
  const mime = require('mime/lite');
11
11
  function createResponseInterface(res, unzippedDir, filesPath) {
12
12
  class HttpResponseImpl {
@@ -15,24 +15,26 @@ function createResponseInterface(res, unzippedDir, filesPath) {
15
15
  'sendFile',
16
16
  'sendSocket',
17
17
  ];
18
+ #setHeaders(options) {
19
+ if (!options?.headers)
20
+ return;
21
+ for (const header of Object.keys(options.headers)) {
22
+ const val = options.headers[header];
23
+ // null-ish headers will cause something to fail downstream.
24
+ if (val != null)
25
+ res.setHeader(header, val);
26
+ }
27
+ }
18
28
  send(body, options) {
19
29
  if (options?.code)
20
30
  res.status(options.code);
21
- if (options?.headers) {
22
- for (const header of Object.keys(options.headers)) {
23
- res.setHeader(header, options.headers[header]);
24
- }
25
- }
31
+ this.#setHeaders(options);
26
32
  res.send(body);
27
33
  }
28
34
  sendFile(path, options) {
29
35
  if (options?.code)
30
36
  res.status(options.code);
31
- if (options?.headers) {
32
- for (const header of Object.keys(options.headers)) {
33
- res.setHeader(header, options.headers[header]);
34
- }
35
- }
37
+ this.#setHeaders(options);
36
38
  if (!res.getHeader('Content-Type')) {
37
39
  const type = mime.getType(path);
38
40
  if (type) {
@@ -59,11 +61,7 @@ function createResponseInterface(res, unzippedDir, filesPath) {
59
61
  sendSocket(socket, options) {
60
62
  if (options?.code)
61
63
  res.status(options.code);
62
- if (options?.headers) {
63
- for (const header of Object.keys(options.headers)) {
64
- res.setHeader(header, options.headers[header]);
65
- }
66
- }
64
+ this.#setHeaders(options);
67
65
  socket.pipe(res);
68
66
  }
69
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http-interfaces.js","sourceRoot":"","sources":["../src/http-interfaces.ts"],"names":[],"mappings":";;;;;;AAEA,+BAAgC;AAChC,+BAAwC;AACxC,4CAAoB;AAGpB,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAElC,SAAgB,uBAAuB,CAAC,GAAa,EAAE,WAAmB,EAAE,SAAiB;IACzF,MAAM,gBAAgB;QAClB,CAAC,aAAO,CAAC,6BAA6B,CAAC,GAAG;YACtC,MAAM;YACN,UAAU;YACV,YAAY;SACf,CAAC;QAMF,IAAI,CAAC,IAAS,EAAE,OAAa;YACzB,IAAI,OAAO,EAAE,IAAI;gBACb,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,OAAO,EAAE,OAAO,EAAE;gBAClB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;oBAC/C,GAAG,CAAC,SAAS,CAAC,MAAM,EAAG,OAAO,CAAC,OAAe,CAAC,MAAM,CAAC,CAAC,CAAC;iBAC3D;aACJ;YAED,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAID,QAAQ,CAAC,IAAS,EAAE,OAA6B;YAC7C,IAAI,OAAO,EAAE,IAAI;gBACb,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,OAAO,EAAE,OAAO,EAAE;gBAClB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;oBAC/C,GAAG,CAAC,SAAS,CAAC,MAAM,EAAG,OAAO,CAAC,OAAe,CAAC,MAAM,CAAC,CAAC,CAAC;iBAC3D;aACJ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
3
+ "version": "0.44.0",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@mapbox/node-pre-gyp": "^1.0.11",
@@ -10,15 +10,15 @@
10
10
  "body-parser": "^1.20.2",
11
11
  "cookie-parser": "^1.4.6",
12
12
  "debug": "^4.3.4",
13
- "engine.io": "^6.5.1",
13
+ "engine.io": "^6.5.2",
14
14
  "express": "^4.18.2",
15
- "ffmpeg-static": "^5.1.0",
15
+ "ffmpeg-static": "^5.2.0",
16
16
  "http-auth": "^4.2.0",
17
17
  "ip": "^1.1.8",
18
18
  "level": "^8.0.0",
19
19
  "linkfs": "^2.1.0",
20
20
  "lodash": "^4.17.21",
21
- "memfs": "^4.2.0",
21
+ "memfs": "^4.2.1",
22
22
  "mime": "^3.0.0",
23
23
  "nan": "^2.17.0",
24
24
  "node-dijkstra": "^2.5.0",
@@ -28,7 +28,7 @@
28
28
  "semver": "^7.5.4",
29
29
  "source-map-support": "^0.5.21",
30
30
  "tar": "^6.1.15",
31
- "tslib": "^2.6.1",
31
+ "tslib": "^2.6.2",
32
32
  "typescript": "^5.1.6",
33
33
  "whatwg-mimetype": "^3.0.0",
34
34
  "ws": "^8.13.0"
@@ -40,10 +40,10 @@
40
40
  "@types/express": "^4.17.17",
41
41
  "@types/http-auth": "^4.1.1",
42
42
  "@types/ip": "^1.1.0",
43
- "@types/lodash": "^4.14.196",
43
+ "@types/lodash": "^4.14.197",
44
44
  "@types/mime": "^3.0.1",
45
45
  "@types/node-dijkstra": "^2.5.3",
46
- "@types/node-forge": "^1.3.3",
46
+ "@types/node-forge": "^1.3.4",
47
47
  "@types/pem": "^1.14.0",
48
48
  "@types/semver": "^7.5.0",
49
49
  "@types/source-map-support": "^0.5.6",
@@ -1,9 +1,9 @@
1
1
  import { HttpResponse, HttpResponseOptions } from "@scrypted/types";
2
2
  import { Response } from "express";
3
- import { RpcPeer } from "./rpc";
4
- import { join as pathJoin } from 'path';
5
3
  import fs from 'fs';
6
4
  import net from 'net';
5
+ import { join as pathJoin } from 'path';
6
+ import { RpcPeer } from "./rpc";
7
7
 
8
8
  const mime = require('mime/lite');
9
9
 
@@ -15,6 +15,17 @@ export function createResponseInterface(res: Response, unzippedDir: string, file
15
15
  'sendSocket',
16
16
  ];
17
17
 
18
+ #setHeaders(options?: HttpResponseOptions) {
19
+ if (!options?.headers)
20
+ return;
21
+ for (const header of Object.keys(options.headers)) {
22
+ const val = (options.headers as any)[header];
23
+ // null-ish headers will cause something to fail downstream.
24
+ if (val != null)
25
+ res.setHeader(header, val);
26
+ }
27
+ }
28
+
18
29
  send(body: string): void;
19
30
  send(body: string, options: HttpResponseOptions): void;
20
31
  send(body: Buffer): void;
@@ -22,11 +33,7 @@ export function createResponseInterface(res: Response, unzippedDir: string, file
22
33
  send(body: any, options?: any) {
23
34
  if (options?.code)
24
35
  res.status(options.code);
25
- if (options?.headers) {
26
- for (const header of Object.keys(options.headers)) {
27
- res.setHeader(header, (options.headers as any)[header]);
28
- }
29
- }
36
+ this.#setHeaders(options);
30
37
 
31
38
  res.send(body);
32
39
  }
@@ -36,11 +43,7 @@ export function createResponseInterface(res: Response, unzippedDir: string, file
36
43
  sendFile(path: any, options?: HttpResponseOptions) {
37
44
  if (options?.code)
38
45
  res.status(options.code);
39
- if (options?.headers) {
40
- for (const header of Object.keys(options.headers)) {
41
- res.setHeader(header, (options.headers as any)[header]);
42
- }
43
- }
46
+ this.#setHeaders(options);
44
47
 
45
48
  if (!res.getHeader('Content-Type')) {
46
49
  const type = mime.getType(path);
@@ -71,11 +74,7 @@ export function createResponseInterface(res: Response, unzippedDir: string, file
71
74
  sendSocket(socket: net.Socket, options: HttpResponseOptions) {
72
75
  if (options?.code)
73
76
  res.status(options.code);
74
- if (options?.headers) {
75
- for (const header of Object.keys(options.headers)) {
76
- res.setHeader(header, (options.headers as any)[header]);
77
- }
78
- }
77
+ this.#setHeaders(options);
79
78
  socket.pipe(res);
80
79
  }
81
80
  }