Skip to content

Commit 04e7e1c

Browse files
committed
deps: @npmcli/[email protected].
1 parent 90d2aab commit 04e7e1c

File tree

8 files changed

+74
-22
lines changed

8 files changed

+74
-22
lines changed

DEPENDENCIES.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ graph LR;
523523
npm-->p-map;
524524
npm-->pacote;
525525
npm-->parse-conflict-json;
526-
npm-->postcss-selector-parser;
527526
npm-->proc-log;
528527
npm-->qrcode-terminal;
529528
npm-->read;

node_modules/@npmcli/redact/lib/deep-map.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
function filterError (input) {
2-
return {
3-
errorType: input.name,
4-
message: input.message,
5-
stack: input.stack,
6-
...(input.code ? { code: input.code } : {}),
7-
...(input.statusCode ? { statusCode: input.statusCode } : {}),
8-
}
9-
}
1+
const { serializeError } = require('./error')
102

113
const deepMap = (input, handler = v => v, path = ['$'], seen = new Set([input])) => {
124
// this is in an effort to maintain bole's error logging behavior
135
if (path.join('.') === '$' && input instanceof Error) {
14-
return deepMap({ err: filterError(input) }, handler, path, seen)
6+
return deepMap({ err: serializeError(input) }, handler, path, seen)
157
}
168
if (input instanceof Error) {
17-
return deepMap(filterError(input), handler, path, seen)
9+
return deepMap(serializeError(input), handler, path, seen)
1810
}
19-
if (input instanceof Buffer) {
11+
// allows for non-node js environments, sush as workers
12+
if (typeof Buffer !== 'undefined' && input instanceof Buffer) {
2013
return `[unable to log instanceof buffer]`
2114
}
2215
if (input instanceof Uint8Array) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/** takes an error object and serializes it to a plan object */
2+
function serializeError (input) {
3+
if (!(input instanceof Error)) {
4+
if (typeof input === 'string') {
5+
const error = new Error(`attempted to serialize a non-error, string String, "${input}"`)
6+
return serializeError(error)
7+
}
8+
const error = new Error(`attempted to serialize a non-error, ${typeof input} ${input?.constructor?.name}`)
9+
return serializeError(error)
10+
}
11+
// different error objects store status code differently
12+
// AxiosError uses `status`, other services use `statusCode`
13+
const statusCode = input.statusCode ?? input.status
14+
// CAUTION: what we serialize here gets add to the size of logs
15+
return {
16+
errorType: input.errorType ?? input.constructor.name,
17+
...(input.message ? { message: input.message } : {}),
18+
...(input.stack ? { stack: input.stack } : {}),
19+
// think of this as error code
20+
...(input.code ? { code: input.code } : {}),
21+
// think of this as http status code
22+
...(statusCode ? { statusCode } : {}),
23+
}
24+
}
25+
26+
module.exports = {
27+
serializeError,
28+
}

node_modules/@npmcli/redact/lib/matchers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ const DEEP_HEADER_SET_COOKIE = {
4444
replacement: '[REDACTED_HEADER_SET_COOKIE]',
4545
}
4646

47+
const DEEP_HEADER_COOKIE = {
48+
type: TYPE_PATH,
49+
predicate: ({ path }) => path.endsWith('.headers.cookie'),
50+
replacement: '[REDACTED_HEADER_COOKIE]',
51+
}
52+
4753
const REWRITE_REQUEST = {
4854
type: TYPE_PATH,
4955
predicate: ({ path }) => path.endsWith('.request'),
@@ -76,6 +82,7 @@ module.exports = {
7682
URL_MATCHER,
7783
DEEP_HEADER_AUTHORIZATION,
7884
DEEP_HEADER_SET_COOKIE,
85+
DEEP_HEADER_COOKIE,
7986
REWRITE_REQUEST,
8087
REWRITE_RESPONSE,
8188
}

node_modules/@npmcli/redact/lib/server.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
DEEP_HEADER_SET_COOKIE,
77
REWRITE_REQUEST,
88
REWRITE_RESPONSE,
9+
DEEP_HEADER_COOKIE,
910
} = require('./matchers')
1011

1112
const {
@@ -14,6 +15,8 @@ const {
1415
redactMatchers,
1516
} = require('./utils')
1617

18+
const { serializeError } = require('./error')
19+
1720
const { deepMap } = require('./deep-map')
1821

1922
const _redact = redactMatchers(
@@ -22,6 +25,7 @@ const _redact = redactMatchers(
2225
JSON_WEB_TOKEN,
2326
DEEP_HEADER_AUTHORIZATION,
2427
DEEP_HEADER_SET_COOKIE,
28+
DEEP_HEADER_COOKIE,
2529
REWRITE_REQUEST,
2630
REWRITE_RESPONSE,
2731
redactUrlMatcher(
@@ -31,4 +35,25 @@ const _redact = redactMatchers(
3135

3236
const redact = (input) => deepMap(input, (value, path) => _redact(value, { path }))
3337

34-
module.exports = { redact }
38+
/** takes an error returns new error keeping some custom properties */
39+
function redactError (input) {
40+
const { message, ...data } = serializeError(input)
41+
const output = new Error(redact(message))
42+
return Object.assign(output, redact(data))
43+
}
44+
45+
/** runs a function within try / catch and throws error wrapped in redactError */
46+
function redactThrow (func) {
47+
if (typeof func !== 'function') {
48+
throw new Error('redactThrow expects a function')
49+
}
50+
return async (...args) => {
51+
try {
52+
return await func(...args)
53+
} catch (error) {
54+
throw redactError(error)
55+
}
56+
}
57+
}
58+
59+
module.exports = { redact, redactError, redactThrow }

node_modules/@npmcli/redact/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/redact",
3-
"version": "3.0.0",
3+
"version": "3.2.2",
44
"description": "Redact sensitive npm information from output",
55
"main": "lib/index.js",
66
"exports": {
@@ -31,7 +31,7 @@
3131
},
3232
"templateOSS": {
3333
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
34-
"version": "4.23.3",
34+
"version": "4.24.3",
3535
"publish": true
3636
},
3737
"tap": {
@@ -43,7 +43,7 @@
4343
},
4444
"devDependencies": {
4545
"@npmcli/eslint-config": "^5.0.0",
46-
"@npmcli/template-oss": "4.23.3",
46+
"@npmcli/template-oss": "4.24.3",
4747
"tap": "^16.3.10"
4848
},
4949
"engines": {

package-lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@npmcli/map-workspaces": "^4.0.2",
9494
"@npmcli/package-json": "^6.2.0",
9595
"@npmcli/promise-spawn": "^8.0.2",
96-
"@npmcli/redact": "^3.0.0",
96+
"@npmcli/redact": "^3.2.2",
9797
"@npmcli/run-script": "^9.0.1",
9898
"@sigstore/tuf": "^3.0.0",
9999
"abbrev": "^3.0.0",
@@ -1789,9 +1789,9 @@
17891789
}
17901790
},
17911791
"node_modules/@npmcli/redact": {
1792-
"version": "3.0.0",
1793-
"resolved": "https://registry.npmjs.org/@npmcli/redact/-/redact-3.0.0.tgz",
1794-
"integrity": "sha512-/1uFzjVcfzqrgCeGW7+SZ4hv0qLWmKXVzFahZGJ6QuJBj6Myt9s17+JL86i76NV9YSnJRcGXJYQbAU0rn1YTCQ==",
1792+
"version": "3.2.2",
1793+
"resolved": "https://registry.npmjs.org/@npmcli/redact/-/redact-3.2.2.tgz",
1794+
"integrity": "sha512-7VmYAmk4csGv08QzrDKScdzn11jHPFGyqJW39FyPgPuAp3zIaUmuCo1yxw9aGs+NEJuTGQ9Gwqpt93vtJubucg==",
17951795
"inBundle": true,
17961796
"license": "ISC",
17971797
"engines": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@npmcli/map-workspaces": "^4.0.2",
5959
"@npmcli/package-json": "^6.2.0",
6060
"@npmcli/promise-spawn": "^8.0.2",
61-
"@npmcli/redact": "^3.0.0",
61+
"@npmcli/redact": "^3.2.2",
6262
"@npmcli/run-script": "^9.0.1",
6363
"@sigstore/tuf": "^3.0.0",
6464
"abbrev": "^3.0.0",

0 commit comments

Comments
 (0)