@lokalise/node-core 9.17.1 → 9.19.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 CHANGED
@@ -231,3 +231,7 @@ 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
package/dist/index.d.ts CHANGED
@@ -2,12 +2,13 @@ export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, sendP
2
2
  export { PublicNonRecoverableError, type PublicNonRecoverableErrorParams, } from './src/errors/PublicNonRecoverableError';
3
3
  export { InternalError, type ErrorDetails, type InternalErrorParams, } from './src/errors/InternalError';
4
4
  export { ResponseStatusError } from './src/errors/ResponseStatusError';
5
- export { isResponseStatusError } from './src/errors/errorTypeGuards';
5
+ export { isResponseStatusError, isEntityGoneError } from './src/errors/errorTypeGuards';
6
6
  export { ConfigScope } from './src/config/ConfigScope';
7
7
  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';
@@ -19,6 +20,6 @@ export { type ErrorReport, type ErrorReporter, type ErrorResolver, } from './src
19
20
  export { executeAsyncAndHandleGlobalErrors, executeAndHandleGlobalErrors, executeSettleAllAndHandleGlobalErrors, globalLogger, resolveGlobalErrorLogObject, } from './src/errors/globalErrorHandler';
20
21
  export { type MayOmit } from './src/common/may-omit';
21
22
  export { type FreeformRecord } from './src/common/commonTypes';
22
- export { RequestValidationError, AccessDeniedError, EntityNotFoundError, type ValidationError, type CommonErrorParams, type OptionalMessageErrorParams, AuthFailedError, } from './src/errors/publicErrors';
23
+ export { type ValidationError, type CommonErrorParams, type OptionalMessageErrorParams, RequestValidationError, AccessDeniedError, EntityNotFoundError, EntityGoneError, AuthFailedError, } from './src/errors/publicErrors';
23
24
  export { waitAndRetry } from './src/utils/waitUtils';
24
25
  export * from './src/observability/observabilityTypes';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccessDeniedError = exports.RequestValidationError = exports.resolveGlobalErrorLogObject = exports.globalLogger = exports.executeSettleAllAndHandleGlobalErrors = exports.executeAndHandleGlobalErrors = exports.executeAsyncAndHandleGlobalErrors = exports.resolveMonorepoLoggerConfiguration = exports.resolveLoggerConfiguration = 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.isFailure = exports.isSuccess = exports.failure = exports.success = exports.createRangeValidator = exports.ensureClosingSlashTransformer = exports.ConfigScope = 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.EntityNotFoundError = void 0;
3
+ exports.resolveGlobalErrorLogObject = exports.globalLogger = exports.executeSettleAllAndHandleGlobalErrors = exports.executeAndHandleGlobalErrors = exports.executeAsyncAndHandleGlobalErrors = exports.resolveMonorepoLoggerConfiguration = exports.resolveLoggerConfiguration = 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 = 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; } });
@@ -22,6 +22,7 @@ var ResponseStatusError_1 = require("./src/errors/ResponseStatusError");
22
22
  Object.defineProperty(exports, "ResponseStatusError", { enumerable: true, get: function () { return ResponseStatusError_1.ResponseStatusError; } });
23
23
  var errorTypeGuards_1 = require("./src/errors/errorTypeGuards");
24
24
  Object.defineProperty(exports, "isResponseStatusError", { enumerable: true, get: function () { return errorTypeGuards_1.isResponseStatusError; } });
25
+ Object.defineProperty(exports, "isEntityGoneError", { enumerable: true, get: function () { return errorTypeGuards_1.isEntityGoneError; } });
25
26
  var ConfigScope_1 = require("./src/config/ConfigScope");
26
27
  Object.defineProperty(exports, "ConfigScope", { enumerable: true, get: function () { return ConfigScope_1.ConfigScope; } });
27
28
  var configTransformers_1 = require("./src/config/configTransformers");
