@ellipticltd/aml-utils 0.15.10-SCR-1297 → 0.15.10-SCR-1297-3
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/lib/errors/errors.d.ts +9 -0
- package/lib/errors/errors.js +42 -0
- package/lib/errors/errors.js.map +1 -0
- package/lib/file-parser/errors.js +0 -1
- package/lib/file-parser/errors.js.map +1 -1
- package/lib/file-parser/file-parser.d.ts +1 -1
- package/lib/file-parser/file-parser.js +2 -2
- package/lib/file-parser/file-parser.js.map +1 -1
- package/lib/file-parser/{sanitzeRows.js → sanitizeRows.js} +1 -1
- package/lib/file-parser/sanitizeRows.js.map +1 -0
- package/lib/formatting/formatting.d.ts +2 -0
- package/lib/formatting/formatting.js +17 -0
- package/lib/formatting/formatting.js.map +1 -0
- package/lib/middleware/middleware.d.ts +4 -0
- package/lib/middleware/middleware.js +22 -0
- package/lib/middleware/middleware.js.map +1 -0
- package/lib/orm-helpers/ormHelpers.d.ts +1 -0
- package/lib/orm-helpers/ormHelpers.js +17 -0
- package/lib/orm-helpers/ormHelpers.js.map +1 -0
- package/lib/structured-file-parser/structured-file-parser.js +0 -4
- package/lib/structured-file-parser/structured-file-parser.js.map +1 -1
- package/lib/types/types.d.ts +17 -0
- package/lib/types/types.js +201 -0
- package/lib/types/types.js.map +1 -0
- package/lib/validations/validations.d.ts +232 -0
- package/lib/validations/validations.js +456 -0
- package/lib/validations/validations.js.map +1 -0
- package/package.json +1 -1
- package/lib/file-parser/sanitzeRows.js.map +0 -1
- /package/lib/file-parser/{sanitzeRows.d.ts → sanitizeRows.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -9,3 +9,11 @@ Run `npx nx test aml-utils` to execute the unit tests via [Jest](https://jestjs.
|
|
|
9
9
|
## Running lint
|
|
10
10
|
|
|
11
11
|
Run `npx nx lint aml-utils` to execute the lint via [ESLint](https://eslint.org/).
|
|
12
|
+
|
|
13
|
+
## Building
|
|
14
|
+
|
|
15
|
+
Run `npx nx build aml-utils` to build the package
|
|
16
|
+
|
|
17
|
+
## Publishing
|
|
18
|
+
Run `npx nx publish aml-utils` to build and publish the package
|
|
19
|
+
You can also publish temp version of the package to npm with a tag by running `npx nx publish aml-utils -- --tag "your-tag-name"`
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const RequestError: any;
|
|
2
|
+
export const ServerError: any;
|
|
3
|
+
export const Forbidden: any;
|
|
4
|
+
export const Unauthorized: any;
|
|
5
|
+
export const BadRequest: any;
|
|
6
|
+
export const NotFound: any;
|
|
7
|
+
export const ConflictError: any;
|
|
8
|
+
export const InvalidArguments: any;
|
|
9
|
+
export const ServerTimeout: any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const create = require('create-error');
|
|
2
|
+
const AppError = create('AppError');
|
|
3
|
+
const RequestError = create(AppError, 'RequestError');
|
|
4
|
+
RequestError.toJSON = () => ({
|
|
5
|
+
message: this.message,
|
|
6
|
+
});
|
|
7
|
+
const Forbidden = create(RequestError, 'ForbiddenError', {
|
|
8
|
+
status: 403,
|
|
9
|
+
});
|
|
10
|
+
const Unauthorized = create(RequestError, 'UnauthorizedError', {
|
|
11
|
+
status: 401,
|
|
12
|
+
});
|
|
13
|
+
const BadRequest = create(RequestError, 'BadRequestError', {
|
|
14
|
+
status: 400,
|
|
15
|
+
});
|
|
16
|
+
const NotFound = create(RequestError, 'NotFoundError', {
|
|
17
|
+
status: 404,
|
|
18
|
+
});
|
|
19
|
+
const ConflictError = create(RequestError, 'ConflictError', {
|
|
20
|
+
status: 409,
|
|
21
|
+
});
|
|
22
|
+
const ServerError = create(RequestError, 'ServerError', {
|
|
23
|
+
status: 500,
|
|
24
|
+
});
|
|
25
|
+
const InvalidArguments = create(RequestError, 'InvalidArgumentsError', {
|
|
26
|
+
status: 500,
|
|
27
|
+
});
|
|
28
|
+
const ServerTimeout = create(RequestError, 'ServerTimeoutError', {
|
|
29
|
+
status: 503,
|
|
30
|
+
});
|
|
31
|
+
module.exports = {
|
|
32
|
+
RequestError,
|
|
33
|
+
ServerError,
|
|
34
|
+
Forbidden,
|
|
35
|
+
Unauthorized,
|
|
36
|
+
BadRequest,
|
|
37
|
+
NotFound,
|
|
38
|
+
ConflictError,
|
|
39
|
+
InvalidArguments,
|
|
40
|
+
ServerTimeout,
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/errors/errors.js"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEvC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAEtD,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;CACtB,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE;IACvD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,mBAAmB,EAAE;IAC7D,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE;IACzD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,eAAe,EAAE;IACrD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,eAAe,EAAE;IAC1D,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,aAAa,EAAE;IACtD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,MAAM,CAAC,YAAY,EAAE,uBAAuB,EAAE;IACrE,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,oBAAoB,EAAE;IAC/D,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,GAAG;IACf,YAAY;IACZ,WAAW;IACX,SAAS;IACT,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,aAAa;CACd,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TooManyRowsError = void 0;
|
|
4
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
5
4
|
class TooManyRowsError extends Error {
|
|
6
5
|
constructor() {
|
|
7
6
|
super('More than configured number of rows imported');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/errors.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IACzC;QACE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const parse_row_1 = tslib_1.__importDefault(require("./parse-row"));
|
|
5
5
|
const errors_1 = require("./errors");
|
|
6
|
-
const
|
|
6
|
+
const sanitizeRows_1 = tslib_1.__importDefault(require("./sanitizeRows"));
|
|
7
7
|
function chunk(array, size) {
|
|
8
8
|
if (!array.length) {
|
|
9
9
|
return [];
|
|
@@ -38,7 +38,7 @@ function parseFile(fileContent, maxRows, dependencies) {
|
|
|
38
38
|
}
|
|
39
39
|
const rows = fileContent.split('\n');
|
|
40
40
|
const parsedRows = rows.map(parse_row_1.default);
|
|
41
|
-
const sanitizedRows = (0,
|
|
41
|
+
const sanitizedRows = (0, sanitizeRows_1.default)(parsedRows, processRow);
|
|
42
42
|
if (sanitizedRows.length > maxRows) {
|
|
43
43
|
throw new errors_1.TooManyRowsError();
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-parser.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/file-parser.ts"],"names":[],"mappings":";;;AAAA,oEAAmC;AACnC,qCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"file-parser.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/file-parser.ts"],"names":[],"mappings":";;;AAAA,oEAAmC;AACnC,qCAA4C;AAC5C,0EAA+D;AAM/D,SAAS,KAAK,CAAI,KAAU,EAAE,IAAY;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAe,YAAY,CAA4B,UAAsB,EAAE,YAA6B;;QAC1G,MAAM,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC;QACpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAA6B,EAAE,MAA8B,EAAQ,EAAE;YACzF,UAA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C,CAAC;SACvC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeRows.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/sanitizeRows.ts"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5F,SAAS,YAAY,CAA4B,UAAsB,EAAE,UAAgC;IACvG,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAErE,MAAM,oBAAoB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEnF,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,qBAAqB,EAAE,UAAU,CAAC,MAAM,GAAG,qBAAqB,GAAG,oBAAoB,CAAC,CAAC;IAEjI,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9C,IAAI,QAAQ,CAAC,OAAO,EAAE;QACpB,OAAO,aAAa,CAAC;KACtB;IACD,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const rethrowError = (fnName, e) => {
|
|
3
|
+
let formattedError;
|
|
4
|
+
if (_.isPlainObject(e.error) || _.isArray(e.error)) {
|
|
5
|
+
formattedError = `\n${JSON.stringify(e.error, null, 2)}`;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
formattedError = e.error;
|
|
9
|
+
}
|
|
10
|
+
return `${fnName} - ${e.name}: ${e.statusCode} - ${formattedError}`;
|
|
11
|
+
};
|
|
12
|
+
const sqlEscapeWildcard = (str) => str.replace(/_|%|\\/g, (x) => `\\${x}`);
|
|
13
|
+
module.exports = {
|
|
14
|
+
rethrowError,
|
|
15
|
+
sqlEscapeWildcard,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/formatting/formatting.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5B,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IACjC,IAAI,cAAc,CAAC;IACnB,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;QAClD,cAAc,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAC1D;SAAM;QACL,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC;KAC1B;IACD,OAAO,GAAG,MAAM,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,UAAU,MAAM,cAAc,EAAE,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAE3E,MAAM,CAAC,OAAO,GAAG;IACf,YAAY;IACZ,iBAAiB;CAClB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function ensureType(type: any): (req: any, res: any, next: any, id: any, name: any) => any;
|
|
2
|
+
export function ensureUUID(req: any, res: any, next: any, id: any, name: any): any;
|
|
3
|
+
export function ensureHex32(req: any, res: any, next: any, id: any, name: any): any;
|
|
4
|
+
export function ensureInteger(req: any, res: any, next: any, id: any, name: any): any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const T = require('../types/types');
|
|
2
|
+
const ensureType = (type) => (req, res, next, id, name) => {
|
|
3
|
+
let error;
|
|
4
|
+
try {
|
|
5
|
+
T.ensureType(type, id, `Invalid ${name}`);
|
|
6
|
+
return next();
|
|
7
|
+
}
|
|
8
|
+
catch (error1) {
|
|
9
|
+
error = error1;
|
|
10
|
+
return next(error);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const ensureUUID = ensureType('UUID');
|
|
14
|
+
const ensureHex32 = ensureType('Hex32');
|
|
15
|
+
const ensureInteger = ensureType('IntString');
|
|
16
|
+
module.exports = {
|
|
17
|
+
ensureType,
|
|
18
|
+
ensureUUID,
|
|
19
|
+
ensureHex32,
|
|
20
|
+
ensureInteger,
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/middleware/middleware.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEpC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IACxD,IAAI,KAAK,CAAC;IACV,IAAI;QACF,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;QAC1C,OAAO,IAAI,EAAE,CAAC;KACf;IAAC,OAAO,MAAM,EAAE;QACf,KAAK,GAAG,MAAM,CAAC;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAEtC,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;AAExC,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AAE9C,MAAM,CAAC,OAAO,GAAG;IACf,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function includeNested(orm: any, models: any): any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const includeNested = (orm, models) => _.map(_.toPairs(models), (arg) => {
|
|
3
|
+
const [modelName, inclusion] = arg;
|
|
4
|
+
const include = includeNested(orm, inclusion);
|
|
5
|
+
const model = orm[modelName];
|
|
6
|
+
if (_.isEmpty(include)) {
|
|
7
|
+
return model;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
model,
|
|
11
|
+
include,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
module.exports = {
|
|
15
|
+
includeNested,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=ormHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ormHelpers.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/orm-helpers/ormHelpers.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5B,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CACpC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;IAC/B,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC;IACnC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,KAAK,CAAC;KACd;IACD,OAAO;QACL,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,OAAO,GAAG;IACf,aAAa;CACd,CAAC"}
|
|
@@ -18,8 +18,6 @@ function chunk(array, size) {
|
|
|
18
18
|
function processChunk(parsedRows, dependencies) {
|
|
19
19
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const { processRow, headers } = dependencies;
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
22
|
-
// @ts-ignore
|
|
23
21
|
return new Promise((resolve, reject) => {
|
|
24
22
|
setTimeout(() => {
|
|
25
23
|
try {
|
|
@@ -27,8 +25,6 @@ function processChunk(parsedRows, dependencies) {
|
|
|
27
25
|
resolve(processedRows);
|
|
28
26
|
}
|
|
29
27
|
catch (ex) {
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
-
// @ts-ignore
|
|
32
28
|
reject(ex);
|
|
33
29
|
}
|
|
34
30
|
}, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured-file-parser.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/structured-file-parser/structured-file-parser.ts"],"names":[],"mappings":";;;;AAAA,qCAAqC;AACrC,yCAAyC;AACzC,oEAAmC;AACnC,qCAAgG;AAChG,4EAA2C;AAe3C,SAAS,KAAK,CAAI,KAAU,EAAE,IAAY;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAe,YAAY,CACzB,UAAsB,EACtB,YAAwC;;QAExC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;QAC7C,
|
|
1
|
+
{"version":3,"file":"structured-file-parser.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/structured-file-parser/structured-file-parser.ts"],"names":[],"mappings":";;;;AAAA,qCAAqC;AACrC,yCAAyC;AACzC,oEAAmC;AACnC,qCAAgG;AAChG,4EAA2C;AAe3C,SAAS,KAAK,CAAI,KAAU,EAAE,IAAY;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAe,YAAY,CACzB,UAAsB,EACtB,YAAwC;;QAExC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;QAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAyC,EAAE,MAA8B,EAAQ,EAAE;YACrG,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI;oBACF,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;oBACxE,OAAO,CAAC,aAAa,CAAC,CAAC;iBACxB;gBAAC,OAAO,EAAE,EAAE;oBACX,MAAM,CAAC,EAAE,CAAC,CAAC;iBACZ;YACH,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,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W,EAAE,CAAC;SACzB;QAED,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,OAAO,GAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,eAAe,IAAI,eAAe,EAAE;YAC7C,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,eAAe,kCACjD,YAAY,KACf,OAAO,IACP,CAAC;YACH,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SACvC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const withNullable: {};
|
|
2
|
+
export function parseType(str: any): any;
|
|
3
|
+
export function parseType(str: any): any;
|
|
4
|
+
export function parsedTypeCheck(type: any, obj: any): any;
|
|
5
|
+
export function parsedTypeCheck(type: any, obj: any): any;
|
|
6
|
+
export function typeCheck(type: any, obj: any): any;
|
|
7
|
+
export function typeCheck(type: any, obj: any): any;
|
|
8
|
+
export namespace opts {
|
|
9
|
+
export { withNullable as customTypes };
|
|
10
|
+
}
|
|
11
|
+
export function ensureType(type: any, obj: any, msg: any): boolean;
|
|
12
|
+
export function ensureType(type: any, obj: any, msg: any): boolean;
|
|
13
|
+
export function checkArg(obj: any, prop: any, type: any, msg: any): any;
|
|
14
|
+
export function checkArg(obj: any, prop: any, type: any, msg: any): any;
|
|
15
|
+
export function checkArgs(input: any, types: any): void;
|
|
16
|
+
export function checkArgs(input: any, types: any): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const TC = require('type-check');
|
|
2
|
+
const _ = require('lodash');
|
|
3
|
+
const E = require('../errors/errors');
|
|
4
|
+
const V = require('../validations/validations');
|
|
5
|
+
const customTypes = {
|
|
6
|
+
Integer: {
|
|
7
|
+
typeOf: 'Number',
|
|
8
|
+
validate(x) {
|
|
9
|
+
return x % 1 === 0;
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
IntString: {
|
|
13
|
+
typeOf: 'String',
|
|
14
|
+
validate: V.isInt,
|
|
15
|
+
},
|
|
16
|
+
BoolString: {
|
|
17
|
+
typeOf: 'String',
|
|
18
|
+
validate: V.isBoolean,
|
|
19
|
+
},
|
|
20
|
+
Hex32: {
|
|
21
|
+
typeOf: 'String',
|
|
22
|
+
validate(x) {
|
|
23
|
+
return V.isHexadecimal(x) && x.length === 32;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
Email: {
|
|
27
|
+
typeOf: 'String',
|
|
28
|
+
validate: V.isEmail,
|
|
29
|
+
},
|
|
30
|
+
UUID: {
|
|
31
|
+
typeOf: 'String',
|
|
32
|
+
validate: V.isUUID,
|
|
33
|
+
},
|
|
34
|
+
UUIDv4: {
|
|
35
|
+
typeOf: 'String',
|
|
36
|
+
validate(x) {
|
|
37
|
+
return V.isUUID(x, 4);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
JSON: {
|
|
41
|
+
typeOf: 'String',
|
|
42
|
+
validate: V.isJSON,
|
|
43
|
+
},
|
|
44
|
+
Url: {
|
|
45
|
+
typeOf: 'String',
|
|
46
|
+
validate: V.isURL,
|
|
47
|
+
},
|
|
48
|
+
DateString: {
|
|
49
|
+
typeOf: 'String',
|
|
50
|
+
validate: V.isDate,
|
|
51
|
+
},
|
|
52
|
+
NonEmptyArray: {
|
|
53
|
+
typeOf: 'Array',
|
|
54
|
+
validate: V.nonEmpty,
|
|
55
|
+
},
|
|
56
|
+
NonNullString: {
|
|
57
|
+
typeOf: 'String',
|
|
58
|
+
validate: V.nonEmpty,
|
|
59
|
+
},
|
|
60
|
+
CustomerReference: {
|
|
61
|
+
typeOf: 'String',
|
|
62
|
+
validate: V.isCustomerReference,
|
|
63
|
+
},
|
|
64
|
+
CustomerLabelName: {
|
|
65
|
+
typeOf: 'String',
|
|
66
|
+
validate: V.isCustomerLabelName,
|
|
67
|
+
},
|
|
68
|
+
BitcoinAddress: {
|
|
69
|
+
typeOf: 'String',
|
|
70
|
+
validate: V.bitcoin.isAddress,
|
|
71
|
+
},
|
|
72
|
+
EthereumAddress: {
|
|
73
|
+
typeOf: 'String',
|
|
74
|
+
validate: V.ethereum.isAddress,
|
|
75
|
+
},
|
|
76
|
+
EthereumTx: {
|
|
77
|
+
typeOf: 'String',
|
|
78
|
+
validate: V.ethereum.isTxHash,
|
|
79
|
+
},
|
|
80
|
+
EthereumBlockHash: {
|
|
81
|
+
typeOf: 'String',
|
|
82
|
+
validate: V.ethereum.isBlockHash,
|
|
83
|
+
},
|
|
84
|
+
EthereumWeiAmount: {
|
|
85
|
+
typeOf: 'String',
|
|
86
|
+
validate: V.ethereum.isValidWeiAmount,
|
|
87
|
+
},
|
|
88
|
+
EthereumAddressCode: {
|
|
89
|
+
typeOf: 'String',
|
|
90
|
+
validate: V.ethereum.isAddressCode,
|
|
91
|
+
},
|
|
92
|
+
MineId: {
|
|
93
|
+
typeOf: 'String',
|
|
94
|
+
validate(x) {
|
|
95
|
+
return x === 'mine';
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
BitcoinTxHash: {
|
|
99
|
+
typeOf: 'String',
|
|
100
|
+
validate: V.bitcoin.isTxHash,
|
|
101
|
+
},
|
|
102
|
+
BitcoinAddressArray: {
|
|
103
|
+
typeOf: 'Array',
|
|
104
|
+
validate(as) {
|
|
105
|
+
return _.every(as, V.bitcoin.isAddress);
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
BitcoinTxHashArray: {
|
|
109
|
+
typeOf: 'Array',
|
|
110
|
+
validate(as) {
|
|
111
|
+
return _.every(as, V.bitcoin.isTxHash);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
BitcoinTxHex: {
|
|
115
|
+
typeOf: 'String',
|
|
116
|
+
validate: V.bitcoin.isTxHex,
|
|
117
|
+
},
|
|
118
|
+
BitcoinScriptHex: {
|
|
119
|
+
typeOf: 'String',
|
|
120
|
+
validate: V.bitcoin.isScriptHex,
|
|
121
|
+
},
|
|
122
|
+
BitcoinHDPath: {
|
|
123
|
+
typeOf: 'String',
|
|
124
|
+
validate: V.bitcoin.isHDPath,
|
|
125
|
+
},
|
|
126
|
+
BitcoinPublicKey: {
|
|
127
|
+
typeOf: 'String',
|
|
128
|
+
validate: V.bitcoin.isPublicKey,
|
|
129
|
+
},
|
|
130
|
+
BitcoinXpub: {
|
|
131
|
+
typeOf: 'String',
|
|
132
|
+
validate: V.bitcoin.isHDPublicKey,
|
|
133
|
+
},
|
|
134
|
+
BitcoinTxSignature: {
|
|
135
|
+
typeOf: 'String',
|
|
136
|
+
validate: V.bitcoin.isTxSignature,
|
|
137
|
+
},
|
|
138
|
+
BitcoinBlockHeight: {
|
|
139
|
+
typeOf: 'Number',
|
|
140
|
+
validate: V.bitcoin.isBlockHeight,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
// add support for nullable properties
|
|
144
|
+
const withNullable = Object.keys(customTypes).reduce((acc, type) => {
|
|
145
|
+
acc[type] = customTypes[type];
|
|
146
|
+
const { typeOf, validate } = customTypes[type];
|
|
147
|
+
// for every type, add Nullable+type. A nullable string can also be empty
|
|
148
|
+
acc[`Nullable${type}`] = Object.assign(Object.assign({}, customTypes[type]), { validate: (x) => x == null || (typeOf === 'String' && x === '') || validate(x) });
|
|
149
|
+
return acc;
|
|
150
|
+
}, {});
|
|
151
|
+
module.exports = {
|
|
152
|
+
parseType(str) {
|
|
153
|
+
return TC.parseType(str);
|
|
154
|
+
},
|
|
155
|
+
parsedTypeCheck(type, obj) {
|
|
156
|
+
return TC.parsedTypeCheck(type, obj, this.opts);
|
|
157
|
+
},
|
|
158
|
+
typeCheck(type, obj) {
|
|
159
|
+
return TC.typeCheck(type, obj, this.opts);
|
|
160
|
+
},
|
|
161
|
+
opts: {
|
|
162
|
+
customTypes: withNullable,
|
|
163
|
+
},
|
|
164
|
+
ensureType(type, obj, msg) {
|
|
165
|
+
return V.ensure(this.typeCheck(type, obj), msg);
|
|
166
|
+
},
|
|
167
|
+
checkArg(obj, prop, type, msg) {
|
|
168
|
+
let message;
|
|
169
|
+
if (msg == null) {
|
|
170
|
+
message = `Invalid ${prop}`;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
message = msg;
|
|
174
|
+
}
|
|
175
|
+
this.ensureType(type, obj[prop], message);
|
|
176
|
+
return obj[prop];
|
|
177
|
+
},
|
|
178
|
+
checkArgs(input, types) {
|
|
179
|
+
const inputKeys = {};
|
|
180
|
+
const [typ] = types;
|
|
181
|
+
const fields = typ.of;
|
|
182
|
+
let numInputKeys = 0;
|
|
183
|
+
let numKeys;
|
|
184
|
+
Object.keys(input).forEach((k) => {
|
|
185
|
+
inputKeys[k] = true;
|
|
186
|
+
numInputKeys += 1;
|
|
187
|
+
});
|
|
188
|
+
numKeys = 0;
|
|
189
|
+
Object.keys(fields).forEach((key) => {
|
|
190
|
+
const objTypes = fields[key];
|
|
191
|
+
V.ensure(this.parsedTypeCheck(objTypes, input[key]), `Invalid ${key}`);
|
|
192
|
+
if (inputKeys[key]) {
|
|
193
|
+
numKeys += 1;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
if (!(typ.subset || numInputKeys === numKeys)) {
|
|
197
|
+
throw new E.BadRequest('invalid extra arguments are present');
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/types/types.js"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEjC,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5B,MAAM,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtC,MAAM,CAAC,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEhD,MA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,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAI,OAAO,CAAC;QAEZ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC/B,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;YACpB,YAAY,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC,CAAC;QAEZ,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,EAAE,CAAC,CAAC;YACvE,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE;gBAClB,OAAO,IAAI,CAAC,CAAC;aACd;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,YAAY,KAAK,OAAO,CAAC,EAAE;YAC7C,MAAM,IAAI,CAAC,CAAC,UAAU,CAAC,qCAAqC,CAAC,CAAC;SAC/D;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
export function _validate(Err: any, pred: any, x: any, msg: any): any;
|
|
2
|
+
export function _validate(Err: any, pred: any, x: any, msg: any): any;
|
|
3
|
+
export function _validateArg(pred: any, x: any, msg: any): any;
|
|
4
|
+
export function _validateArg(pred: any, x: any, msg: any): any;
|
|
5
|
+
export function _tryCheck(fn: any, arg: any): boolean;
|
|
6
|
+
export function _tryCheck(fn: any, arg: any): boolean;
|
|
7
|
+
export function exists(x: any): boolean;
|
|
8
|
+
export function exists(x: any): boolean;
|
|
9
|
+
export function nonEmpty(x: any): boolean;
|
|
10
|
+
export function nonEmpty(x: any): boolean;
|
|
11
|
+
export function isNonEmptyString(x: any): boolean;
|
|
12
|
+
export function isNonEmptyString(x: any): boolean;
|
|
13
|
+
export function isSafeString(str: any): boolean;
|
|
14
|
+
export function isSafeString(str: any): boolean;
|
|
15
|
+
export function ensureShortEnough(limit: any, x: any): boolean;
|
|
16
|
+
export function ensureShortEnough(limit: any, x: any): boolean;
|
|
17
|
+
export function ensure(crit: any, msg: any): boolean;
|
|
18
|
+
export function ensure(crit: any, msg: any): boolean;
|
|
19
|
+
export function argExists(x: any, msg: any): any;
|
|
20
|
+
export function argExists(x: any, msg: any): any;
|
|
21
|
+
export namespace check {
|
|
22
|
+
function matches(required: any, given: any, msg: any): boolean;
|
|
23
|
+
function matches(required: any, given: any, msg: any): boolean;
|
|
24
|
+
function wasFound(type: any): (item: any) => any;
|
|
25
|
+
function wasFound(type: any): (item: any) => any;
|
|
26
|
+
function wasCreated(msg: any): (arr: any) => any;
|
|
27
|
+
function wasCreated(msg: any): (arr: any) => any;
|
|
28
|
+
function isTrue(crit: any, msg: any): boolean;
|
|
29
|
+
function isTrue(crit: any, msg: any): boolean;
|
|
30
|
+
function isFalse(crit: any, msg: any): boolean;
|
|
31
|
+
function isFalse(crit: any, msg: any): boolean;
|
|
32
|
+
}
|
|
33
|
+
export function isCustomerReference(x: any): boolean;
|
|
34
|
+
export function isCustomerReference(x: any): boolean;
|
|
35
|
+
export function isCustomerLabelName(x: any): boolean;
|
|
36
|
+
export function isCustomerLabelName(x: any): boolean;
|
|
37
|
+
export namespace binanceChain {
|
|
38
|
+
function isAddress(str: any): boolean;
|
|
39
|
+
function isAddress(str: any): boolean;
|
|
40
|
+
function isTxHash(str: any): boolean;
|
|
41
|
+
function isTxHash(str: any): boolean;
|
|
42
|
+
}
|
|
43
|
+
export namespace bitcoin {
|
|
44
|
+
function isAddress(str: any): any;
|
|
45
|
+
function isAddress(str: any): any;
|
|
46
|
+
function isBech32Address(str: any): boolean;
|
|
47
|
+
function isBech32Address(str: any): boolean;
|
|
48
|
+
function isHDPublicKey(str: any): boolean;
|
|
49
|
+
function isHDPublicKey(str: any): boolean;
|
|
50
|
+
function isPublicKey(str: any): boolean;
|
|
51
|
+
function isPublicKey(str: any): boolean;
|
|
52
|
+
function isTxHash(str: any): boolean;
|
|
53
|
+
function isTxHash(str: any): boolean;
|
|
54
|
+
function isTxHex(str: any): boolean;
|
|
55
|
+
function isTxHex(str: any): boolean;
|
|
56
|
+
function isHDPath(str: any): any;
|
|
57
|
+
function isHDPath(str: any): any;
|
|
58
|
+
function isScriptHex(str: any): boolean;
|
|
59
|
+
function isScriptHex(str: any): boolean;
|
|
60
|
+
function isTxSignature(str: any): boolean;
|
|
61
|
+
function isTxSignature(str: any): boolean;
|
|
62
|
+
function isBlockHeight(obj: any): boolean;
|
|
63
|
+
function isBlockHeight(obj: any): boolean;
|
|
64
|
+
}
|
|
65
|
+
export namespace bitcoinCash {
|
|
66
|
+
function isAddress(str: any): boolean;
|
|
67
|
+
function isAddress(str: any): boolean;
|
|
68
|
+
function isTxHash(str: any): boolean;
|
|
69
|
+
function isTxHash(str: any): boolean;
|
|
70
|
+
}
|
|
71
|
+
export namespace ethereum {
|
|
72
|
+
function isAddress(str: any): any;
|
|
73
|
+
function isAddress(str: any): any;
|
|
74
|
+
function isBlockHash(str: any): any;
|
|
75
|
+
function isBlockHash(str: any): any;
|
|
76
|
+
function isTxHash(str: any): any;
|
|
77
|
+
function isTxHash(str: any): any;
|
|
78
|
+
function isAddressCode(str: any): any;
|
|
79
|
+
function isAddressCode(str: any): any;
|
|
80
|
+
function isValidWeiAmount(str: any): boolean;
|
|
81
|
+
function isValidWeiAmount(str: any): boolean;
|
|
82
|
+
}
|
|
83
|
+
export namespace horizen {
|
|
84
|
+
function isAddress(str: any): any;
|
|
85
|
+
function isAddress(str: any): any;
|
|
86
|
+
function isTxHash(str: any): boolean;
|
|
87
|
+
function isTxHash(str: any): boolean;
|
|
88
|
+
}
|
|
89
|
+
export namespace litecoin {
|
|
90
|
+
function isAddress(str: any): boolean;
|
|
91
|
+
function isAddress(str: any): boolean;
|
|
92
|
+
function isTxHash(str: any): boolean;
|
|
93
|
+
function isTxHash(str: any): boolean;
|
|
94
|
+
}
|
|
95
|
+
export namespace ripple {
|
|
96
|
+
function isAddress(str: any): any;
|
|
97
|
+
function isAddress(str: any): any;
|
|
98
|
+
function isTxHash(str: any): boolean;
|
|
99
|
+
function isTxHash(str: any): boolean;
|
|
100
|
+
}
|
|
101
|
+
export namespace stellar {
|
|
102
|
+
function isAddress(str: any): boolean;
|
|
103
|
+
function isAddress(str: any): boolean;
|
|
104
|
+
function isTxHash(str: any): boolean;
|
|
105
|
+
function isTxHash(str: any): boolean;
|
|
106
|
+
}
|
|
107
|
+
export namespace zcash {
|
|
108
|
+
function isAddress(str: any): any;
|
|
109
|
+
function isAddress(str: any): any;
|
|
110
|
+
function isTxHash(str: any): boolean;
|
|
111
|
+
function isTxHash(str: any): boolean;
|
|
112
|
+
}
|
|
113
|
+
export namespace zilliqa {
|
|
114
|
+
function isAddress(str: any): boolean;
|
|
115
|
+
function isAddress(str: any): boolean;
|
|
116
|
+
function isTxHash(str: any): any;
|
|
117
|
+
function isTxHash(str: any): any;
|
|
118
|
+
}
|
|
119
|
+
export namespace algorand {
|
|
120
|
+
function isAddress(str: any): any;
|
|
121
|
+
function isAddress(str: any): any;
|
|
122
|
+
function isTxHash(str: any): boolean;
|
|
123
|
+
function isTxHash(str: any): boolean;
|
|
124
|
+
}
|
|
125
|
+
export namespace tezos {
|
|
126
|
+
function isAddress(str: any): any;
|
|
127
|
+
function isAddress(str: any): any;
|
|
128
|
+
function isTxHash(str: any): boolean;
|
|
129
|
+
function isTxHash(str: any): boolean;
|
|
130
|
+
}
|
|
131
|
+
export namespace polkadot {
|
|
132
|
+
function isAddress(str: any): any;
|
|
133
|
+
function isAddress(str: any): any;
|
|
134
|
+
function isTxHash(str: any): any;
|
|
135
|
+
function isTxHash(str: any): any;
|
|
136
|
+
}
|
|
137
|
+
export namespace cardano {
|
|
138
|
+
function isAddress(str: any): any;
|
|
139
|
+
function isAddress(str: any): any;
|
|
140
|
+
function isTxHash(str: any): boolean;
|
|
141
|
+
function isTxHash(str: any): boolean;
|
|
142
|
+
}
|
|
143
|
+
export namespace cryptocom {
|
|
144
|
+
function isAddress(str: any): any;
|
|
145
|
+
function isAddress(str: any): any;
|
|
146
|
+
function isTxHash(str: any): boolean;
|
|
147
|
+
function isTxHash(str: any): boolean;
|
|
148
|
+
}
|
|
149
|
+
export namespace near {
|
|
150
|
+
function isAddress(str: any): boolean;
|
|
151
|
+
function isAddress(str: any): boolean;
|
|
152
|
+
function isTxHash(str: any): boolean;
|
|
153
|
+
function isTxHash(str: any): boolean;
|
|
154
|
+
}
|
|
155
|
+
export namespace doge {
|
|
156
|
+
function isAddress(str: any): boolean;
|
|
157
|
+
function isAddress(str: any): boolean;
|
|
158
|
+
function isTxHash(str: any): boolean;
|
|
159
|
+
function isTxHash(str: any): boolean;
|
|
160
|
+
}
|
|
161
|
+
export namespace cosmos {
|
|
162
|
+
function isAddress(str: any): boolean;
|
|
163
|
+
function isAddress(str: any): boolean;
|
|
164
|
+
function isTxHash(str: any): any;
|
|
165
|
+
function isTxHash(str: any): any;
|
|
166
|
+
}
|
|
167
|
+
export namespace solana {
|
|
168
|
+
function isAddress(str: any): boolean;
|
|
169
|
+
function isAddress(str: any): boolean;
|
|
170
|
+
function isTxHash(str: any): boolean;
|
|
171
|
+
function isTxHash(str: any): boolean;
|
|
172
|
+
}
|
|
173
|
+
export namespace binanceSmartChain {
|
|
174
|
+
function isAddress(str: any): any;
|
|
175
|
+
function isAddress(str: any): any;
|
|
176
|
+
function isTxHash(str: any): any;
|
|
177
|
+
function isTxHash(str: any): any;
|
|
178
|
+
}
|
|
179
|
+
export namespace polygon {
|
|
180
|
+
function isAddress(str: any): any;
|
|
181
|
+
function isAddress(str: any): any;
|
|
182
|
+
function isTxHash(str: any): any;
|
|
183
|
+
function isTxHash(str: any): any;
|
|
184
|
+
}
|
|
185
|
+
export namespace filecoin {
|
|
186
|
+
function isAddress(str: any): boolean;
|
|
187
|
+
function isAddress(str: any): boolean;
|
|
188
|
+
function isTxHash(str: any): boolean;
|
|
189
|
+
function isTxHash(str: any): boolean;
|
|
190
|
+
}
|
|
191
|
+
export namespace optimism {
|
|
192
|
+
function isAddress(str: any): any;
|
|
193
|
+
function isAddress(str: any): any;
|
|
194
|
+
function isTxHash(str: any): any;
|
|
195
|
+
function isTxHash(str: any): any;
|
|
196
|
+
}
|
|
197
|
+
export namespace avalanche {
|
|
198
|
+
function isAddress(str: any): any;
|
|
199
|
+
function isAddress(str: any): any;
|
|
200
|
+
function isTxHash(str: any): any;
|
|
201
|
+
function isTxHash(str: any): any;
|
|
202
|
+
}
|
|
203
|
+
export namespace arbitrum {
|
|
204
|
+
function isAddress(str: any): any;
|
|
205
|
+
function isAddress(str: any): any;
|
|
206
|
+
function isTxHash(str: any): any;
|
|
207
|
+
function isTxHash(str: any): any;
|
|
208
|
+
}
|
|
209
|
+
export namespace tron {
|
|
210
|
+
function isAddress(str: any): any;
|
|
211
|
+
function isAddress(str: any): any;
|
|
212
|
+
function isTxHash(str: any): any;
|
|
213
|
+
function isTxHash(str: any): any;
|
|
214
|
+
}
|
|
215
|
+
export namespace fantom {
|
|
216
|
+
function isAddress(str: any): any;
|
|
217
|
+
function isAddress(str: any): any;
|
|
218
|
+
function isTxHash(str: any): any;
|
|
219
|
+
function isTxHash(str: any): any;
|
|
220
|
+
}
|
|
221
|
+
export namespace celo {
|
|
222
|
+
function isAddress(str: any): any;
|
|
223
|
+
function isAddress(str: any): any;
|
|
224
|
+
function isTxHash(str: any): any;
|
|
225
|
+
function isTxHash(str: any): any;
|
|
226
|
+
}
|
|
227
|
+
export namespace ethereumClassic {
|
|
228
|
+
function isAddress(str: any): any;
|
|
229
|
+
function isAddress(str: any): any;
|
|
230
|
+
function isTxHash(str: any): any;
|
|
231
|
+
function isTxHash(str: any): any;
|
|
232
|
+
}
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/* eslint no-underscore-dangle: 0 */
|
|
2
|
+
const V = require('validator');
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const { crypto: { Signature }, HDPrivateKey, HDPublicKey, PublicKey, Script, Transaction, } = require('bitcore-lib');
|
|
5
|
+
const addressValidator = require('multicoin-address-validator');
|
|
6
|
+
const zilUtils = require('@zilliqa-js/util');
|
|
7
|
+
const web3 = require('web3-utils');
|
|
8
|
+
const stellarSDK = require('stellar-sdk');
|
|
9
|
+
const E = require('../errors/errors');
|
|
10
|
+
const validations = {
|
|
11
|
+
_validate(Err, pred, x, msg) {
|
|
12
|
+
if (pred(x)) {
|
|
13
|
+
return x;
|
|
14
|
+
}
|
|
15
|
+
throw new Err(msg);
|
|
16
|
+
},
|
|
17
|
+
_validateArg(pred, x, msg) {
|
|
18
|
+
return this._validate(E.InvalidArguments, pred, x, msg);
|
|
19
|
+
},
|
|
20
|
+
_tryCheck(fn, arg) {
|
|
21
|
+
try {
|
|
22
|
+
fn(arg);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
exists(x) {
|
|
30
|
+
return x != null;
|
|
31
|
+
},
|
|
32
|
+
nonEmpty(x) {
|
|
33
|
+
return (x != null ? x.length : undefined) > 0;
|
|
34
|
+
},
|
|
35
|
+
isNonEmptyString(x) {
|
|
36
|
+
return _.isString(x) && (x != null ? x.length : undefined) > 0;
|
|
37
|
+
},
|
|
38
|
+
isSafeString(str) {
|
|
39
|
+
// eslint-disable-next-line no-useless-escape, prefer-regex-literals
|
|
40
|
+
return RegExp(/^(\p{L}|[0-9]|-|=|!|\.|:|\s|@|\+|_|,|\$|£|&)+$/, 'u').test(str);
|
|
41
|
+
},
|
|
42
|
+
ensureShortEnough(limit, x) {
|
|
43
|
+
const l = x != null ? x.length : undefined;
|
|
44
|
+
if (l <= limit) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
throw new E.BadRequest(`Max query size exceeded: ${l} / ${limit}`);
|
|
48
|
+
},
|
|
49
|
+
ensure(crit, msg) {
|
|
50
|
+
if (crit) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
throw new E.BadRequest(msg);
|
|
54
|
+
},
|
|
55
|
+
argExists(x, msg) {
|
|
56
|
+
return this._validateArg(this.exists, x, msg);
|
|
57
|
+
},
|
|
58
|
+
check: {
|
|
59
|
+
matches(required, given, msg) {
|
|
60
|
+
const newGiven = _.uniq(given);
|
|
61
|
+
const crit = _.intersection(newGiven, required).length === given.length;
|
|
62
|
+
if (crit) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
throw new E.BadRequest(msg);
|
|
66
|
+
},
|
|
67
|
+
wasFound(type) {
|
|
68
|
+
return (item) => {
|
|
69
|
+
if (item == null) {
|
|
70
|
+
throw new E.NotFound(`Unknown ${type}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return item;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
wasCreated(msg) {
|
|
78
|
+
return (arr) => {
|
|
79
|
+
if (!arr[1]) {
|
|
80
|
+
throw new E.BadRequest(msg);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return arr;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
isTrue(crit, msg) {
|
|
88
|
+
if (crit) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
throw new E.BadRequest(msg);
|
|
92
|
+
},
|
|
93
|
+
isFalse(crit, msg) {
|
|
94
|
+
if (!crit) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
throw new E.BadRequest(msg);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
isCustomerReference(x) {
|
|
101
|
+
return _.isString(x) && (x != null ? x.length : undefined) > 0 && (x != null ? x.length : undefined) <= 100;
|
|
102
|
+
},
|
|
103
|
+
isCustomerLabelName(x) {
|
|
104
|
+
return _.isString(x) && (x != null ? x.length : undefined) > 0 && (x != null ? x.length : undefined) <= 50;
|
|
105
|
+
},
|
|
106
|
+
binanceChain: {
|
|
107
|
+
isAddress(str) {
|
|
108
|
+
return /^(bnb)([a-z0-9]{39})$/.test(str);
|
|
109
|
+
},
|
|
110
|
+
isTxHash(str) {
|
|
111
|
+
if (!V.isHexadecimal(str)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return str.length === 64;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
bitcoin: {
|
|
118
|
+
isAddress(str) {
|
|
119
|
+
const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
|
|
120
|
+
return typeof str === 'string' && addressValidator.validate(str.trim(), 'btc', network);
|
|
121
|
+
},
|
|
122
|
+
isBech32Address(str) {
|
|
123
|
+
return /^bc1[ac-hj-np-z02-9]{6,86}|^BC1[AC-HJ-NP-Z02-9]{6,86}/.test(str);
|
|
124
|
+
},
|
|
125
|
+
isHDPublicKey(str) {
|
|
126
|
+
try {
|
|
127
|
+
HDPublicKey(str);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
isPublicKey(str) {
|
|
135
|
+
try {
|
|
136
|
+
PublicKey(str);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
isTxHash(str) {
|
|
144
|
+
if (!V.isHexadecimal(str)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return str.length === 64;
|
|
148
|
+
},
|
|
149
|
+
isTxHex(str) {
|
|
150
|
+
if (!V.isHexadecimal(str)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
Transaction(str);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
isHDPath(str) {
|
|
162
|
+
return HDPrivateKey.isValidPath(str);
|
|
163
|
+
},
|
|
164
|
+
isScriptHex(str) {
|
|
165
|
+
if (!V.isHexadecimal(str)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
Script(str);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
isTxSignature(str) {
|
|
177
|
+
if (!V.isHexadecimal(str)) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const b = Buffer.from(str, 'hex');
|
|
182
|
+
Signature.fromTxFormat(b);
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
isBlockHeight(obj) {
|
|
190
|
+
return _.isInteger(+obj) && parseInt(obj, 10) >= 0;
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
bitcoinCash: {
|
|
194
|
+
isAddress(str) {
|
|
195
|
+
return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bitcoincash:)?[q|p][a-z0-9]{41}$|^(BITCOINCASH:)?[Q|P][A-Z0-9]{41}$/.test(str);
|
|
196
|
+
},
|
|
197
|
+
isTxHash(str) {
|
|
198
|
+
if (!V.isHexadecimal(str)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return str.length === 64;
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
ethereum: {
|
|
205
|
+
isAddress(str) {
|
|
206
|
+
return web3.isAddress(str);
|
|
207
|
+
},
|
|
208
|
+
isBlockHash(str) {
|
|
209
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
210
|
+
},
|
|
211
|
+
isTxHash(str) {
|
|
212
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
213
|
+
},
|
|
214
|
+
isAddressCode(str) {
|
|
215
|
+
return web3.isHexStrict(str);
|
|
216
|
+
},
|
|
217
|
+
isValidWeiAmount(str) {
|
|
218
|
+
try {
|
|
219
|
+
web3.fromWei(str);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
horizen: {
|
|
228
|
+
isAddress(str) {
|
|
229
|
+
return addressValidator.validate(str, 'zen');
|
|
230
|
+
},
|
|
231
|
+
isTxHash(str) {
|
|
232
|
+
if (!V.isHexadecimal(str)) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
return str.length === 64;
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
litecoin: {
|
|
239
|
+
isAddress(str) {
|
|
240
|
+
return /^[3LM][a-km-zA-HJ-NP-Z1-9]{24,33}$|^ltc1[ac-hj-np-z02-9]{6,86}$|^LTC1[AC-HJ-NP-Z02-9]{6,86}$|^ltcmweb[a-zA-Z0-9]{114}$/.test(str);
|
|
241
|
+
},
|
|
242
|
+
isTxHash(str) {
|
|
243
|
+
if (!V.isHexadecimal(str)) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
return str.length === 64;
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
ripple: {
|
|
250
|
+
isAddress(str) {
|
|
251
|
+
return addressValidator.validate(str, 'xrp');
|
|
252
|
+
},
|
|
253
|
+
isTxHash(str) {
|
|
254
|
+
if (!V.isHexadecimal(str)) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
return str.length === 64;
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
stellar: {
|
|
261
|
+
isAddress(str) {
|
|
262
|
+
return stellarSDK.StrKey.isValidEd25519PublicKey(str);
|
|
263
|
+
},
|
|
264
|
+
isTxHash(str) {
|
|
265
|
+
if (!V.isHexadecimal(str)) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
return str.length === 64;
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
zcash: {
|
|
272
|
+
isAddress(str) {
|
|
273
|
+
return addressValidator.validate(str, 'zec');
|
|
274
|
+
},
|
|
275
|
+
isTxHash(str) {
|
|
276
|
+
if (!V.isHexadecimal(str)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
return str.length === 64;
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
zilliqa: {
|
|
283
|
+
isAddress(str) {
|
|
284
|
+
return zilUtils.validation.isBech32(str);
|
|
285
|
+
},
|
|
286
|
+
isTxHash(str) {
|
|
287
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
algorand: {
|
|
291
|
+
isAddress(str) {
|
|
292
|
+
return addressValidator.validate(str, 'algo');
|
|
293
|
+
},
|
|
294
|
+
isTxHash(str) {
|
|
295
|
+
return str.length === 52;
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
tezos: {
|
|
299
|
+
isAddress(str) {
|
|
300
|
+
return str[0] !== 'o' && addressValidator.validate(str, 'xtz');
|
|
301
|
+
},
|
|
302
|
+
isTxHash(str) {
|
|
303
|
+
return str.length === 51;
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
polkadot: {
|
|
307
|
+
isAddress(str) {
|
|
308
|
+
return addressValidator.validate(str, 'dot');
|
|
309
|
+
},
|
|
310
|
+
isTxHash(str) {
|
|
311
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
cardano: {
|
|
315
|
+
isAddress(str) {
|
|
316
|
+
return addressValidator.validate(str, 'ada');
|
|
317
|
+
},
|
|
318
|
+
isTxHash(str) {
|
|
319
|
+
if (!V.isHexadecimal(str)) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
return str.length === 64;
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
cryptocom: {
|
|
326
|
+
isAddress(str) {
|
|
327
|
+
return addressValidator.validate(str, 'cro');
|
|
328
|
+
},
|
|
329
|
+
isTxHash(str) {
|
|
330
|
+
if (!V.isHexadecimal(str)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
return str.length === 64;
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
near: {
|
|
337
|
+
isAddress(str) {
|
|
338
|
+
// https://nomicon.io/DataStructures/Account
|
|
339
|
+
return /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/.test(str);
|
|
340
|
+
},
|
|
341
|
+
isTxHash(str) {
|
|
342
|
+
return str.length === 44 || str.length === 43;
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
doge: {
|
|
346
|
+
isAddress(str) {
|
|
347
|
+
return /^[a-zA-Z\d]{34}$/.test(str);
|
|
348
|
+
},
|
|
349
|
+
isTxHash(str) {
|
|
350
|
+
return str.length === 64;
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
cosmos: {
|
|
354
|
+
isAddress(str) {
|
|
355
|
+
return /^cosmos{1}[a-zA-Z\d]{39}$/.test(str);
|
|
356
|
+
},
|
|
357
|
+
isTxHash(str) {
|
|
358
|
+
return str.length === 64 && web3.isHex(str);
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
solana: {
|
|
362
|
+
isAddress(str) {
|
|
363
|
+
return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(str);
|
|
364
|
+
},
|
|
365
|
+
isTxHash(str) {
|
|
366
|
+
return /^[1-9A-HJ-NP-Za-km-z]{77,88}$/.test(str);
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
binanceSmartChain: {
|
|
370
|
+
isAddress(str) {
|
|
371
|
+
return web3.isAddress(str);
|
|
372
|
+
},
|
|
373
|
+
isTxHash(str) {
|
|
374
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
polygon: {
|
|
378
|
+
isAddress(str) {
|
|
379
|
+
return web3.isAddress(str);
|
|
380
|
+
},
|
|
381
|
+
isTxHash(str) {
|
|
382
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
filecoin: {
|
|
386
|
+
isAddress(str) {
|
|
387
|
+
return /^(f0|f1|f2|f3)/.test(str);
|
|
388
|
+
},
|
|
389
|
+
isTxHash(str) {
|
|
390
|
+
return str.length === 62 && /^bafy2bza/.test(str);
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
optimism: {
|
|
394
|
+
isAddress(str) {
|
|
395
|
+
return web3.isAddress(str);
|
|
396
|
+
},
|
|
397
|
+
isTxHash(str) {
|
|
398
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
avalanche: {
|
|
402
|
+
isAddress(str) {
|
|
403
|
+
return web3.isAddress(str);
|
|
404
|
+
},
|
|
405
|
+
isTxHash(str) {
|
|
406
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
arbitrum: {
|
|
410
|
+
isAddress(str) {
|
|
411
|
+
return web3.isAddress(str);
|
|
412
|
+
},
|
|
413
|
+
isTxHash(str) {
|
|
414
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
tron: {
|
|
418
|
+
isAddress(str) {
|
|
419
|
+
return addressValidator.validate(str, 'tron');
|
|
420
|
+
},
|
|
421
|
+
isTxHash(str) {
|
|
422
|
+
return str.length === 64 && web3.isHex(str);
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
fantom: {
|
|
426
|
+
isAddress(str) {
|
|
427
|
+
return web3.isAddress(str);
|
|
428
|
+
},
|
|
429
|
+
isTxHash(str) {
|
|
430
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
celo: {
|
|
434
|
+
isAddress(str) {
|
|
435
|
+
return web3.isAddress(str);
|
|
436
|
+
},
|
|
437
|
+
isTxHash(str) {
|
|
438
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
ethereumClassic: {
|
|
442
|
+
isAddress(str) {
|
|
443
|
+
return web3.isAddress(str);
|
|
444
|
+
},
|
|
445
|
+
isTxHash(str) {
|
|
446
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
Object.keys(V).forEach((k) => {
|
|
451
|
+
const v = V[k];
|
|
452
|
+
// don't trigger validation with null values (prevents swagger 500 error)
|
|
453
|
+
validations[k] = (x) => (x === null ? false : v(x));
|
|
454
|
+
});
|
|
455
|
+
module.exports = validations;
|
|
456
|
+
//# sourceMappingURL=validations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/validations/validations.js"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAC/B,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EACJ,MAAM,EAAE,EAAE,SAAS,EAAE,EACrB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,MAAM,EACN,WAAW,GACZ,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC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,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitzeRows.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/sanitzeRows.ts"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5F,SAAS,YAAY,CAA4B,UAAsB,EAAE,UAAgC;IACvG,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAErE,MAAM,oBAAoB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEnF,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,qBAAqB,EAAE,UAAU,CAAC,MAAM,GAAG,qBAAqB,GAAG,oBAAoB,CAAC,CAAC;IAEjI,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9C,IAAI,QAAQ,CAAC,OAAO,EAAE;QACpB,OAAO,aAAa,CAAC;KACtB;IACD,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
|
File without changes
|