From 57f38d5d768142c536fafc8860f6fe70869c74f5 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sun, 13 Mar 2022 14:15:57 -0700 Subject: [PATCH] update api-dingus dependency --- package-lock.json | 99 ++++++++++++++++++++++++++++----------------- package.json | 2 +- src/service.js | 45 +++++---------------- test/src/service.js | 14 ------- 4 files changed, 75 insertions(+), 85 deletions(-) diff --git a/package-lock.json b/package-lock.json index 352a433..e80ea48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -315,16 +315,16 @@ } }, "@eslint/eslintrc": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.0.tgz", - "integrity": "sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", + "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^9.3.1", "globals": "^13.9.0", - "ignore": "^4.0.6", + "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.0.4", @@ -337,12 +337,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -500,8 +494,8 @@ "dev": true }, "@squeep/api-dingus": { - "version": "git+https://git.squeep.com/squeep-api-dingus/#0ebfbe2181ce363e13d8b6fd10c9703897d5306f", - "from": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.4", + "version": "git+https://git.squeep.com/squeep-api-dingus/#12568946a94e853c3c16974d57dd34de1ad3877c", + "from": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.5", "requires": { "mime-db": "^1.51.0", "uuid": "^8.3.2" @@ -526,9 +520,22 @@ "node-linux-pam": "^0.2.1" }, "dependencies": { + "@squeep/api-dingus": { + "version": "git+https://git.squeep.com/squeep-api-dingus/#0ebfbe2181ce363e13d8b6fd10c9703897d5306f", + "from": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.4", + "requires": { + "mime-db": "^1.51.0", + "uuid": "^8.3.2" + } + }, "@squeep/html-template-helper": { "version": "git+https://git.squeep.com/squeep-html-template-helper#5506e8de3b9c93e2ec2d37d71134eee8ee5fd27c", "from": "git+https://git.squeep.com/squeep-html-template-helper#v1.0.2" + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" } } }, @@ -720,9 +727,9 @@ "optional": true }, "axios": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.0.tgz", - "integrity": "sha512-lKoGLMYtHvFrPVt3r+RBMp9nh34N0M8zEfCWqdWZx6phynIEhQqAdydpyBAAG211zlhX9Rgu08cOamy6XjE5Og==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "requires": { "follow-redirects": "^1.14.8" } @@ -881,9 +888,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001243", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001243.tgz", - "integrity": "sha512-vNxw9mkTBtkmLFnJRv/2rhs1yufpDfCkBZexG3Y0xdOH2Z/eE/85E4Dl5j1YUN34nZVsSp6vVRFQRrez9wJMRA==", + "version": "1.0.30001315", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001315.tgz", + "integrity": "sha512-5v7LFQU4Sb/qvkz7JcZkvtSH1Ko+1x2kgo3ocdBeMGZSOFpuE1kkm0kpTwLtWeFrw5qw08ulLxJjVIXIS8MkiQ==", "dev": true }, "chalk": { @@ -1256,12 +1263,12 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "eslint": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.10.0.tgz", - "integrity": "sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz", + "integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.2.0", + "@eslint/eslintrc": "^1.2.1", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -1582,9 +1589,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.8", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", - "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==" + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" }, "foreground-child": { "version": "2.0.0", @@ -2234,9 +2241,9 @@ } }, "mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" }, "mimic-response": { "version": "3.1.0", @@ -2289,9 +2296,9 @@ "optional": true }, "mocha": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.1.tgz", - "integrity": "sha512-T7uscqjJVS46Pq1XDXyo9Uvey9gd3huT/DD9cYBb4K2Xc/vbKRPUWK067bxDQRK0yIz6Jxk73IrnimvASzBNAQ==", + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", + "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", @@ -2307,9 +2314,9 @@ "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "3.0.4", + "minimatch": "4.2.1", "ms": "2.1.3", - "nanoid": "3.2.0", + "nanoid": "3.3.1", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -2361,6 +2368,17 @@ "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } } }, "has-flag": { @@ -2378,6 +2396,15 @@ "argparse": "^2.0.1" } }, + "minimatch": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", + "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, "ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2412,9 +2439,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", + "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", "dev": true }, "napi-build-utils": { diff --git a/package.json b/package.json index b70dbc4..59d5097 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "coverage-check" ], "dependencies": { - "@squeep/api-dingus": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.4", + "@squeep/api-dingus": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.5", "@squeep/authentication-module": "git+https://git.squeep.com/squeep-authentication-module/#v1.2.0", "@squeep/html-template-helper": "git+https://git.squeep.com/squeep-html-template-helper#v1.0.3", "@squeep/web-linking": "git+https://git.squeep.com/squeep-web-linking/#v1.0.3", diff --git a/src/service.js b/src/service.js index df89401..cfed60c 100644 --- a/src/service.js +++ b/src/service.js @@ -69,24 +69,6 @@ class Service extends Dingus { } - /** - * Wrap the Dingus head handler, to remove the response body from the context, - * lest it be logged. - * @param {http.ClientRequest} req - * @param {http.ServerResponse} res - * @param {object} ctx - */ - static setHeadHandler(req, res, ctx) { - if (req.method === 'HEAD') { - Dingus.setHeadHandler(req, res, ctx); - const origEnd = res.end.bind(res); - res.end = function (data, encoding, ...rest) { - const origResult = origEnd(data, encoding, ...rest); - delete ctx.responseBody; - return origResult; - }; - } - } /** * @param {http.ClientRequest} req @@ -116,7 +98,7 @@ class Service extends Dingus { ]; this.logger.debug(_scope, 'called', { req: common.requestLogData(req), ctx }); - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(responseTypes, req, res, ctx); @@ -135,7 +117,7 @@ class Service extends Dingus { const _scope = _fileScope('handlerGetHealthcheck'); this.logger.debug(_scope, 'called', { req: common.requestLogData(req), ctx }); - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(this.responseTypes, req, res, ctx); @@ -154,7 +136,7 @@ class Service extends Dingus { const responseTypes = [...this.responseTypes, Enum.ContentType.ImageSVG]; - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(responseTypes, req, res, ctx); @@ -168,7 +150,7 @@ class Service extends Dingus { const responseTypes = [Enum.ContentType.ImageSVG]; - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(responseTypes, req, res, ctx); @@ -185,7 +167,7 @@ class Service extends Dingus { const _scope = _fileScope('handlerGetAdminOverview'); this.logger.debug(_scope, 'called', { req: common.requestLogData(req), ctx }); - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(this.responseTypes, req, res, ctx); @@ -204,7 +186,7 @@ class Service extends Dingus { const _scope = _fileScope('handlerGetAdminTopicDetails'); this.logger.debug(_scope, 'called', { req: common.requestLogData(req), ctx }); - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(this.responseTypes, req, res, ctx); @@ -215,20 +197,15 @@ class Service extends Dingus { /** - * Similar to super.ingestBody, but if no body was sent, do not parse (and - * thus avoid possible unsupported media type error). - * Also removes raw body from context, to simplify scrubbing sensitive data from logs. + * If no body was sent, do not parse (and thus avoid possible unsupported media type error). * @param {http.ClientRequest} req * @param {http.ServerResponse} res * @param {Object} ctx */ async maybeIngestBody(req, res, ctx) { - ctx.rawBody = await this.bodyData(req); - const contentType = Dingus.getRequestContentType(req); - if (ctx.rawBody) { - this.parseBody(contentType, ctx); - delete ctx.rawBody; - } + return super.ingestBody(req, res, ctx, { + parseEmptyBody: false, + }); } @@ -297,7 +274,7 @@ class Service extends Dingus { const _scope = _fileScope('handlerGetAdminLogin'); this.logger.debug(_scope, 'called', { req: common.requestLogData(req), ctx }); - Service.setHeadHandler(req, res, ctx); + Dingus.setHeadHandler(req, res, ctx); this.setResponseType(this.responseTypes, req, res, ctx); diff --git a/test/src/service.js b/test/src/service.js index bc74ff5..9afaf13 100644 --- a/test/src/service.js +++ b/test/src/service.js @@ -61,20 +61,6 @@ describe('Service', function () { }); }); // maybeIngestBody - describe('setHeadHandler', function () { - it('covers', function () { - const origEnd = res.end; - sinon.stub(Service.__proto__, 'setHeadHandler'); - ctx.responseBody = 'data'; - req.method = 'HEAD'; - Service.setHeadHandler(req, res, ctx); - res.end('foop'); - assert(Service.__proto__.setHeadHandler.called); - assert(origEnd.called); - assert(!('responseBody' in ctx)); - }); - }); // setHeadHandler - describe('handlerPostRoot', function () { it('covers public mode', async function () { await service.handlerPostRoot(req, res, ctx); -- 2.45.2