@@ -33,6 +34,8 @@ Object.defineProperty(exports, "success", { enumerable: true, get: function () {
33
34
  Object.defineProperty(exports, "failure", { enumerable: true, get: function () { return either_1.failure; } });
34
35
  Object.defineProperty(exports, "isSuccess", { enumerable: true, get: function () { return either_1.isSuccess; } });
35
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; } });
36
39
  var arrayUtils_1 = require("./src/utils/arrayUtils");
37
40
  Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return arrayUtils_1.chunk; } });
38
41
  Object.defineProperty(exports, "callChunked", { enumerable: true, get: function () { return arrayUtils_1.callChunked; } });
@@ -69,6 +72,7 @@ var publicErrors_1 = require("./src/errors/publicErrors");
69
72
  Object.defineProperty(exports, "RequestValidationError", { enumerable: true, get: function () { return publicErrors_1.RequestValidationError; } });
70
73
  Object.defineProperty(exports, "AccessDeniedError", { enumerable: true, get: function () { return publicErrors_1.AccessDeniedError; } });
71
74
  Object.defineProperty(exports, "EntityNotFoundError", { enumerable: true, get: function () { return publicErrors_1.EntityNotFoundError; } });
75
+ Object.defineProperty(exports, "EntityGoneError", { enumerable: true, get: function () { return publicErrors_1.EntityGoneError; } });
72
76
  Object.defineProperty(exports, "AuthFailedError", { enumerable: true, get: function () { return publicErrors_1.AuthFailedError; } });
73
77
  var waitUtils_1 = require("./src/utils/waitUtils");
