@naturalcycles/nodejs-lib 13.27.0 → 13.28.1

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.
@@ -31,21 +31,13 @@ function sha256AsBuffer(s) {
31
31
  return hashAsBuffer(s, 'sha256');
32
32
  }
33
33
  function hash(s, algorithm, outputEncoding = 'hex') {
34
- // todo: cleanup after @types/node is updated
35
34
  // https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#crypto-implement-cryptohash
36
- // Node 20.12+
37
- if (node_crypto_1.default.hash) {
38
- return node_crypto_1.default.hash(algorithm, s, outputEncoding);
39
- }
40
- return node_crypto_1.default.createHash(algorithm).update(s).digest(outputEncoding);
35
+ // Note: crypto.hash is Node 20.12+
36
+ return node_crypto_1.default.hash(algorithm, s, outputEncoding);
41
37
  }
42
38
  function hashAsBuffer(s, algorithm) {
43
- // todo: cleanup after @types/node is updated
44
- // Node 20.12+
45
- if (node_crypto_1.default.hash) {
46
- return node_crypto_1.default.hash(algorithm, s, 'buffer');
47
- }
48
- return node_crypto_1.default.createHash(algorithm).update(s).digest();
39
+ // Note: crypto.hash is Node 20.12+
40
+ return node_crypto_1.default.hash(algorithm, s, 'buffer');
49
41
  }
50
42
  function base64(s) {
51
43
  return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64');
@@ -6,7 +6,7 @@ const fs2_1 = require("../fs/fs2");
6
6
  const git_util_1 = require("./git.util");
7
7
  function generateBuildInfo(opt = {}) {
8
8
  const now = js_lib_1.localTime.orNow(opt.overrideTimestamp);
9
- const ts = now.unix();
9
+ const ts = now.unix;
10
10
  const rev = (0, git_util_1.gitCurrentCommitSha)();
11
11
  const branchName = (0, git_util_1.gitCurrentBranchName)();
12
12
  const repoName = (0, git_util_1.gitCurrentRepoName)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.27.0",
3
+ "version": "13.28.1",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "docs-serve": "vuepress dev docs",
@@ -14,7 +14,7 @@
14
14
  "json2env-debug": "tsn ./src/bin/json2env.ts ./src/test/someFile.json"
15
15
  },
16
16
  "dependencies": {
17
- "@naturalcycles/js-lib": "^14.0.0",
17
+ "@naturalcycles/js-lib": "^14.244.0",
18
18
  "@types/js-yaml": "^4.0.9",
19
19
  "@types/jsonwebtoken": "^9.0.0",
20
20
  "@types/through2-concurrent": "^2.0.0",
@@ -68,7 +68,7 @@
68
68
  "url": "https://github.com/NaturalCycles/nodejs-lib"
69
69
  },
70
70
  "engines": {
71
- "node": ">=18.12.0"
71
+ "node": ">=20.12.0"
72
72
  },
73
73
  "description": "Standard library for Node.js",
74
74
  "author": "Natural Cycles Team",
@@ -22,24 +22,14 @@ export function hash(
22
22
  algorithm: string,
23
23
  outputEncoding: BinaryToTextEncoding = 'hex',
24
24
  ): string {
25
- // todo: cleanup after @types/node is updated
26
25
  // https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#crypto-implement-cryptohash
27
- // Node 20.12+
28
- if ((crypto as any).hash) {
29
- return (crypto as any).hash(algorithm, s, outputEncoding)
30
- }
31
-
32
- return crypto.createHash(algorithm).update(s).digest(outputEncoding)
26
+ // Note: crypto.hash is Node 20.12+
27
+ return crypto.hash(algorithm, s, outputEncoding)
33
28
  }
34
29
 
35
30
  export function hashAsBuffer(s: string | Buffer, algorithm: string): Buffer {
36
- // todo: cleanup after @types/node is updated
37
- // Node 20.12+
38
- if ((crypto as any).hash) {
39
- return (crypto as any).hash(algorithm, s, 'buffer')
40
- }
41
-
42
- return crypto.createHash(algorithm).update(s).digest()
31
+ // Note: crypto.hash is Node 20.12+
32
+ return crypto.hash(algorithm, s, 'buffer')
43
33
  }
44
34
 
45
35
  export function base64(s: string | Buffer): Base64String {
@@ -22,7 +22,7 @@ export interface GenerateBuildInfoOptions {
22
22
 
23
23
  export function generateBuildInfo(opt: GenerateBuildInfoOptions = {}): BuildInfo {
24
24
  const now = localTime.orNow(opt.overrideTimestamp)
25
- const ts = now.unix()
25
+ const ts = now.unix
26
26
 
27
27
  const rev = gitCurrentCommitSha()
28
28
  const branchName = gitCurrentBranchName()