@lidofinance/api-logger 0.0.2 → 0.1.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.
- package/README.md +4 -5
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# @lidofinance/api-logger
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
API logger, which hides secrets
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
2. `yarn add @lidofinance/api-logger`.
|
|
7
|
+
`yarn add @lidofinance/api-logger`
|
|
9
8
|
|
|
10
9
|
## Getting started
|
|
11
10
|
|
|
12
|
-
You just need to initialize it with secrets you want to hide, usually it's all secrets from `serverRuntimeConfig`
|
|
13
|
-
after that, you are free to use it as regular `console.log`.
|
|
11
|
+
You just need to initialize it with secrets you want to hide, usually it's all secrets from `serverRuntimeConfig` for
|
|
12
|
+
next.js, after that, you are free to use it as regular `console.log`.
|
|
14
13
|
|
|
15
14
|
```ts
|
|
16
15
|
import getConfig from 'next/config';
|
package/dist/index.cjs
CHANGED
|
@@ -27,14 +27,14 @@ var $2b0676a8d7ac44c3$exports = {};
|
|
|
27
27
|
$parcel$export($2b0676a8d7ac44c3$exports, "serverLoggerFactory", () => $2b0676a8d7ac44c3$export$937ae38af6b48c0f);
|
|
28
28
|
|
|
29
29
|
const $2b0676a8d7ac44c3$var$anyHex = new RegExp("0x[a-fA-F0-9]+", "ig");
|
|
30
|
-
const $2b0676a8d7ac44c3$var$
|
|
30
|
+
const $2b0676a8d7ac44c3$var$anyEthAddress = new RegExp("[a-zA-Z0-9.]+\\.eth", "ig");
|
|
31
31
|
let $2b0676a8d7ac44c3$var$LEVEL;
|
|
32
|
-
(function(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
(function(LEVEL) {
|
|
33
|
+
LEVEL["error"] = "error";
|
|
34
|
+
LEVEL["warn"] = "warn";
|
|
35
|
+
LEVEL["info"] = "info";
|
|
36
|
+
LEVEL["debug"] = "debug";
|
|
37
|
+
LEVEL["log"] = "log";
|
|
38
38
|
})($2b0676a8d7ac44c3$var$LEVEL || ($2b0676a8d7ac44c3$var$LEVEL = {}));
|
|
39
39
|
const $2b0676a8d7ac44c3$var$stringify = (data)=>data instanceof Error ? JSON.stringify({
|
|
40
40
|
message: data.message,
|
|
@@ -44,7 +44,7 @@ const $2b0676a8d7ac44c3$export$937ae38af6b48c0f = (secrets)=>{
|
|
|
44
44
|
const patterns = [
|
|
45
45
|
...secrets,
|
|
46
46
|
$2b0676a8d7ac44c3$var$anyHex,
|
|
47
|
-
$2b0676a8d7ac44c3$var$
|
|
47
|
+
$2b0676a8d7ac44c3$var$anyEthAddress
|
|
48
48
|
].filter(Boolean);
|
|
49
49
|
// TODO: replace not with *** but with name of masked pattern e.g. https://example.com/{INFURA_KEY}
|
|
50
50
|
const mask = (message)=>(0, ($parcel$interopDefault($dDFU1$darkobitsmaskstring)))(patterns, message);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;AAEA,MAAM,4BAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC;AACjD,MAAM,mCAAa,GAAG,IAAI,MAAM,CAAC,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;AAEA,MAAM,4BAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC;AACjD,MAAM,mCAAa,GAAG,IAAI,MAAM,CAAC,qBAAqB,EAAE,IAAI,CAAC;IAE7D,2BAMC;UANI,KAAK;IAAL,K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AAK,EAAE,GAAG,CAAC,2BAAK,CAAC,KAAK,CAAC;QACvB,GAAG,EAAE,GAAG,CAAC,2BAAK,CAAC,GAAG,CAAC;KACpB,GACD,OAAO,CAAA;CACZ;;ADvDD","sources":["packages/api/logger/src/index.ts","packages/api/logger/src/serverLoggerFactory.ts"],"sourcesContent":["export * from './serverLoggerFactory'\n","import maskString from '@darkobits/mask-string'\n\nconst anyHex = new RegExp('0x[a-fA-F0-9]+', 'ig')\nconst anyEthAddress = new RegExp('[a-zA-Z0-9.]+\\\\.eth', 'ig')\n\nenum LEVEL {\n error = 'error',\n warn = 'warn',\n info = 'info',\n debug = 'debug',\n log = 'log',\n}\n\nconst stringify = (data: unknown) =>\n data instanceof Error\n ? // extract Error's non-enumerable props before stringifying\n JSON.stringify({\n message: data.message,\n stack: data.stack,\n })\n : JSON.stringify(data)\n\nexport type Logger = (...messages: unknown[]) => void\nexport type ServerLogger = {\n error: Logger\n warn: Logger\n info: Logger\n debug: Logger\n log: Logger\n}\n\nexport const serverLoggerFactory = (secrets: Array<RegExp | string>): ServerLogger => {\n const patterns = [...secrets, anyHex, anyEthAddress].filter(Boolean)\n // TODO: replace not with *** but with name of masked pattern e.g. https://example.com/{INFURA_KEY}\n const mask = (message: string): string => maskString(patterns, message)\n\n const log =\n (level: LEVEL) =>\n (...output: unknown[]): void => {\n try {\n console[level](...output.map(stringify).map(mask))\n } catch (error) {\n console.error(error)\n console.warn('Failed to sanitize output')\n }\n }\n return process.env.NODE_ENV === 'production'\n ? {\n error: log(LEVEL.error),\n warn: log(LEVEL.warn),\n info: log(LEVEL.info),\n debug: log(LEVEL.debug),\n log: log(LEVEL.log),\n }\n : console\n}\n"],"names":[],"version":3,"file":"index.cjs.map","sourceRoot":"../../../../"}
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":"AAsBA,qBAAqB,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AACrD,2BAA2B;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,OAAO,MAAM,+BAAgC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAG,YAwBrE,CAAA","sources":["packages/api/logger/src/src/serverLoggerFactory.ts","packages/api/logger/src/src/index.ts","packages/api/logger/src/index.ts"],"sourcesContent":[null,null,"export * from './serverLoggerFactory'\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../../../"}
|
package/dist/index.mjs
CHANGED
|
@@ -8,14 +8,14 @@ var $3e685537995feb8a$exports = {};
|
|
|
8
8
|
$parcel$export($3e685537995feb8a$exports, "serverLoggerFactory", () => $3e685537995feb8a$export$937ae38af6b48c0f);
|
|
9
9
|
|
|
10
10
|
const $3e685537995feb8a$var$anyHex = new RegExp("0x[a-fA-F0-9]+", "ig");
|
|
11
|
-
const $3e685537995feb8a$var$
|
|
11
|
+
const $3e685537995feb8a$var$anyEthAddress = new RegExp("[a-zA-Z0-9.]+\\.eth", "ig");
|
|
12
12
|
let $3e685537995feb8a$var$LEVEL;
|
|
13
|
-
(function(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
(function(LEVEL) {
|
|
14
|
+
LEVEL["error"] = "error";
|
|
15
|
+
LEVEL["warn"] = "warn";
|
|
16
|
+
LEVEL["info"] = "info";
|
|
17
|
+
LEVEL["debug"] = "debug";
|
|
18
|
+
LEVEL["log"] = "log";
|
|
19
19
|
})($3e685537995feb8a$var$LEVEL || ($3e685537995feb8a$var$LEVEL = {}));
|
|
20
20
|
const $3e685537995feb8a$var$stringify = (data)=>data instanceof Error ? JSON.stringify({
|
|
21
21
|
message: data.message,
|
|
@@ -25,7 +25,7 @@ const $3e685537995feb8a$export$937ae38af6b48c0f = (secrets)=>{
|
|
|
25
25
|
const patterns = [
|
|
26
26
|
...secrets,
|
|
27
27
|
$3e685537995feb8a$var$anyHex,
|
|
28
|
-
$3e685537995feb8a$var$
|
|
28
|
+
$3e685537995feb8a$var$anyEthAddress
|
|
29
29
|
].filter(Boolean);
|
|
30
30
|
// TODO: replace not with *** but with name of masked pattern e.g. https://example.com/{INFURA_KEY}
|
|
31
31
|
const mask = (message)=>(0, $2Az7d$darkobitsmaskstring)(patterns, message);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;ACAA;AAEA,MAAM,4BAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC;AACjD,MAAM,mCAAa,GAAG,IAAI,MAAM,CAAC,
|
|
1
|
+
{"mappings":";;;;;;;;ACAA;AAEA,MAAM,4BAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC;AACjD,MAAM,mCAAa,GAAG,IAAI,MAAM,CAAC,qBAAqB,EAAE,IAAI,CAAC;IAE7D,2BAMC;UANI,KAAK;IAAL,KAAK,CACR,OAAK,IAAL,OAAK;IADF,KAAK,CAER,MAAI,IAAJ,MAAI;IAFD,KAAK,CAGR,MAAI,IAAJ,MAAI;IAHD,KAAK,CAIR,OAAK,IAAL,OAAK;IAJF,KAAK,CAKR,KAAG,IAAH,KAAG;GALA,2BAAK,KAAL,2BAAK;AAQV,MAAM,+BAAS,GAAG,CAAC,IAAa,GAC9B,IAAI,YAAY,KAAK,GAEjB,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,GACF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AAWnB,MAAM,yCAAmB,GAAG,CAAC,OAA+B,GAAmB;IACpF,MAAM,QAAQ,GAAG;WAAI,OAAO;QAAE,4BAAM;QAAE,mCAAa;KAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IACpE,mGAAmG;IACnG,MAAM,IAAI,GAAG,CAAC,OAAe,GAAa,CAAA,GAAA,0BAAU,CAAA,CAAC,QAAQ,EAAE,OAAO,CAAC;IAEvE,MAAM,GAAG,GACP,CAAC,KAAY,GACb,CAAC,GAAG,MAAM,AAAW,GAAW;YAC9B,IAAI;gBACF,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,+BAAS,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACnD,CAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC;aAC1C;SACF;IACH,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GACxC;QACE,KAAK,EAAE,GAAG,CAAC,2BAAK,CAAC,KAAK,CAAC;QACvB,IAAI,EAAE,GAAG,CAAC,2BAAK,CAAC,IAAI,CAAC;QACrB,IAAI,EAAE,GAAG,CAAC,2BAAK,CAAC,IAAI,CAAC;QACrB,KAAK,EAAE,GAAG,CAAC,2BAAK,CAAC,KAAK,CAAC;QACvB,GAAG,EAAE,GAAG,CAAC,2BAAK,CAAC,GAAG,CAAC;KACpB,GACD,OAAO,CAAA;CACZ;;ADvDD","sources":["packages/api/logger/src/index.ts","packages/api/logger/src/serverLoggerFactory.ts"],"sourcesContent":["export * from './serverLoggerFactory'\n","import maskString from '@darkobits/mask-string'\n\nconst anyHex = new RegExp('0x[a-fA-F0-9]+', 'ig')\nconst anyEthAddress = new RegExp('[a-zA-Z0-9.]+\\\\.eth', 'ig')\n\nenum LEVEL {\n error = 'error',\n warn = 'warn',\n info = 'info',\n debug = 'debug',\n log = 'log',\n}\n\nconst stringify = (data: unknown) =>\n data instanceof Error\n ? // extract Error's non-enumerable props before stringifying\n JSON.stringify({\n message: data.message,\n stack: data.stack,\n })\n : JSON.stringify(data)\n\nexport type Logger = (...messages: unknown[]) => void\nexport type ServerLogger = {\n error: Logger\n warn: Logger\n info: Logger\n debug: Logger\n log: Logger\n}\n\nexport const serverLoggerFactory = (secrets: Array<RegExp | string>): ServerLogger => {\n const patterns = [...secrets, anyHex, anyEthAddress].filter(Boolean)\n // TODO: replace not with *** but with name of masked pattern e.g. https://example.com/{INFURA_KEY}\n const mask = (message: string): string => maskString(patterns, message)\n\n const log =\n (level: LEVEL) =>\n (...output: unknown[]): void => {\n try {\n console[level](...output.map(stringify).map(mask))\n } catch (error) {\n console.error(error)\n console.warn('Failed to sanitize output')\n }\n }\n return process.env.NODE_ENV === 'production'\n ? {\n error: log(LEVEL.error),\n warn: log(LEVEL.warn),\n info: log(LEVEL.info),\n debug: log(LEVEL.debug),\n log: log(LEVEL.log),\n }\n : console\n}\n"],"names":[],"version":3,"file":"index.mjs.map","sourceRoot":"../../../../"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lidofinance/api-logger",
|
|
3
3
|
"description": "API logger, which hides secrets",
|
|
4
|
-
"repository": "git@github.com:lidofinance/
|
|
4
|
+
"repository": "git@github.com:lidofinance/warehouse.git",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0
|
|
6
|
+
"version": "0.1.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@darkobits/mask-string": "^2.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@lidofinance/config-prettier": "0.0
|
|
28
|
+
"@lidofinance/config-prettier": "~0.1.0",
|
|
29
29
|
"@types/jest": "^28.1.6",
|
|
30
30
|
"@types/node": "^18.0.6",
|
|
31
31
|
"jest": "^28.1.3",
|