74
78
  Object.defineProperty(exports, "waitAndRetry", { enumerable: true, get: function () { return waitUtils_1.wa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A,OAAO,OAAA;AACP,mGAAA,SAAS,OAAA;AACT,mGAAA,SAAS,OAAA;AAGX,mEAAiE;AAAxD,sHAAA,iBAAiB,OAAA;AAE1B,qDAAuF;AAA9E,mGAAA,KAAK,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,2GAAA,aAAa,OAAA;AACvD,uDAWgC;AAV9B,sGAAA,OAAO,OAAA;AACP,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,mGAAA,IAAI,OAAA;AACJ,mHAAA,oBAAoB,OAAA;AACpB,mHAAA,oBAAoB,OAAA;AACpB,+GAAA,gBAAgB,OAAA;AAChB,4GAAA,aAAa,OAAA;AACb,2HAAA,4BAA4B,OAAA;AAC5B,wGAAA,SAAS,OAAA;AAGX,mDAO8B;AAN5B,oGAAA,OAAO,OAAA;AACP,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,qGAAA,QAAQ,OAAA;AACR,wHAAA,2BAA2B,OAAA;AAC3B,uGAAA,UAAU,OAAA;AAIZ,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"}
@@ -1,2 +1,4 @@
1
1
  import type { ResponseStatusError } from './ResponseStatusError';
2
+ import type { EntityGoneError } from './publicErrors';
2
3
  export declare function isResponseStatusError(entity: unknown): entity is ResponseStatusError;
4
+ export declare function isEntityGoneError(entity: unknown): entity is EntityGoneError;
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isResponseStatusError = void 0;
3
+ exports.isEntityGoneError = exports.isResponseStatusError = void 0;
4
+ const typeUtils_1 = require("../utils/typeUtils");
4
5
  function isResponseStatusError(entity) {
5
6
  return 'isResponseStatusError' in entity;
6
7
  }
7
8
  exports.isResponseStatusError = isResponseStatusError;
9
+ function isEntityGoneError(entity) {
10
+ return (0, typeUtils_1.isPublicNonRecoverableError)(entity) && entity.httpStatusCode === 410;
11
+ }
12
+ exports.isEntityGoneError = isEntityGoneError;
8
13
  //# sourceMappingURL=errorTypeGuards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorTypeGuards.js","sourceRoot":"","sources":["../../../src/errors/errorTypeGuards.ts"],"names":[],"mappings":";;;AAEA,SAAgB,qBAAqB,CAAC,MAAe;IACnD,OAAO,uBAAuB,IAAK,MAA8B,CAAA;AACnE,CAAC;AAFD,sDAEC"}
1
+ {"version":3,"file":"errorTypeGuards.js","sourceRoot":"","sources":["../../../src/errors/errorTypeGuards.ts"],"names":[],"mappings":";;;AAAA,kDAAgE;AAKhE,SAAgB,qBAAqB,CAAC,MAAe;IACnD,OAAO,uBAAuB,IAAK,MAA8B,CAAA;AACnE,CAAC;AAFD,sDAEC;AAED,SAAgB,iBAAiB,CAAC,MAAe;IAC/C,OAAO,IAAA,uCAA2B,EAAC,MAAM,CAAC,IAAI,MAAM,CAAC,cAAc,KAAK,GAAG,CAAA;AAC7E,CAAC;AAFD,8CAEC"}
@@ -19,6 +19,9 @@ export declare class AccessDeniedError extends PublicNonRecoverableError {
19
19
  export declare class EntityNotFoundError extends PublicNonRecoverableError {
20
20
  constructor(params: CommonErrorParams);
21
21
  }
22
+ export declare class EntityGoneError extends PublicNonRecoverableError {
23
+ constructor(params: CommonErrorParams);
24
+ }
22
25
  export declare class AuthFailedError extends PublicNonRecoverableError {
23
26
  constructor(params?: OptionalMessageErrorParams);
24
27
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthFailedError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = void 0;
3
+ exports.AuthFailedError = exports.EntityGoneError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = void 0;
4
4
  const node_http2_1 = require("node:http2");
5
5
  const PublicNonRecoverableError_1 = require("./PublicNonRecoverableError");
6
6
  class RequestValidationError extends PublicNonRecoverableError_1.PublicNonRecoverableError {
@@ -40,6 +40,17 @@ class EntityNotFoundError extends PublicNonRecoverableError_1.PublicNonRecoverab
40
40
  }
41
41
  }
42
42
  exports.EntityNotFoundError = EntityNotFoundError;
43
+ class EntityGoneError extends PublicNonRecoverableError_1.PublicNonRecoverableError {
44
+ constructor(params) {
45
+ super({
46
+ message: params.message,
47
+ errorCode: 'ENTITY_GONE',
48
+ httpStatusCode: 410,
49
+ details: params.details,
50
+ });
51
+ }
52
+ }
53
+ exports.EntityGoneError = EntityGoneError;
43
54
  class AuthFailedError extends PublicNonRecoverableError_1.PublicNonRecoverableError {
44
55
  constructor(params = {}) {
45
56
  super({
@@ -1 +1 @@
1
- {"version":3,"file":"publicErrors.js","sourceRoot":"","sources":["../../../src/errors/publicErrors.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAIvD,2EAAuE;AAevE,MAAa,sBAAuB,SAAQ,qDAAyB;IACnE,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,gBAAgB;YACzB,SAAS,EAAE,kBAAkB;YAC7B,cAAc,EAAE,sBAAa,CAAC,uBAAuB;YACrD,OAAO,EAAE;gBACP,KAAK,EAAE,MAAM;aACd;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAXD,wDAWC;AAED,MAAa,iBAAkB,SAAQ,qDAAyB;IAC9D,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAA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9D,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,eAAe;YAC1B,cAAc,EAAE,sBAAa,CAAC,qBAAqB;YACnD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,8CAUC;AAED,MAAa,mBAAoB,SAAQ,qDAAyB;IAChE,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,kBAAkB;YAC7B,cAAc,EAAE,sBAAa,CAAC,qBAAqB;YACnD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,kDAUC;AAED,MAAa,eAAgB,SAAQ,qDAAyB;IAC5D,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,aAAa;YACxB,cAAc,EAAE,GAAG;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAA;IACJ,CAAC;CACF;AATD,0CASC;AAED,MAAa,eAAgB,SAAQ,qDAAyB;IAC5D,YAAY,SAAqC,EAAE;QACjD,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;YAClD,SAAS,EAAE,aAAa;YACxB,cAAc,EAAE,sBAAa,CAAC,wBAAwB;YACtD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,0CAUC"}
@@ -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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