@lodestar/utils 1.13.0-dev.faa4514532 → 1.13.0-rc.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/lib/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export * from "./sleep.js";
15
15
  export * from "./sort.js";
16
16
  export * from "./timeout.js";
17
17
  export { type RecursivePartial, bnToNum } from "./types.js";
18
- export * from "./validation.js";
18
+ export * from "./url.js";
19
19
  export * from "./verifyMerkleBranch.js";
20
20
  export * from "./promise.js";
21
21
  export * from "./waitFor.js";
package/lib/index.js CHANGED
@@ -15,7 +15,7 @@ export * from "./sleep.js";
15
15
  export * from "./sort.js";
16
16
  export * from "./timeout.js";
17
17
  export { bnToNum } from "./types.js";
18
- export * from "./validation.js";
18
+ export * from "./url.js";
19
19
  export * from "./verifyMerkleBranch.js";
20
20
  export * from "./promise.js";
21
21
  export * from "./waitFor.js";
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAoB,MAAM,YAAY,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAwB,OAAO,EAAC,MAAM,YAAY,CAAC;AAC1D,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,KAAK,EAAoB,MAAM,YAAY,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAwB,OAAO,EAAC,MAAM,YAAY,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
package/lib/url.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare function isValidHttpUrl(urlStr: string): boolean;
2
+ /**
3
+ * Sanitize URL to prevent leaking user credentials in logs
4
+ *
5
+ * Note: `urlStr` must be a valid URL
6
+ */
7
+ export declare function toSafePrintableUrl(urlStr: string): string;
8
+ //# sourceMappingURL=url.d.ts.map
package/lib/url.js ADDED
@@ -0,0 +1,28 @@
1
+ export function isValidHttpUrl(urlStr) {
2
+ let url;
3
+ try {
4
+ url = new URL(urlStr);
5
+ // `new URL` encodes the username/password with the userinfo percent-encode set.
6
+ // This means the `%` character is not encoded, but others are (such as `=`).
7
+ // If a username/password contain a `%`, they will not be able to be decoded.
8
+ //
9
+ // Make sure that we can successfully decode the username and password here.
10
+ //
11
+ // Unfortunately this means we don't accept every character supported by RFC-3986.
12
+ decodeURIComponent(url.username);
13
+ decodeURIComponent(url.password);
14
+ }
15
+ catch (_) {
16
+ return false;
17
+ }
18
+ return url.protocol === "http:" || url.protocol === "https:";
19
+ }
20
+ /**
21
+ * Sanitize URL to prevent leaking user credentials in logs
22
+ *
23
+ * Note: `urlStr` must be a valid URL
24
+ */
25
+ export function toSafePrintableUrl(urlStr) {
26
+ return new URL(urlStr).origin;
27
+ }
28
+ //# sourceMappingURL=url.js.map
package/lib/url.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,GAAG,CAAC;IACR,IAAI;QACF,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAEtB,gFAAgF;QAChF,6EAA6E;QAC7E,6EAA6E;QAC7E,EAAE;QACF,4EAA4E;QAC5E,EAAE;QACF,kFAAkF;QAClF,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;KAClC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AAChC,CAAC"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.13.0-dev.faa4514532",
14
+ "version": "1.13.0-rc.0",
15
15
  "type": "module",
16
16
  "exports": "./lib/index.js",
17
17
  "files": [
@@ -55,5 +55,5 @@
55
55
  "beacon",
56
56
  "blockchain"
57
57
  ],
58
- "gitHead": "b06bf05b1e36d78c78978a523496f8521bff5f38"
58
+ "gitHead": "85272e1c2061251617465232f9173ddd171c1d6b"
59
59
  }
@@ -1,2 +0,0 @@
1
- export declare function isValidHttpUrl(urlStr: string): boolean;
2
- //# sourceMappingURL=validation.d.ts.map
package/lib/validation.js DELETED
@@ -1,11 +0,0 @@
1
- export function isValidHttpUrl(urlStr) {
2
- let url;
3
- try {
4
- url = new URL(urlStr);
5
- }
6
- catch (_) {
7
- return false;
8
- }
9
- return url.protocol === "http:" || url.protocol === "https:";
10
- }
11
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,GAAG,CAAC;IACR,IAAI;QACF,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;KACvB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC/D,CAAC"}