@lokalise/node-core 9.18.0 → 9.20.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 +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/src/utils/encryptionUtility.d.ts +21 -0
- package/dist/src/utils/encryptionUtility.js +58 -0
- package/dist/src/utils/encryptionUtility.js.map +1 -0
- package/dist/src/utils/hashUtils.d.ts +9 -0
- package/dist/src/utils/hashUtils.js +19 -0
- package/dist/src/utils/hashUtils.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -231,3 +231,11 @@ const result = await waitAndRetry(
|
|
|
231
231
|
expect(result).toBe(false) // resolves to what the last attempt has returned
|
|
232
232
|
expect(someEventEmitter.emittedEvents.length).toBe(1)
|
|
233
233
|
```
|
|
234
|
+
|
|
235
|
+
## Encryption
|
|
236
|
+
|
|
237
|
+
- `EncryptionUtility` - small class for encrypting/decrypting using aes-256-gcm. Adapted from: https://github.com/MauriceButler/cryptr
|
|
238
|
+
|
|
239
|
+
## Hashing
|
|
240
|
+
|
|
241
|
+
- `HashUtils` - utils for hashing using sha256/sha512 algorithms
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,12 @@ export { ensureClosingSlashTransformer } from './src/config/configTransformers';
|
|
|
8
8
|
export { createRangeValidator } from './src/config/configValidators';
|
|
9
9
|
export { type EnvValueValidator, type EnvValueTransformer, type AppConfig, type RedisConfig, } from './src/config/configTypes';
|
|
10
10
|
export { type Either, type DefiniteEither, success, failure, isSuccess, isFailure, } from './src/errors/either';
|
|
11
|
+
export { EncryptionUtility } from './src/utils/encryptionUtility';
|
|
11
12
|
export { chunk, callChunked, removeFalsy, removeNullish } from './src/utils/arrayUtils';
|
|
12
13
|
export { groupBy, groupByPath, groupByUnique, pick, pickWithoutUndefined, copyWithoutUndefined, copyWithoutEmpty, isEmptyObject, convertDateFieldsToIsoString, deepClone, } from './src/utils/objectUtils';
|
|
13
14
|
export { isError, isInternalError, isStandardizedError, isObject, isPublicNonRecoverableError, hasMessage, } from './src/utils/typeUtils';
|
|
14
15
|
export { type StandardizedError } from './src/utils/typeUtils';
|
|
16
|
+
export { generateHash, HashAlgorithm, HashEncoding } from './src/utils/hashUtils';
|
|
15
17
|
export { resolveLoggerConfiguration, resolveMonorepoLoggerConfiguration, } from './src/logging/loggerConfigResolver';
|
|
16
18
|
export type { AppLoggerConfig, MonorepoAppLoggerConfig } from './src/logging/loggerConfigResolver';
|
|
17
19
|
export type { CommonLogger } from './src/logging/commonLogger';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.waitAndRetry = exports.AuthFailedError = exports.EntityGoneError = exports.EntityNotFoundError = exports.AccessDeniedError = void 0;
|
|
3
|
+
exports.executeAndHandleGlobalErrors = exports.executeAsyncAndHandleGlobalErrors = exports.resolveMonorepoLoggerConfiguration = exports.resolveLoggerConfiguration = exports.HashEncoding = exports.HashAlgorithm = exports.generateHash = exports.hasMessage = exports.isPublicNonRecoverableError = exports.isObject = exports.isStandardizedError = exports.isInternalError = exports.isError = exports.deepClone = exports.convertDateFieldsToIsoString = exports.isEmptyObject = exports.copyWithoutEmpty = exports.copyWithoutUndefined = exports.pickWithoutUndefined = exports.pick = exports.groupByUnique = exports.groupByPath = exports.groupBy = exports.removeNullish = exports.removeFalsy = exports.callChunked = exports.chunk = exports.EncryptionUtility = exports.isFailure = exports.isSuccess = exports.failure = exports.success = exports.createRangeValidator = exports.ensureClosingSlashTransformer = exports.ConfigScope = exports.isEntityGoneError = exports.isResponseStatusError = exports.ResponseStatusError = exports.InternalError = exports.PublicNonRecoverableError = exports.JSON_HEADERS = exports.buildClient = exports.httpClient = exports.sendPostBinary = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = void 0;
|
|
4
|
+
exports.waitAndRetry = exports.AuthFailedError = exports.EntityGoneError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = exports.resolveGlobalErrorLogObject = exports.globalLogger = exports.executeSettleAllAndHandleGlobalErrors = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
var httpClient_1 = require("./src/http/httpClient");
|
|
7
7
|
Object.defineProperty(exports, "sendPut", { enumerable: true, get: function () { return httpClient_1.sendPut; } });
|
|
@@ -34,6 +34,8 @@ Object.defineProperty(exports, "success", { enumerable: true, get: function () {
|
|
|
34
34
|
Object.defineProperty(exports, "failure", { enumerable: true, get: function () { return either_1.failure; } });
|
|
35
35
|
Object.defineProperty(exports, "isSuccess", { enumerable: true, get: function () { return either_1.isSuccess; } });
|
|
36
36
|
Object.defineProperty(exports, "isFailure", { enumerable: true, get: function () { return either_1.isFailure; } });
|
|
37
|
+
var encryptionUtility_1 = require("./src/utils/encryptionUtility");
|
|
38
|
+
Object.defineProperty(exports, "EncryptionUtility", { enumerable: true, get: function () { return encryptionUtility_1.EncryptionUtility; } });
|
|
37
39
|
var arrayUtils_1 = require("./src/utils/arrayUtils");
|
|
38
40
|
Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return arrayUtils_1.chunk; } });
|
|
39
41
|
Object.defineProperty(exports, "callChunked", { enumerable: true, get: function () { return arrayUtils_1.callChunked; } });
|
|
@@ -57,6 +59,10 @@ Object.defineProperty(exports, "isStandardizedError", { enumerable: true, get: f
|
|
|
57
59
|
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return typeUtils_1.isObject; } });
|
|
58
60
|
Object.defineProperty(exports, "isPublicNonRecoverableError", { enumerable: true, get: function () { return typeUtils_1.isPublicNonRecoverableError; } });
|
|
59
61
|
Object.defineProperty(exports, "hasMessage", { enumerable: true, get: function () { return typeUtils_1.hasMessage; } });
|
|
62
|
+
var hashUtils_1 = require("./src/utils/hashUtils");
|
|
63
|
+
Object.defineProperty(exports, "generateHash", { enumerable: true, get: function () { return hashUtils_1.generateHash; } });
|
|
64
|
+
Object.defineProperty(exports, "HashAlgorithm", { enumerable: true, get: function () { return hashUtils_1.HashAlgorithm; } });
|
|
65
|
+
Object.defineProperty(exports, "HashEncoding", { enumerable: true, get: function () { return hashUtils_1.HashEncoding; } });
|
|
60
66
|
var loggerConfigResolver_1 = require("./src/logging/loggerConfigResolver");
|
|
61
67
|
Object.defineProperty(exports, "resolveLoggerConfiguration", { enumerable: true, get: function () { return loggerConfigResolver_1.resolveLoggerConfiguration; } });
|
|
62
68
|
Object.defineProperty(exports, "resolveMonorepoLoggerConfiguration", { enumerable: true, get: function () { return loggerConfigResolver_1.resolveMonorepoLoggerConfiguration; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AAAA,oDAe8B;AAd5B,qGAAA,OAAO,OAAA;AACP,2GAAA,aAAa,OAAA;AACb,wGAAA,UAAU,OAAA;AACV,uGAAA,SAAS,OAAA;AACT,qGAAA,OAAO,OAAA;AACP,sGAAA,QAAQ,OAAA;AACR,4GAAA,cAAc,OAAA;AACd,wGAAA,UAAU,OAAA;AACV,yGAAA,WAAW,OAAA;AAKX,0GAAA,YAAY,OAAA;AAGd,oFAG+C;AAF7C,sIAAA,yBAAyB,OAAA;AAI3B,4DAImC;AAHjC,8GAAA,aAAa,OAAA;AAIf,wEAAsE;AAA7D,0HAAA,mBAAmB,OAAA;AAC5B,gEAAuF;AAA9E,wHAAA,qBAAqB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAEjD,wDAAsD;AAA7C,0GAAA,WAAW,OAAA;AACpB,sEAA+E;AAAtE,mIAAA,6BAA6B,OAAA;AACtC,kEAAoE;AAA3D,wHAAA,oBAAoB,OAAA;AAQ7B,8CAO4B;AAJ1B,iGAAA,OAAO,OAAA;AACP,iGAAA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AA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,yGAAA,YAAY,OAAA;AAElD,2EAG2C;AAFzC,kIAAA,0BAA0B,OAAA;AAC1B,0IAAA,kCAAkC,OAAA;AAUpC,sEAMwC;AALtC,uIAAA,iCAAiC,OAAA;AACjC,kIAAA,4BAA4B,OAAA;AAC5B,2IAAA,qCAAqC,OAAA;AACrC,kHAAA,YAAY,OAAA;AACZ,iIAAA,2BAA2B,OAAA;AAK7B,0DASkC;AALhC,sHAAA,sBAAsB,OAAA;AACtB,iHAAA,iBAAiB,OAAA;AACjB,mHAAA,mBAAmB,OAAA;AACnB,+GAAA,eAAe,OAAA;AACf,+GAAA,eAAe,OAAA;AAGjB,mDAAoD;AAA3C,yGAAA,YAAY,OAAA;AAErB,iFAAsD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export type Options = {
|
|
3
|
+
saltLength?: number;
|
|
4
|
+
pbkdf2Iterations?: number;
|
|
5
|
+
encoding?: BufferEncoding;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Type-scripted version of https://github.com/MauriceButler/cryptr
|
|
9
|
+
*/
|
|
10
|
+
export declare class EncryptionUtility {
|
|
11
|
+
private readonly secret;
|
|
12
|
+
private readonly saltLength;
|
|
13
|
+
private readonly encryptedPosition;
|
|
14
|
+
private readonly tagPosition;
|
|
15
|
+
private readonly pbkdf2Iterations;
|
|
16
|
+
private readonly encoding;
|
|
17
|
+
constructor(secret: string, options?: Options);
|
|
18
|
+
private getKey;
|
|
19
|
+
encrypt(value: string): string;
|
|
20
|
+
decrypt(value: string): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EncryptionUtility = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
+
const algorithm = 'aes-256-gcm';
|
|
7
|
+
const ivLength = 16;
|
|
8
|
+
const tagLength = 16;
|
|
9
|
+
const defaultEncoding = 'hex';
|
|
10
|
+
const defaultSaltLength = 64;
|
|
11
|
+
const defaultPbkdf2Iterations = 100000;
|
|
12
|
+
/**
|
|
13
|
+
* Type-scripted version of https://github.com/MauriceButler/cryptr
|
|
14
|
+
*/
|
|
15
|
+
class EncryptionUtility {
|
|
16
|
+
secret;
|
|
17
|
+
saltLength;
|
|
18
|
+
encryptedPosition;
|
|
19
|
+
tagPosition;
|
|
20
|
+
pbkdf2Iterations;
|
|
21
|
+
encoding;
|
|
22
|
+
constructor(secret, options) {
|
|
23
|
+
this.secret = secret;
|
|
24
|
+
this.encoding = options?.encoding ?? defaultEncoding;
|
|
25
|
+
this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations;
|
|
26
|
+
this.saltLength = options?.saltLength ?? defaultSaltLength;
|
|
27
|
+
this.tagPosition = this.saltLength + ivLength;
|
|
28
|
+
this.encryptedPosition = this.tagPosition + tagLength;
|
|
29
|
+
}
|
|
30
|
+
getKey(salt) {
|
|
31
|
+
return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512');
|
|
32
|
+
}
|
|
33
|
+
encrypt(value) {
|
|
34
|
+
const iv = crypto.randomBytes(ivLength);
|
|
35
|
+
const salt = crypto.randomBytes(this.saltLength);
|
|
36
|
+
const key = this.getKey(salt);
|
|
37
|
+
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
|
38
|
+
const encrypted = Buffer.concat([cipher.update(String(value), 'utf8'), cipher.final()]);
|
|
39
|
+
const tag = cipher.getAuthTag();
|
|
40
|
+
return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding);
|
|
41
|
+
}
|
|
42
|
+
decrypt(value) {
|
|
43
|
+
const stringValue = Buffer.from(String(value), this.encoding);
|
|
44
|
+
const salt = stringValue.subarray(0, this.saltLength);
|
|
45
|
+
const iv = stringValue.subarray(this.saltLength, this.tagPosition);
|
|
46
|
+
const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition);
|
|
47
|
+
const encrypted = stringValue.subarray(this.encryptedPosition);
|
|
48
|
+
const key = this.getKey(salt);
|
|
49
|
+
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
|
50
|
+
decipher.setAuthTag(tag);
|
|
51
|
+
return Buffer.concat([
|
|
52
|
+
decipher.update(encrypted),
|
|
53
|
+
Buffer.from(decipher.final('utf8')),
|
|
54
|
+
]).toString('utf8');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.EncryptionUtility = EncryptionUtility;
|
|
58
|
+
//# sourceMappingURL=encryptionUtility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryptionUtility.js","sourceRoot":"","sources":["../../../src/utils/encryptionUtility.ts"],"names":[],"mappings":";;;;AAAA,uDAAgC;AAEhC,MAAM,SAAS,GAAG,aAAa,CAAA;AAC/B,MAAM,QAAQ,GAAG,EAAE,CAAA;AACnB,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,MAAM,eAAe,GAAG,KAAK,CAAA;AAC7B,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAC5B,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAQtC;;GAEG;AACH,MAAa,iBAAiB;IACX,MAAM,CAAQ;IACd,UAAU,CAAQ;IAClB,iBAAiB,CAAQ;IACzB,WAAW,CAAQ;IACnB,gBAAgB,CAAQ;IACxB,QAAQ,CAAgB;IAEzC,YAAY,MAAc,EAAE,OAAiB;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAA;QACpD,IAAI,CAAC,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,CAAA;QAC5E,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,U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Q,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QACrD,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAClE,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAC1E,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAE9D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;QAE5D,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAExB,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;YAC1B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACpC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACrB,CAAC;CACF;AAxDD,8CAwDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum HashEncoding {
|
|
2
|
+
HEX = "hex",
|
|
3
|
+
BASE64 = "base64"
|
|
4
|
+
}
|
|
5
|
+
export declare enum HashAlgorithm {
|
|
6
|
+
SHA256 = "sha256",
|
|
7
|
+
SHA512 = "sha512"
|
|
8
|
+
}
|
|
9
|
+
export declare function generateHash(algorithm: HashAlgorithm, data: string, encoding?: HashEncoding): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateHash = exports.HashAlgorithm = exports.HashEncoding = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
var HashEncoding;
|
|
6
|
+
(function (HashEncoding) {
|
|
7
|
+
HashEncoding["HEX"] = "hex";
|
|
8
|
+
HashEncoding["BASE64"] = "base64";
|
|
9
|
+
})(HashEncoding || (exports.HashEncoding = HashEncoding = {}));
|
|
10
|
+
var HashAlgorithm;
|
|
11
|
+
(function (HashAlgorithm) {
|
|
12
|
+
HashAlgorithm["SHA256"] = "sha256";
|
|
13
|
+
HashAlgorithm["SHA512"] = "sha512";
|
|
14
|
+
})(HashAlgorithm || (exports.HashAlgorithm = HashAlgorithm = {}));
|
|
15
|
+
function generateHash(algorithm, data, encoding = HashEncoding.HEX) {
|
|
16
|
+
return (0, node_crypto_1.createHash)(algorithm).update(data).digest(encoding);
|
|
17
|
+
}
|
|
18
|
+
exports.generateHash = generateHash;
|
|
19
|
+
//# sourceMappingURL=hashUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../../../src/utils/hashUtils.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,SAAgB,YAAY,CAC1B,SAAwB,EACxB,IAAY,EACZ,WAAyB,YAAY,CAAC,GAAG;IAEzC,OAAO,IAAA,wBAAU,EAAC,SAAS,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC5D,CAAC;AAND,oCAMC"}
|