@naturalcycles/nodejs-lib 13.45.3 → 14.0.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/dist/bin/generate-build-info.js +15 -18
- package/dist/bin/json2env.js +6 -9
- package/dist/bin/kpy.js +6 -9
- package/dist/bin/secrets-decrypt.d.ts +1 -1
- package/dist/bin/secrets-decrypt.js +9 -12
- package/dist/bin/secrets-encrypt.d.ts +1 -1
- package/dist/bin/secrets-encrypt.js +9 -12
- package/dist/bin/secrets-gen-key.js +8 -11
- package/dist/bin/slack-this.js +6 -9
- package/dist/buffer/buffer.util.js +1 -4
- package/dist/colors/colors.d.ts +26 -27
- package/dist/colors/colors.js +29 -33
- package/dist/csv/csvReader.js +4 -8
- package/dist/csv/csvWriter.js +7 -12
- package/dist/csv/transformToCSV.d.ts +2 -2
- package/dist/csv/transformToCSV.js +5 -8
- package/dist/diff/tableDiff.js +4 -7
- package/dist/fs/fs2.d.ts +1 -1
- package/dist/fs/fs2.js +88 -94
- package/dist/fs/json2env.js +18 -28
- package/dist/fs/kpy.js +28 -33
- package/dist/index.d.ts +71 -71
- package/dist/index.js +73 -78
- package/dist/infra/process.util.js +23 -28
- package/dist/jwt/jwt.service.js +17 -21
- package/dist/log/log.util.js +4 -7
- package/dist/script/runScript.js +11 -15
- package/dist/secret/secrets-decrypt.util.js +18 -22
- package/dist/secret/secrets-encrypt.util.js +17 -21
- package/dist/security/crypto.util.js +24 -34
- package/dist/security/hash.util.js +19 -37
- package/dist/security/id.util.js +11 -18
- package/dist/security/nanoid.js +15 -20
- package/dist/security/secret.util.js +20 -30
- package/dist/slack/slack.service.d.ts +1 -1
- package/dist/slack/slack.service.js +13 -16
- package/dist/slack/slack.service.model.d.ts +1 -1
- package/dist/slack/slack.service.model.js +1 -2
- package/dist/stream/ndjson/ndjson.model.js +10 -16
- package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonMap.js +11 -14
- package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonStreamForEach.js +9 -12
- package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
- package/dist/stream/ndjson/transformJsonParse.js +4 -9
- package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
- package/dist/stream/ndjson/transformToNDJson.js +5 -8
- package/dist/stream/pipeline/pipeline.js +13 -17
- package/dist/stream/progressLogger.d.ts +1 -1
- package/dist/stream/progressLogger.js +32 -28
- package/dist/stream/readable/readableCreate.d.ts +1 -1
- package/dist/stream/readable/readableCreate.js +5 -9
- package/dist/stream/readable/readableForEach.d.ts +2 -2
- package/dist/stream/readable/readableForEach.js +7 -11
- package/dist/stream/readable/readableFromArray.d.ts +1 -1
- package/dist/stream/readable/readableFromArray.js +4 -7
- package/dist/stream/readable/readableToArray.d.ts +1 -1
- package/dist/stream/readable/readableToArray.js +1 -4
- package/dist/stream/sizeStack.js +9 -12
- package/dist/stream/stream.model.js +1 -2
- package/dist/stream/stream.util.js +1 -4
- package/dist/stream/transform/transformChunk.d.ts +1 -1
- package/dist/stream/transform/transformChunk.js +3 -6
- package/dist/stream/transform/transformFilter.d.ts +2 -2
- package/dist/stream/transform/transformFilter.js +6 -10
- package/dist/stream/transform/transformLimit.d.ts +2 -2
- package/dist/stream/transform/transformLimit.js +6 -11
- package/dist/stream/transform/transformLogProgress.d.ts +2 -2
- package/dist/stream/transform/transformLogProgress.js +5 -8
- package/dist/stream/transform/transformMap.d.ts +1 -1
- package/dist/stream/transform/transformMap.js +18 -22
- package/dist/stream/transform/transformMapSimple.d.ts +1 -1
- package/dist/stream/transform/transformMapSimple.js +6 -9
- package/dist/stream/transform/transformMapSync.d.ts +3 -3
- package/dist/stream/transform/transformMapSync.js +14 -19
- package/dist/stream/transform/transformNoOp.d.ts +1 -1
- package/dist/stream/transform/transformNoOp.js +3 -6
- package/dist/stream/transform/transformOffset.d.ts +1 -1
- package/dist/stream/transform/transformOffset.js +5 -8
- package/dist/stream/transform/transformSplit.d.ts +1 -1
- package/dist/stream/transform/transformSplit.js +5 -9
- package/dist/stream/transform/transformTap.d.ts +1 -1
- package/dist/stream/transform/transformTap.js +3 -6
- package/dist/stream/transform/transformTee.d.ts +1 -1
- package/dist/stream/transform/transformTee.js +7 -10
- package/dist/stream/transform/transformThrottle.d.ts +1 -1
- package/dist/stream/transform/transformThrottle.js +9 -12
- package/dist/stream/transform/transformToArray.d.ts +1 -1
- package/dist/stream/transform/transformToArray.js +3 -6
- package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
- package/dist/stream/transform/worker/baseWorkerClass.js +2 -5
- package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
- package/dist/stream/transform/worker/transformMultiThreaded.js +12 -11
- package/dist/stream/transform/worker/transformMultiThreaded.model.js +1 -2
- package/dist/stream/transform/worker/workerClassProxy.js +6 -4
- package/dist/stream/writable/writableForEach.d.ts +2 -2
- package/dist/stream/writable/writableForEach.js +6 -10
- package/dist/stream/writable/writableFork.d.ts +1 -1
- package/dist/stream/writable/writableFork.js +6 -9
- package/dist/stream/writable/writableLimit.d.ts +1 -1
- package/dist/stream/writable/writableLimit.js +3 -6
- package/dist/stream/writable/writablePushToArray.d.ts +1 -1
- package/dist/stream/writable/writablePushToArray.js +3 -6
- package/dist/stream/writable/writableVoid.d.ts +1 -1
- package/dist/stream/writable/writableVoid.js +3 -6
- package/dist/string/inspect.js +8 -13
- package/dist/util/buildInfo.util.js +12 -15
- package/dist/util/env.util.js +5 -9
- package/dist/util/exec2.js +17 -21
- package/dist/util/git2.js +17 -20
- package/dist/util/lruMemoCache.js +4 -7
- package/dist/util/zip.util.js +14 -25
- package/dist/validation/ajv/ajv.util.d.ts +3 -3
- package/dist/validation/ajv/ajv.util.js +6 -10
- package/dist/validation/ajv/ajvSchema.d.ts +2 -2
- package/dist/validation/ajv/ajvSchema.js +17 -18
- package/dist/validation/ajv/ajvValidationError.js +2 -6
- package/dist/validation/ajv/getAjv.d.ts +1 -1
- package/dist/validation/ajv/getAjv.js +9 -9
- package/dist/validation/joi/joi.extensions.d.ts +2 -2
- package/dist/validation/joi/joi.extensions.js +6 -10
- package/dist/validation/joi/joi.model.js +1 -2
- package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
- package/dist/validation/joi/joi.shared.schemas.js +61 -74
- package/dist/validation/joi/joi.validation.error.js +2 -6
- package/dist/validation/joi/joi.validation.util.d.ts +1 -1
- package/dist/validation/joi/joi.validation.util.js +10 -17
- package/dist/validation/joi/number.extensions.js +1 -4
- package/dist/validation/joi/string.extensions.js +4 -7
- package/dist/yargs.util.js +5 -8
- package/package.json +5 -4
- package/src/bin/generate-build-info.ts +3 -3
- package/src/bin/json2env.ts +2 -2
- package/src/bin/kpy.ts +2 -2
- package/src/bin/secrets-decrypt.ts +7 -8
- package/src/bin/secrets-encrypt.ts +7 -8
- package/src/bin/secrets-gen-key.ts +2 -2
- package/src/bin/slack-this.ts +2 -2
- package/src/csv/transformToCSV.ts +3 -3
- package/src/fs/fs2.ts +4 -4
- package/src/fs/json2env.ts +2 -2
- package/src/fs/kpy.ts +2 -2
- package/src/index.ts +71 -71
- package/src/jwt/jwt.service.ts +2 -2
- package/src/log/log.util.ts +1 -1
- package/src/script/runScript.ts +4 -3
- package/src/secret/secrets-decrypt.util.ts +3 -3
- package/src/secret/secrets-encrypt.util.ts +3 -3
- package/src/security/crypto.util.ts +1 -1
- package/src/security/id.util.ts +1 -1
- package/src/security/secret.util.ts +2 -2
- package/src/slack/slack.service.model.ts +1 -1
- package/src/slack/slack.service.ts +3 -3
- package/src/stream/ndjson/ndjson.model.ts +1 -1
- package/src/stream/ndjson/ndjsonMap.ts +2 -2
- package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
- package/src/stream/ndjson/transformJsonParse.ts +1 -1
- package/src/stream/ndjson/transformToNDJson.ts +1 -1
- package/src/stream/pipeline/pipeline.ts +1 -1
- package/src/stream/progressLogger.ts +3 -3
- package/src/stream/readable/readableCreate.ts +1 -1
- package/src/stream/readable/readableForEach.ts +4 -4
- package/src/stream/readable/readableFromArray.ts +1 -1
- package/src/stream/readable/readableToArray.ts +1 -1
- package/src/stream/sizeStack.ts +2 -2
- package/src/stream/transform/transformChunk.ts +1 -1
- package/src/stream/transform/transformFilter.ts +3 -3
- package/src/stream/transform/transformLimit.ts +3 -3
- package/src/stream/transform/transformLogProgress.ts +3 -3
- package/src/stream/transform/transformMap.ts +5 -5
- package/src/stream/transform/transformMapSimple.ts +1 -1
- package/src/stream/transform/transformMapSync.ts +5 -5
- package/src/stream/transform/transformNoOp.ts +1 -1
- package/src/stream/transform/transformOffset.ts +2 -2
- package/src/stream/transform/transformSplit.ts +1 -1
- package/src/stream/transform/transformTap.ts +1 -1
- package/src/stream/transform/transformTee.ts +3 -3
- package/src/stream/transform/transformThrottle.ts +1 -1
- package/src/stream/transform/transformToArray.ts +1 -1
- package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
- package/src/stream/transform/worker/transformMultiThreaded.ts +8 -3
- package/src/stream/transform/worker/workerClassProxy.js +6 -4
- package/src/stream/writable/writableForEach.ts +3 -3
- package/src/stream/writable/writableFork.ts +3 -3
- package/src/stream/writable/writableLimit.ts +1 -1
- package/src/stream/writable/writablePushToArray.ts +1 -1
- package/src/stream/writable/writableVoid.ts +1 -1
- package/src/util/buildInfo.util.ts +2 -2
- package/src/util/exec2.ts +1 -1
- package/src/util/git2.ts +2 -2
- package/src/validation/ajv/ajv.util.ts +4 -4
- package/src/validation/ajv/ajvSchema.ts +4 -5
- package/src/validation/ajv/getAjv.ts +7 -3
- package/src/validation/joi/joi.extensions.ts +4 -4
- package/src/validation/joi/joi.shared.schemas.ts +3 -3
- package/src/validation/joi/joi.validation.util.ts +2 -2
- package/src/yargs.util.ts +1 -0
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
|
-
const colors_1 = require("../colors/colors");
|
|
9
|
-
const index_1 = require("../index");
|
|
10
|
-
const crypto_util_1 = require("../security/crypto.util");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { _assert } from '@naturalcycles/js-lib';
|
|
4
|
+
import { dimGrey, yellow } from '../colors/colors.js';
|
|
5
|
+
import { fastGlob, fs2 } from '../index.js';
|
|
6
|
+
import { encryptObject, encryptRandomIVBuffer } from '../security/crypto.util.js';
|
|
11
7
|
/**
|
|
12
8
|
* Encrypts all files in given directory (except *.enc), saves encrypted versions as filename.ext.enc.
|
|
13
9
|
* Using provided encKey.
|
|
14
10
|
*/
|
|
15
|
-
function secretsEncrypt(pattern, file, encKeyBuffer, del = false, jsonMode = false) {
|
|
11
|
+
export function secretsEncrypt(pattern, file, encKeyBuffer, del = false, jsonMode = false) {
|
|
16
12
|
const patterns = file
|
|
17
13
|
? [file]
|
|
18
14
|
: [
|
|
19
15
|
...pattern,
|
|
20
16
|
`!**/*.enc`, // excluding already encoded
|
|
21
17
|
];
|
|
22
|
-
const filenames =
|
|
18
|
+
const filenames = fastGlob.sync(patterns);
|
|
23
19
|
let encFilename;
|
|
24
20
|
filenames.forEach(filename => {
|
|
25
21
|
if (jsonMode) {
|
|
26
|
-
|
|
22
|
+
_assert(filename.endsWith('.plain.json'), `${path.basename(filename)} MUST end with '.plain.json'`);
|
|
27
23
|
encFilename = filename.replace('.plain', '');
|
|
28
|
-
const json =
|
|
29
|
-
|
|
24
|
+
const json = encryptObject(fs2.readJson(filename), encKeyBuffer);
|
|
25
|
+
fs2.writeJson(encFilename, json, { spaces: 2 });
|
|
30
26
|
}
|
|
31
27
|
else {
|
|
32
|
-
const plain =
|
|
33
|
-
const enc =
|
|
28
|
+
const plain = fs.readFileSync(filename);
|
|
29
|
+
const enc = encryptRandomIVBuffer(plain, encKeyBuffer);
|
|
34
30
|
encFilename = `${filename}.enc`;
|
|
35
|
-
|
|
31
|
+
fs.writeFileSync(encFilename, enc);
|
|
36
32
|
}
|
|
37
33
|
if (del) {
|
|
38
|
-
|
|
34
|
+
fs.unlinkSync(filename);
|
|
39
35
|
}
|
|
40
|
-
console.log(` ${
|
|
36
|
+
console.log(` ${path.basename(filename)} > ${path.basename(encFilename)}`);
|
|
41
37
|
});
|
|
42
|
-
console.log(`encrypted ${
|
|
38
|
+
console.log(`encrypted ${yellow(filenames.length)} files in (${dimGrey(pattern.join(' '))})`);
|
|
43
39
|
}
|
|
@@ -1,49 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.decryptRandomIVBuffer = decryptRandomIVBuffer;
|
|
5
|
-
exports.decryptObject = decryptObject;
|
|
6
|
-
exports.encryptObject = encryptObject;
|
|
7
|
-
exports.decryptString = decryptString;
|
|
8
|
-
exports.encryptString = encryptString;
|
|
9
|
-
exports.timingSafeStringEqual = timingSafeStringEqual;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
12
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
13
|
-
const hash_util_1 = require("./hash.util");
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { _stringMapEntries } from '@naturalcycles/js-lib';
|
|
3
|
+
import { md5AsBuffer, sha256AsBuffer } from './hash.util.js';
|
|
14
4
|
const algorithm = 'aes-256-cbc';
|
|
15
5
|
/**
|
|
16
6
|
* Using aes-256-cbc.
|
|
17
7
|
*/
|
|
18
|
-
function encryptRandomIVBuffer(input, secretKeyBuffer) {
|
|
8
|
+
export function encryptRandomIVBuffer(input, secretKeyBuffer) {
|
|
19
9
|
// sha256 to match aes-256 key length
|
|
20
|
-
const key =
|
|
10
|
+
const key = sha256AsBuffer(secretKeyBuffer);
|
|
21
11
|
// Random iv to achieve non-deterministic encryption (but deterministic decryption)
|
|
22
|
-
const iv =
|
|
23
|
-
const cipher =
|
|
12
|
+
const iv = crypto.randomBytes(16);
|
|
13
|
+
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
|
24
14
|
return Buffer.concat([iv, cipher.update(input), cipher.final()]);
|
|
25
15
|
}
|
|
26
16
|
/**
|
|
27
17
|
* Using aes-256-cbc.
|
|
28
18
|
*/
|
|
29
|
-
function decryptRandomIVBuffer(input, secretKeyBuffer) {
|
|
19
|
+
export function decryptRandomIVBuffer(input, secretKeyBuffer) {
|
|
30
20
|
// sha256 to match aes-256 key length
|
|
31
|
-
const key =
|
|
21
|
+
const key = sha256AsBuffer(secretKeyBuffer);
|
|
32
22
|
// iv is first 16 bytes of encrypted buffer, the rest is payload
|
|
33
23
|
const iv = input.subarray(0, 16);
|
|
34
24
|
const payload = input.subarray(16);
|
|
35
|
-
const decipher =
|
|
25
|
+
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
|
36
26
|
return Buffer.concat([decipher.update(payload), decipher.final()]);
|
|
37
27
|
}
|
|
38
28
|
/**
|
|
39
29
|
* Decrypts all object values (base64 strings).
|
|
40
30
|
* Returns object with decrypted values (utf8 strings).
|
|
41
31
|
*/
|
|
42
|
-
function decryptObject(obj, secretKeyBuffer) {
|
|
32
|
+
export function decryptObject(obj, secretKeyBuffer) {
|
|
43
33
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
44
34
|
const r = {};
|
|
45
|
-
|
|
46
|
-
const decipher =
|
|
35
|
+
_stringMapEntries(obj).forEach(([k, v]) => {
|
|
36
|
+
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
|
47
37
|
r[k] = decipher.update(v, 'base64', 'utf8') + decipher.final('utf8');
|
|
48
38
|
});
|
|
49
39
|
return r;
|
|
@@ -52,11 +42,11 @@ function decryptObject(obj, secretKeyBuffer) {
|
|
|
52
42
|
* Encrypts all object values (utf8 strings).
|
|
53
43
|
* Returns object with encrypted values (base64 strings).
|
|
54
44
|
*/
|
|
55
|
-
function encryptObject(obj, secretKeyBuffer) {
|
|
45
|
+
export function encryptObject(obj, secretKeyBuffer) {
|
|
56
46
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
57
47
|
const r = {};
|
|
58
|
-
|
|
59
|
-
const cipher =
|
|
48
|
+
_stringMapEntries(obj).forEach(([k, v]) => {
|
|
49
|
+
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
|
60
50
|
r[k] = cipher.update(v, 'utf8', 'base64') + cipher.final('base64');
|
|
61
51
|
});
|
|
62
52
|
return r;
|
|
@@ -67,9 +57,9 @@ function encryptObject(obj, secretKeyBuffer) {
|
|
|
67
57
|
* Input is base64 string.
|
|
68
58
|
* Output is utf8 string.
|
|
69
59
|
*/
|
|
70
|
-
function decryptString(str, secretKeyBuffer) {
|
|
60
|
+
export function decryptString(str, secretKeyBuffer) {
|
|
71
61
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
72
|
-
const decipher =
|
|
62
|
+
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
|
73
63
|
return decipher.update(str, 'base64', 'utf8') + decipher.final('utf8');
|
|
74
64
|
}
|
|
75
65
|
/**
|
|
@@ -78,14 +68,14 @@ function decryptString(str, secretKeyBuffer) {
|
|
|
78
68
|
* Input is utf8 string.
|
|
79
69
|
* Output is base64 string.
|
|
80
70
|
*/
|
|
81
|
-
function encryptString(str, secretKeyBuffer) {
|
|
71
|
+
export function encryptString(str, secretKeyBuffer) {
|
|
82
72
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
83
|
-
const cipher =
|
|
73
|
+
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
|
84
74
|
return cipher.update(str, 'utf8', 'base64') + cipher.final('base64');
|
|
85
75
|
}
|
|
86
76
|
function getCryptoParams(secretKeyBuffer) {
|
|
87
|
-
const key =
|
|
88
|
-
const iv =
|
|
77
|
+
const key = sha256AsBuffer(secretKeyBuffer);
|
|
78
|
+
const iv = md5AsBuffer(Buffer.concat([secretKeyBuffer, key]));
|
|
89
79
|
return { key, iv };
|
|
90
80
|
}
|
|
91
81
|
/**
|
|
@@ -100,8 +90,8 @@ function getCryptoParams(secretKeyBuffer) {
|
|
|
100
90
|
*
|
|
101
91
|
* Returns true if inputs are equal, false otherwise.
|
|
102
92
|
*/
|
|
103
|
-
function timingSafeStringEqual(s1, s2) {
|
|
93
|
+
export function timingSafeStringEqual(s1, s2) {
|
|
104
94
|
if (s1 === undefined || s2 === undefined || s1.length !== s2.length)
|
|
105
95
|
return false;
|
|
106
|
-
return
|
|
96
|
+
return crypto.timingSafeEqual(Buffer.from(s1), Buffer.from(s2));
|
|
107
97
|
}
|
|
@@ -1,67 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.md5 = md5;
|
|
4
|
-
exports.md5AsBuffer = md5AsBuffer;
|
|
5
|
-
exports.sha256 = sha256;
|
|
6
|
-
exports.sha256AsBuffer = sha256AsBuffer;
|
|
7
|
-
exports.hash = hash;
|
|
8
|
-
exports.hashAsBuffer = hashAsBuffer;
|
|
9
|
-
exports.base64 = base64;
|
|
10
|
-
exports.base64Url = base64Url;
|
|
11
|
-
exports.base64ToString = base64ToString;
|
|
12
|
-
exports.base64UrlToString = base64UrlToString;
|
|
13
|
-
exports.base64ToBuffer = base64ToBuffer;
|
|
14
|
-
exports.base64UrlToBuffer = base64UrlToBuffer;
|
|
15
|
-
exports.stringToBase64 = stringToBase64;
|
|
16
|
-
exports.stringToBase64Url = stringToBase64Url;
|
|
17
|
-
exports.bufferToBase64 = bufferToBase64;
|
|
18
|
-
exports.bufferToBase64Url = bufferToBase64Url;
|
|
19
|
-
const node_crypto_1 = require("node:crypto");
|
|
20
|
-
function md5(s, outputEncoding = 'hex') {
|
|
1
|
+
import { hash as cryptoHash } from 'node:crypto';
|
|
2
|
+
export function md5(s, outputEncoding = 'hex') {
|
|
21
3
|
return hash(s, 'md5', outputEncoding);
|
|
22
4
|
}
|
|
23
|
-
function md5AsBuffer(s) {
|
|
5
|
+
export function md5AsBuffer(s) {
|
|
24
6
|
return hashAsBuffer(s, 'md5');
|
|
25
7
|
}
|
|
26
|
-
function sha256(s, outputEncoding = 'hex') {
|
|
8
|
+
export function sha256(s, outputEncoding = 'hex') {
|
|
27
9
|
return hash(s, 'sha256', outputEncoding);
|
|
28
10
|
}
|
|
29
|
-
function sha256AsBuffer(s) {
|
|
11
|
+
export function sha256AsBuffer(s) {
|
|
30
12
|
return hashAsBuffer(s, 'sha256');
|
|
31
13
|
}
|
|
32
|
-
function hash(s, algorithm, outputEncoding = 'hex') {
|
|
33
|
-
return (
|
|
14
|
+
export function hash(s, algorithm, outputEncoding = 'hex') {
|
|
15
|
+
return cryptoHash(algorithm, s, outputEncoding);
|
|
34
16
|
}
|
|
35
|
-
function hashAsBuffer(s, algorithm) {
|
|
36
|
-
return (
|
|
17
|
+
export function hashAsBuffer(s, algorithm) {
|
|
18
|
+
return cryptoHash(algorithm, s, 'buffer');
|
|
37
19
|
}
|
|
38
|
-
function base64(s) {
|
|
20
|
+
export function base64(s) {
|
|
39
21
|
return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64');
|
|
40
22
|
}
|
|
41
|
-
function base64Url(s) {
|
|
23
|
+
export function base64Url(s) {
|
|
42
24
|
return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64url');
|
|
43
25
|
}
|
|
44
|
-
function base64ToString(strBase64) {
|
|
26
|
+
export function base64ToString(strBase64) {
|
|
45
27
|
return Buffer.from(strBase64, 'base64').toString('utf8');
|
|
46
28
|
}
|
|
47
|
-
function base64UrlToString(strBase64Url) {
|
|
29
|
+
export function base64UrlToString(strBase64Url) {
|
|
48
30
|
return Buffer.from(strBase64Url, 'base64url').toString('utf8');
|
|
49
31
|
}
|
|
50
|
-
function base64ToBuffer(strBase64) {
|
|
32
|
+
export function base64ToBuffer(strBase64) {
|
|
51
33
|
return Buffer.from(strBase64, 'base64');
|
|
52
34
|
}
|
|
53
|
-
function base64UrlToBuffer(strBase64Url) {
|
|
35
|
+
export function base64UrlToBuffer(strBase64Url) {
|
|
54
36
|
return Buffer.from(strBase64Url, 'base64url');
|
|
55
37
|
}
|
|
56
|
-
function stringToBase64(s) {
|
|
38
|
+
export function stringToBase64(s) {
|
|
57
39
|
return Buffer.from(s, 'utf8').toString('base64');
|
|
58
40
|
}
|
|
59
|
-
function stringToBase64Url(s) {
|
|
41
|
+
export function stringToBase64Url(s) {
|
|
60
42
|
return Buffer.from(s, 'utf8').toString('base64url');
|
|
61
43
|
}
|
|
62
|
-
function bufferToBase64(b) {
|
|
44
|
+
export function bufferToBase64(b) {
|
|
63
45
|
return b.toString('base64');
|
|
64
46
|
}
|
|
65
|
-
function bufferToBase64Url(b) {
|
|
47
|
+
export function bufferToBase64Url(b) {
|
|
66
48
|
return b.toString('base64url');
|
|
67
49
|
}
|
package/dist/security/id.util.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.stringIdBase62 = void 0;
|
|
4
|
-
exports.stringId = stringId;
|
|
5
|
-
exports.stringIdBase64 = stringIdBase64;
|
|
6
|
-
exports.stringIdBase64Url = stringIdBase64Url;
|
|
7
|
-
exports.stringIdNonAmbiguous = stringIdNonAmbiguous;
|
|
8
|
-
const node_crypto_1 = require("node:crypto");
|
|
9
|
-
const nanoid_1 = require("./nanoid");
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { ALPHABET_ALPHANUMERIC, ALPHABET_ALPHANUMERIC_LOWERCASE, ALPHABET_NONAMBIGUOUS, nanoIdCustomAlphabet, } from './nanoid.js';
|
|
10
3
|
/**
|
|
11
4
|
* Generate cryptographically-secure string id.
|
|
12
5
|
* Powered by `nanoid`.
|
|
13
6
|
*/
|
|
14
|
-
function stringId(length = 16, alphabet =
|
|
15
|
-
return
|
|
7
|
+
export function stringId(length = 16, alphabet = ALPHABET_ALPHANUMERIC_LOWERCASE) {
|
|
8
|
+
return nanoIdCustomAlphabet(alphabet, length)();
|
|
16
9
|
}
|
|
17
10
|
/**
|
|
18
11
|
* Generate a string id of Base62 alphabet (same as "alphanumeric": A-Za-z0-9)
|
|
19
12
|
*
|
|
20
13
|
* Length is 16 (non-configurable currently).
|
|
21
14
|
*/
|
|
22
|
-
|
|
15
|
+
export const stringIdBase62 = nanoIdCustomAlphabet(ALPHABET_ALPHANUMERIC, 16);
|
|
23
16
|
/**
|
|
24
17
|
* Generate a string id of Base64 alphabet: A-Za-z0-9+/
|
|
25
18
|
*
|
|
@@ -28,8 +21,8 @@ exports.stringIdBase62 = (0, nanoid_1.nanoIdCustomAlphabet)(nanoid_1.ALPHABET_AL
|
|
|
28
21
|
*
|
|
29
22
|
* Dividable by 4 lengths produce ids with no padding `=` characters, which is optimal.
|
|
30
23
|
*/
|
|
31
|
-
function stringIdBase64(size = 16) {
|
|
32
|
-
return
|
|
24
|
+
export function stringIdBase64(size = 16) {
|
|
25
|
+
return randomBytes(size * 0.75).toString('base64');
|
|
33
26
|
}
|
|
34
27
|
/**
|
|
35
28
|
* Generate a string id of Base64url alphabet: A-Za-z0-9-_
|
|
@@ -39,8 +32,8 @@ function stringIdBase64(size = 16) {
|
|
|
39
32
|
*
|
|
40
33
|
* Base64url always produces strings without a padding character `=`, by design.
|
|
41
34
|
*/
|
|
42
|
-
function stringIdBase64Url(size = 16) {
|
|
43
|
-
return
|
|
35
|
+
export function stringIdBase64Url(size = 16) {
|
|
36
|
+
return randomBytes(size * 0.75).toString('base64url');
|
|
44
37
|
}
|
|
45
38
|
/**
|
|
46
39
|
* Generate cryptographically-secure string id with non-ambiguous characters only,
|
|
@@ -48,6 +41,6 @@ function stringIdBase64Url(size = 16) {
|
|
|
48
41
|
*
|
|
49
42
|
* Default length is 16.
|
|
50
43
|
*/
|
|
51
|
-
function stringIdNonAmbiguous(size = 16) {
|
|
52
|
-
return stringId(size,
|
|
44
|
+
export function stringIdNonAmbiguous(size = 16) {
|
|
45
|
+
return stringId(size, ALPHABET_NONAMBIGUOUS);
|
|
53
46
|
}
|
package/dist/security/nanoid.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
|
|
4
3
|
This file is "vendored" from Nanoid, all credit is to Nanoid authors:
|
|
5
4
|
https://github.com/ai/nanoid/
|
|
6
5
|
|
|
7
6
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ALPHABET_BASE64_URL = exports.ALPHABET_BASE64 = exports.ALPHABET_ALPHANUMERIC = exports.ALPHABET_ALPHANUMERIC_UPPERCASE = exports.ALPHABET_ALPHANUMERIC_LOWERCASE = exports.ALPHABET_UPPERCASE = exports.ALPHABET_LOWERCASE = exports.ALPHABET_NUMBER = exports.ALPHABET_NONAMBIGUOUS = void 0;
|
|
10
|
-
exports.nanoIdCustomAlphabet = nanoIdCustomAlphabet;
|
|
11
|
-
exports.nanoid = nanoid;
|
|
12
7
|
/* eslint-disable */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
import { randomFillSync } from 'node:crypto';
|
|
9
|
+
export const ALPHABET_NONAMBIGUOUS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
|
|
10
|
+
export const ALPHABET_NUMBER = '0123456789';
|
|
11
|
+
export const ALPHABET_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
|
|
12
|
+
export const ALPHABET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
13
|
+
export const ALPHABET_ALPHANUMERIC_LOWERCASE = [ALPHABET_NUMBER, ALPHABET_LOWERCASE].join('');
|
|
14
|
+
export const ALPHABET_ALPHANUMERIC_UPPERCASE = [ALPHABET_NUMBER, ALPHABET_UPPERCASE].join('');
|
|
15
|
+
export const ALPHABET_ALPHANUMERIC = [ALPHABET_NUMBER, ALPHABET_LOWERCASE, ALPHABET_UPPERCASE].join('');
|
|
16
|
+
export const ALPHABET_BASE64 = [ALPHABET_ALPHANUMERIC, '+/'].join('');
|
|
17
|
+
export const ALPHABET_BASE64_URL = [ALPHABET_ALPHANUMERIC, '-_'].join('');
|
|
23
18
|
// It is best to make fewer, larger requests to the crypto module to
|
|
24
19
|
// avoid system call overhead. So, random numbers are generated in a
|
|
25
20
|
// pool. The pool is a Buffer that is larger than the initial random
|
|
@@ -31,11 +26,11 @@ let poolOffset;
|
|
|
31
26
|
function fillPool(bytes) {
|
|
32
27
|
if (!pool || pool.length < bytes) {
|
|
33
28
|
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
34
|
-
|
|
29
|
+
randomFillSync(pool);
|
|
35
30
|
poolOffset = 0;
|
|
36
31
|
}
|
|
37
32
|
else if (poolOffset + bytes > pool.length) {
|
|
38
|
-
|
|
33
|
+
randomFillSync(pool);
|
|
39
34
|
poolOffset = 0;
|
|
40
35
|
}
|
|
41
36
|
poolOffset += bytes;
|
|
@@ -77,10 +72,10 @@ function customRandom(alphabet, defaultSize, getRandom) {
|
|
|
77
72
|
}
|
|
78
73
|
};
|
|
79
74
|
}
|
|
80
|
-
function nanoIdCustomAlphabet(alphabet, size = 21) {
|
|
75
|
+
export function nanoIdCustomAlphabet(alphabet, size = 21) {
|
|
81
76
|
return customRandom(alphabet, size, random);
|
|
82
77
|
}
|
|
83
|
-
function nanoid(size = 21) {
|
|
78
|
+
export function nanoid(size = 21) {
|
|
84
79
|
// `-=` convert `size` to number to prevent `valueOf` abusing
|
|
85
80
|
fillPool((size -= 0));
|
|
86
81
|
let id = '';
|
|
@@ -91,7 +86,7 @@ function nanoid(size = 21) {
|
|
|
91
86
|
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
92
87
|
// as empty string fallback or magic numbers, is unneccessary because
|
|
93
88
|
// the bitmask trims bytes down to the alphabet size.
|
|
94
|
-
id +=
|
|
89
|
+
id += ALPHABET_BASE64_URL[pool[i] & 63];
|
|
95
90
|
}
|
|
96
91
|
return id;
|
|
97
92
|
}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.removeSecretsFromEnv = removeSecretsFromEnv;
|
|
5
|
-
exports.loadSecretsFromEncryptedJsonFile = loadSecretsFromEncryptedJsonFile;
|
|
6
|
-
exports.loadSecretsFromEncryptedJsonFileValues = loadSecretsFromEncryptedJsonFileValues;
|
|
7
|
-
exports.secret = secret;
|
|
8
|
-
exports.secretOptional = secretOptional;
|
|
9
|
-
exports.getSecretMap = getSecretMap;
|
|
10
|
-
exports.setSecretMap = setSecretMap;
|
|
11
|
-
const node_fs_1 = require("node:fs");
|
|
12
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
13
|
-
const crypto_util_1 = require("./crypto.util");
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { _assert, _jsonParseIfPossible } from '@naturalcycles/js-lib';
|
|
3
|
+
import { decryptObject, decryptRandomIVBuffer } from './crypto.util.js';
|
|
14
4
|
let loaded = false;
|
|
15
5
|
const secretMap = {};
|
|
16
6
|
/**
|
|
@@ -19,8 +9,8 @@ const secretMap = {};
|
|
|
19
9
|
*
|
|
20
10
|
* Does NOT delete previous secrets from secretMap.
|
|
21
11
|
*/
|
|
22
|
-
function loadSecretsFromEnv() {
|
|
23
|
-
require('dotenv').config()
|
|
12
|
+
export function loadSecretsFromEnv() {
|
|
13
|
+
// require('dotenv').config() // ensure .env is loaded
|
|
24
14
|
const secrets = {};
|
|
25
15
|
Object.keys(process.env)
|
|
26
16
|
.filter(k => k.toUpperCase().startsWith('SECRET_'))
|
|
@@ -35,7 +25,7 @@ function loadSecretsFromEnv() {
|
|
|
35
25
|
/**
|
|
36
26
|
* Removes process.env.SECRET_*
|
|
37
27
|
*/
|
|
38
|
-
function removeSecretsFromEnv() {
|
|
28
|
+
export function removeSecretsFromEnv() {
|
|
39
29
|
Object.keys(process.env)
|
|
40
30
|
.filter(k => k.toUpperCase().startsWith('SECRET_'))
|
|
41
31
|
.forEach(k => delete process.env[k]);
|
|
@@ -48,17 +38,17 @@ function removeSecretsFromEnv() {
|
|
|
48
38
|
* Whole file is encrypted.
|
|
49
39
|
* For "json-values encrypted" style - use `loadSecretsFromEncryptedJsonFileValues`
|
|
50
40
|
*/
|
|
51
|
-
function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
|
|
52
|
-
|
|
41
|
+
export function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
|
|
42
|
+
_assert(existsSync(filePath), `loadSecretsFromEncryptedJsonFile() cannot load from path: ${filePath}`);
|
|
53
43
|
let secrets;
|
|
54
44
|
if (secretEncryptionKey) {
|
|
55
|
-
const buf =
|
|
45
|
+
const buf = readFileSync(filePath);
|
|
56
46
|
const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64');
|
|
57
|
-
const plain =
|
|
47
|
+
const plain = decryptRandomIVBuffer(buf, encKeyBuffer).toString('utf8');
|
|
58
48
|
secrets = JSON.parse(plain);
|
|
59
49
|
}
|
|
60
50
|
else {
|
|
61
|
-
secrets = JSON.parse(
|
|
51
|
+
secrets = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
62
52
|
}
|
|
63
53
|
Object.entries(secrets).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
|
|
64
54
|
loaded = true;
|
|
@@ -70,12 +60,12 @@ function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
|
|
|
70
60
|
* Whole file is NOT encrypted, but instead individual json values ARE encrypted..
|
|
71
61
|
* For whole-file encryption - use `loadSecretsFromEncryptedJsonFile`
|
|
72
62
|
*/
|
|
73
|
-
function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
|
|
74
|
-
|
|
75
|
-
let secrets = JSON.parse(
|
|
63
|
+
export function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
|
|
64
|
+
_assert(existsSync(filePath), `loadSecretsFromEncryptedJsonFileValues() cannot load from path: ${filePath}`);
|
|
65
|
+
let secrets = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
76
66
|
if (secretEncryptionKey) {
|
|
77
67
|
const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64');
|
|
78
|
-
secrets =
|
|
68
|
+
secrets = decryptObject(secrets, encKeyBuffer);
|
|
79
69
|
}
|
|
80
70
|
Object.entries(secrets).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
|
|
81
71
|
loaded = true;
|
|
@@ -83,31 +73,31 @@ function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
|
|
|
83
73
|
.map(s => s.toUpperCase())
|
|
84
74
|
.join(', ')}`);
|
|
85
75
|
}
|
|
86
|
-
function secret(k, parseJson = false) {
|
|
76
|
+
export function secret(k, parseJson = false) {
|
|
87
77
|
const v = secretOptional(k, parseJson);
|
|
88
78
|
if (!v) {
|
|
89
79
|
throw new Error(`secret(${k.toUpperCase()}) not found!`);
|
|
90
80
|
}
|
|
91
81
|
return v;
|
|
92
82
|
}
|
|
93
|
-
function secretOptional(k, parseJson = false) {
|
|
83
|
+
export function secretOptional(k, parseJson = false) {
|
|
94
84
|
requireLoaded();
|
|
95
85
|
let v = secretMap[k.toUpperCase()];
|
|
96
86
|
if (!v)
|
|
97
87
|
return;
|
|
98
88
|
if (parseJson) {
|
|
99
|
-
v =
|
|
89
|
+
v = _jsonParseIfPossible(v);
|
|
100
90
|
}
|
|
101
91
|
return v;
|
|
102
92
|
}
|
|
103
|
-
function getSecretMap() {
|
|
93
|
+
export function getSecretMap() {
|
|
104
94
|
requireLoaded();
|
|
105
95
|
return secretMap;
|
|
106
96
|
}
|
|
107
97
|
/**
|
|
108
98
|
* REPLACES secretMap with new map.
|
|
109
99
|
*/
|
|
110
|
-
function setSecretMap(map) {
|
|
100
|
+
export function setSecretMap(map) {
|
|
111
101
|
Object.keys(secretMap).forEach(k => delete secretMap[k]);
|
|
112
102
|
Object.entries(map).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
|
|
113
103
|
console.log(`setSecretMap set ${Object.keys(secretMap).length} secret(s): ${Object.keys(map)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObject, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model';
|
|
2
|
+
import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model.js';
|
|
3
3
|
/**
|
|
4
4
|
* Has 2 main methods:
|
|
5
5
|
*
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SlackService = void 0;
|
|
4
|
-
exports.slackDefaultMessagePrefixHook = slackDefaultMessagePrefixHook;
|
|
5
|
-
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
|
-
const __1 = require("..");
|
|
1
|
+
import { _omit, commonLoggerMinLevel, getFetcher, localTime, PQueue } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _inspect } from '../index.js';
|
|
7
3
|
const GAE = !!process.env['GAE_INSTANCE'];
|
|
8
4
|
const DEFAULTS = {
|
|
9
5
|
username: 'bot',
|
|
@@ -27,7 +23,7 @@ const INSPECT_OPT = {
|
|
|
27
23
|
* .send method has a shortcut:
|
|
28
24
|
* .send(string, ctx?: CTX)
|
|
29
25
|
*/
|
|
30
|
-
class SlackService {
|
|
26
|
+
export class SlackService {
|
|
31
27
|
constructor(cfg) {
|
|
32
28
|
this.cfg = {
|
|
33
29
|
messagePrefixHook: slackDefaultMessagePrefixHook,
|
|
@@ -38,10 +34,12 @@ class SlackService {
|
|
|
38
34
|
...cfg.inspectOptions,
|
|
39
35
|
},
|
|
40
36
|
};
|
|
41
|
-
this.fetcher =
|
|
37
|
+
this.fetcher = getFetcher({
|
|
42
38
|
timeoutSeconds: 90,
|
|
43
39
|
});
|
|
44
40
|
}
|
|
41
|
+
fetcher;
|
|
42
|
+
cfg;
|
|
45
43
|
/**
|
|
46
44
|
* Allows to "log" many things at once, similar to `console.log(one, two, three).
|
|
47
45
|
*/
|
|
@@ -70,10 +68,10 @@ class SlackService {
|
|
|
70
68
|
let text;
|
|
71
69
|
// Array has a special treatment here
|
|
72
70
|
if (Array.isArray(msg.items)) {
|
|
73
|
-
text = msg.items.map(t =>
|
|
71
|
+
text = msg.items.map(t => _inspect(t, inspectOptions)).join('\n');
|
|
74
72
|
}
|
|
75
73
|
else {
|
|
76
|
-
text =
|
|
74
|
+
text = _inspect(msg.items, inspectOptions);
|
|
77
75
|
}
|
|
78
76
|
// Wrap in markdown-text-block if it's anything but plain String
|
|
79
77
|
if (typeof msg.items !== 'string') {
|
|
@@ -85,7 +83,7 @@ class SlackService {
|
|
|
85
83
|
const prefix = await messagePrefixHook(msg);
|
|
86
84
|
if (prefix === null)
|
|
87
85
|
return; // filtered out!
|
|
88
|
-
const json =
|
|
86
|
+
const json = _omit({
|
|
89
87
|
...DEFAULTS,
|
|
90
88
|
...this.cfg.defaults,
|
|
91
89
|
...msg,
|
|
@@ -117,19 +115,18 @@ class SlackService {
|
|
|
117
115
|
getCommonLogger(opt) {
|
|
118
116
|
const { minLogLevel = 'log', logChannel, warnChannel, errorChannel } = opt;
|
|
119
117
|
const defaultChannel = this.cfg.defaults?.channel || DEFAULTS.channel;
|
|
120
|
-
const q = new
|
|
118
|
+
const q = new PQueue({
|
|
121
119
|
concurrency: 1,
|
|
122
120
|
});
|
|
123
|
-
return
|
|
121
|
+
return commonLoggerMinLevel({
|
|
124
122
|
log: (...args) => q.push(() => this.send({ items: args, channel: logChannel || defaultChannel })),
|
|
125
123
|
warn: (...args) => q.push(() => this.send({ items: args, channel: warnChannel || defaultChannel })),
|
|
126
124
|
error: (...args) => q.push(() => this.send({ items: args, channel: errorChannel || defaultChannel })),
|
|
127
125
|
}, minLogLevel);
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const tokens = [js_lib_1.localTime.now().toPretty()];
|
|
128
|
+
export function slackDefaultMessagePrefixHook(msg) {
|
|
129
|
+
const tokens = [localTime.now().toPretty()];
|
|
133
130
|
const { ctx } = msg;
|
|
134
131
|
// AppEngine-specific decoration
|
|
135
132
|
if (GAE && ctx && typeof ctx === 'object' && typeof ctx.header === 'function') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { InspectAnyOptions } from '
|
|
2
|
+
import type { InspectAnyOptions } from '../index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Properties that exists both in SlackApiBody (as per Slack API) and SlackMessage (our abstraction).
|
|
5
5
|
*/
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|