@ellipticltd/aml-utils 0.2.2 → 0.4.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/.circleci/config.yml +49 -0
- package/.eslintrc +19 -2
- package/.idea/workspace.xml +29 -12
- package/.nycrc.json +11 -0
- package/codecov.yml +29 -0
- package/lib/formatting.js +1 -1
- package/lib/middleware.js +1 -1
- package/lib/ormHelpers.js +12 -13
- package/lib/types.js +10 -8
- package/lib/validations.js +51 -41
- package/package.json +20 -11
- package/.npmignore +0 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
executors:
|
|
4
|
+
node-8_4:
|
|
5
|
+
docker:
|
|
6
|
+
- image: circleci/node:8.4.0
|
|
7
|
+
working_directory: /tmp/workspace
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
install:
|
|
11
|
+
executor: node-8_4
|
|
12
|
+
steps:
|
|
13
|
+
- checkout
|
|
14
|
+
- restore_cache:
|
|
15
|
+
keys:
|
|
16
|
+
- npm-cache-{{ checksum "package-lock.json" }}
|
|
17
|
+
- run:
|
|
18
|
+
name: install node modules
|
|
19
|
+
command: |
|
|
20
|
+
npm i
|
|
21
|
+
- save_cache:
|
|
22
|
+
key: npm-cache-{{ checksum "package-lock.json" }}
|
|
23
|
+
paths:
|
|
24
|
+
- node_modules
|
|
25
|
+
- persist_to_workspace:
|
|
26
|
+
root: /tmp
|
|
27
|
+
paths:
|
|
28
|
+
- workspace
|
|
29
|
+
|
|
30
|
+
unit_test:
|
|
31
|
+
executor: node-8_4
|
|
32
|
+
steps:
|
|
33
|
+
- attach_workspace:
|
|
34
|
+
at: /tmp
|
|
35
|
+
- run:
|
|
36
|
+
name: unit_test
|
|
37
|
+
command: npm run coverage
|
|
38
|
+
- store_artifacts:
|
|
39
|
+
path: coverage
|
|
40
|
+
|
|
41
|
+
workflows:
|
|
42
|
+
version: 2.1
|
|
43
|
+
build-test-deploy:
|
|
44
|
+
jobs:
|
|
45
|
+
- install
|
|
46
|
+
|
|
47
|
+
- unit_test:
|
|
48
|
+
requires:
|
|
49
|
+
- install
|
package/.eslintrc
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": [
|
|
3
|
-
|
|
2
|
+
"extends": [
|
|
3
|
+
"airbnb"
|
|
4
|
+
],
|
|
5
|
+
"overrides": [
|
|
6
|
+
{
|
|
7
|
+
"files": [
|
|
8
|
+
"*.spec.js",
|
|
9
|
+
],
|
|
10
|
+
"env": {
|
|
11
|
+
"mocha": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"rules": {
|
|
16
|
+
"no-underscore-dangle": 0,
|
|
17
|
+
"prefer-object-spread": 0,
|
|
18
|
+
"new-parens": 0
|
|
19
|
+
}
|
|
20
|
+
}
|
package/.idea/workspace.xml
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
|
-
<list default="true" id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment=""
|
|
4
|
+
<list default="true" id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment="">
|
|
5
|
+
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
6
|
+
</list>
|
|
5
7
|
<ignored path="$PROJECT_DIR$/.tmp/" />
|
|
6
8
|
<ignored path="$PROJECT_DIR$/temp/" />
|
|
7
9
|
<ignored path="$PROJECT_DIR$/tmp/" />
|
|
@@ -14,20 +16,20 @@
|
|
|
14
16
|
</component>
|
|
15
17
|
<component name="FileEditorManager">
|
|
16
18
|
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
|
17
|
-
<file leaf-file-name="package.json" pinned="false" current-in-tab="
|
|
19
|
+
<file leaf-file-name="package.json" pinned="false" current-in-tab="true">
|
|
18
20
|
<entry file="file://$PROJECT_DIR$/package.json">
|
|
19
21
|
<provider selected="true" editor-type-id="text-editor">
|
|
20
|
-
<state relative-caret-position="
|
|
21
|
-
<caret line="
|
|
22
|
+
<state relative-caret-position="26">
|
|
23
|
+
<caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
|
|
22
24
|
</state>
|
|
23
25
|
</provider>
|
|
24
26
|
</entry>
|
|
25
27
|
</file>
|
|
26
|
-
<file leaf-file-name="validations.js" pinned="false" current-in-tab="
|
|
28
|
+
<file leaf-file-name="validations.js" pinned="false" current-in-tab="false">
|
|
27
29
|
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
28
30
|
<provider selected="true" editor-type-id="text-editor">
|
|
29
31
|
<state relative-caret-position="399">
|
|
30
|
-
<caret line="148" column="7"
|
|
32
|
+
<caret line="148" column="7" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
31
33
|
</state>
|
|
32
34
|
</provider>
|
|
33
35
|
</entry>
|
|
@@ -45,8 +47,8 @@
|
|
|
45
47
|
<component name="IdeDocumentHistory">
|
|
46
48
|
<option name="CHANGED_PATHS">
|
|
47
49
|
<list>
|
|
48
|
-
<option value="$PROJECT_DIR$/package.json" />
|
|
49
50
|
<option value="$PROJECT_DIR$/lib/validations.js" />
|
|
51
|
+
<option value="$PROJECT_DIR$/package.json" />
|
|
50
52
|
</list>
|
|
51
53
|
</option>
|
|
52
54
|
</component>
|
|
@@ -129,11 +131,12 @@
|
|
|
129
131
|
<updated>1563360614655</updated>
|
|
130
132
|
<workItem from="1563360615721" duration="151000" />
|
|
131
133
|
<workItem from="1567667753338" duration="597000" />
|
|
134
|
+
<workItem from="1574357456118" duration="8000" />
|
|
132
135
|
</task>
|
|
133
136
|
<servers />
|
|
134
137
|
</component>
|
|
135
138
|
<component name="TimeTrackingManager">
|
|
136
|
-
<option name="totallyTimeSpent" value="
|
|
139
|
+
<option name="totallyTimeSpent" value="756000" />
|
|
137
140
|
</component>
|
|
138
141
|
<component name="ToolWindowManager">
|
|
139
142
|
<frame x="0" y="23" width="1920" height="1057" extended-state="6" />
|
|
@@ -143,8 +146,8 @@
|
|
|
143
146
|
<window_info anchor="bottom" id="TODO" order="6" />
|
|
144
147
|
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
|
145
148
|
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
|
|
146
|
-
<window_info id="npm" order="2" side_tool="true" />
|
|
147
149
|
<window_info anchor="bottom" id="Version Control" order="7" />
|
|
150
|
+
<window_info id="npm" order="2" side_tool="true" />
|
|
148
151
|
<window_info anchor="bottom" id="Run" order="2" />
|
|
149
152
|
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
|
150
153
|
<window_info anchor="bottom" id="Terminal" order="7" />
|
|
@@ -169,21 +172,35 @@
|
|
|
169
172
|
<entry file="file://$PROJECT_DIR$/package.json">
|
|
170
173
|
<provider selected="true" editor-type-id="text-editor">
|
|
171
174
|
<state relative-caret-position="364">
|
|
172
|
-
<caret line="28" column="
|
|
175
|
+
<caret line="28" column="27" lean-forward="true" selection-start-line="28" selection-start-column="27" selection-end-line="28" selection-end-column="27" />
|
|
176
|
+
</state>
|
|
177
|
+
</provider>
|
|
178
|
+
</entry>
|
|
179
|
+
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
180
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
181
|
+
<state relative-caret-position="1924">
|
|
182
|
+
<caret line="148" column="7" lean-forward="true" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
173
183
|
</state>
|
|
174
184
|
</provider>
|
|
175
185
|
</entry>
|
|
176
186
|
<entry file="file://$PROJECT_DIR$/package.json">
|
|
177
187
|
<provider selected="true" editor-type-id="text-editor">
|
|
178
188
|
<state relative-caret-position="364">
|
|
179
|
-
<caret line="28" column="
|
|
189
|
+
<caret line="28" column="24" selection-start-line="28" selection-start-column="24" selection-end-line="28" selection-end-column="24" />
|
|
180
190
|
</state>
|
|
181
191
|
</provider>
|
|
182
192
|
</entry>
|
|
183
193
|
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
184
194
|
<provider selected="true" editor-type-id="text-editor">
|
|
185
195
|
<state relative-caret-position="399">
|
|
186
|
-
<caret line="148" column="7"
|
|
196
|
+
<caret line="148" column="7" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
197
|
+
</state>
|
|
198
|
+
</provider>
|
|
199
|
+
</entry>
|
|
200
|
+
<entry file="file://$PROJECT_DIR$/package.json">
|
|
201
|
+
<provider selected="true" editor-type-id="text-editor">
|
|
202
|
+
<state relative-caret-position="26">
|
|
203
|
+
<caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
|
|
187
204
|
</state>
|
|
188
205
|
</provider>
|
|
189
206
|
</entry>
|
package/.nycrc.json
ADDED
package/codecov.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
codecov:
|
|
2
|
+
require_ci_to_pass: yes
|
|
3
|
+
|
|
4
|
+
coverage:
|
|
5
|
+
precision: 2
|
|
6
|
+
round: down
|
|
7
|
+
range: "70...100"
|
|
8
|
+
|
|
9
|
+
status:
|
|
10
|
+
project:
|
|
11
|
+
default:
|
|
12
|
+
target: 85%
|
|
13
|
+
patch:
|
|
14
|
+
default:
|
|
15
|
+
target: 85%
|
|
16
|
+
changes: no
|
|
17
|
+
|
|
18
|
+
parsers:
|
|
19
|
+
gcov:
|
|
20
|
+
branch_detection:
|
|
21
|
+
conditional: yes
|
|
22
|
+
loop: yes
|
|
23
|
+
method: no
|
|
24
|
+
macro: no
|
|
25
|
+
|
|
26
|
+
comment:
|
|
27
|
+
layout: "reach,diff,flags,tree"
|
|
28
|
+
behavior: default
|
|
29
|
+
require_changes: no
|
package/lib/formatting.js
CHANGED
|
@@ -10,7 +10,7 @@ const rethrowError = (fnName, e) => {
|
|
|
10
10
|
return `${fnName} - ${e.name}: ${e.statusCode} - ${formattedError}`;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const sqlEscapeWildcard = str => str.replace(/_|%|\\/g, x => `\\${x}`);
|
|
13
|
+
const sqlEscapeWildcard = (str) => str.replace(/_|%|\\/g, (x) => `\\${x}`);
|
|
14
14
|
|
|
15
15
|
module.exports = {
|
|
16
16
|
rethrowError,
|
package/lib/middleware.js
CHANGED
package/lib/ormHelpers.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
|
|
3
|
-
const includeNested = (orm, models) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
3
|
+
const includeNested = (orm, models) => _.map(_.toPairs(models), (arg) => {
|
|
4
|
+
const [modelName, inclusion] = arg;
|
|
5
|
+
const include = includeNested(orm, inclusion);
|
|
6
|
+
const model = orm[modelName];
|
|
7
|
+
if (_.isEmpty(include)) {
|
|
8
|
+
return model;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
model,
|
|
12
|
+
include,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
16
15
|
|
|
17
16
|
module.exports = {
|
|
18
17
|
includeNested,
|
package/lib/types.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const TC = require('type-check');
|
|
2
2
|
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
|
|
3
5
|
const E = require('./errors');
|
|
4
6
|
|
|
5
7
|
const V = require('./validations');
|
|
6
8
|
|
|
7
|
-
const _ = require('lodash');
|
|
8
|
-
|
|
9
9
|
const customTypes = {
|
|
10
10
|
Integer: {
|
|
11
11
|
typeOf: 'Number',
|
|
@@ -152,8 +152,7 @@ const withNullable = Object.keys(customTypes).reduce((acc, _type) => {
|
|
|
152
152
|
|
|
153
153
|
// for every type, add Nullable+type. A nullable string can also be empty
|
|
154
154
|
acc[`Nullable${_type}`] = Object.assign({}, customTypes[_type], {
|
|
155
|
-
validate: x =>
|
|
156
|
-
x == null || (typeOf === 'String' && x === '') || validate(x),
|
|
155
|
+
validate: (x) => x == null || (typeOf === 'String' && x === '') || validate(x),
|
|
157
156
|
});
|
|
158
157
|
|
|
159
158
|
return acc;
|
|
@@ -176,10 +175,13 @@ module.exports = {
|
|
|
176
175
|
return V.ensure(this.typeCheck(type, obj), msg);
|
|
177
176
|
},
|
|
178
177
|
checkArg(obj, prop, type, msg) {
|
|
178
|
+
let message;
|
|
179
179
|
if (msg == null) {
|
|
180
|
-
|
|
180
|
+
message = `Invalid ${prop}`;
|
|
181
|
+
} else {
|
|
182
|
+
message = msg;
|
|
181
183
|
}
|
|
182
|
-
this.ensureType(type, obj[prop],
|
|
184
|
+
this.ensureType(type, obj[prop], message);
|
|
183
185
|
return obj[prop];
|
|
184
186
|
},
|
|
185
187
|
checkArgs(input, types) {
|
|
@@ -197,8 +199,8 @@ module.exports = {
|
|
|
197
199
|
numKeys = 0;
|
|
198
200
|
|
|
199
201
|
Object.keys(fields).forEach((key) => {
|
|
200
|
-
|
|
201
|
-
V.ensure(this.parsedTypeCheck(
|
|
202
|
+
const objTypes = fields[key];
|
|
203
|
+
V.ensure(this.parsedTypeCheck(objTypes, input[key]), `Invalid ${key}`);
|
|
202
204
|
if (inputKeys[key]) {
|
|
203
205
|
numKeys += 1;
|
|
204
206
|
}
|
package/lib/validations.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const E = require('./errors');
|
|
2
1
|
const V = require('validator');
|
|
3
2
|
const _ = require('lodash');
|
|
4
3
|
const {
|
|
@@ -11,6 +10,7 @@ const {
|
|
|
11
10
|
} = require('bitcore-lib');
|
|
12
11
|
const addressValidator = require('wallet-address-validator');
|
|
13
12
|
const web3 = require('web3-utils');
|
|
13
|
+
const E = require('./errors');
|
|
14
14
|
|
|
15
15
|
const validations = {
|
|
16
16
|
_validate(Err, pred, x, msg) {
|
|
@@ -59,8 +59,8 @@ const validations = {
|
|
|
59
59
|
|
|
60
60
|
check: {
|
|
61
61
|
matches(required, given, msg) {
|
|
62
|
-
|
|
63
|
-
const crit = _.intersection(
|
|
62
|
+
const newGiven = _.uniq(given);
|
|
63
|
+
const crit = _.intersection(newGiven, required).length === given.length;
|
|
64
64
|
if (crit) {
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
@@ -100,44 +100,21 @@ const validations = {
|
|
|
100
100
|
|
|
101
101
|
isCustomerReference(x) {
|
|
102
102
|
return (
|
|
103
|
-
_.isString(x)
|
|
104
|
-
(x != null ? x.length : undefined) > 0
|
|
105
|
-
(x != null ? x.length : undefined) <= 100
|
|
103
|
+
_.isString(x)
|
|
104
|
+
&& (x != null ? x.length : undefined) > 0
|
|
105
|
+
&& (x != null ? x.length : undefined) <= 100
|
|
106
106
|
);
|
|
107
107
|
},
|
|
108
108
|
isCustomerLabelName(x) {
|
|
109
109
|
return (
|
|
110
|
-
_.isString(x)
|
|
111
|
-
(x != null ? x.length : undefined) > 0
|
|
112
|
-
(x != null ? x.length : undefined) <= 50
|
|
110
|
+
_.isString(x)
|
|
111
|
+
&& (x != null ? x.length : undefined) > 0
|
|
112
|
+
&& (x != null ? x.length : undefined) <= 50
|
|
113
113
|
);
|
|
114
114
|
},
|
|
115
|
-
ethereum: {
|
|
116
|
-
isAddress(str) {
|
|
117
|
-
return web3.isAddress(str);
|
|
118
|
-
},
|
|
119
|
-
isBlockHash(str) {
|
|
120
|
-
return str.length === 66 && web3.isHexStrict(str);
|
|
121
|
-
},
|
|
122
|
-
isTxHash(str) {
|
|
123
|
-
return str.length === 66 && web3.isHexStrict(str);
|
|
124
|
-
},
|
|
125
|
-
isAddressCode(str) {
|
|
126
|
-
return web3.isHexStrict(str);
|
|
127
|
-
},
|
|
128
|
-
isValidWeiAmount(str) {
|
|
129
|
-
try {
|
|
130
|
-
web3.fromWei(str);
|
|
131
|
-
return true;
|
|
132
|
-
} catch (e) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
115
|
bitcoin: {
|
|
138
116
|
isAddress(str) {
|
|
139
|
-
const network =
|
|
140
|
-
process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
|
|
117
|
+
const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
|
|
141
118
|
return typeof str === 'string' && addressValidator.validate(str.trim(), 'BTC', network);
|
|
142
119
|
},
|
|
143
120
|
isBech32Address(str) {
|
|
@@ -160,13 +137,13 @@ const validations = {
|
|
|
160
137
|
}
|
|
161
138
|
},
|
|
162
139
|
isTxHash(str) {
|
|
163
|
-
if (!V.isHexadecimal(
|
|
140
|
+
if (!V.isHexadecimal(str)) {
|
|
164
141
|
return false;
|
|
165
142
|
}
|
|
166
143
|
return str.length === 64;
|
|
167
144
|
},
|
|
168
145
|
isTxHex(str) {
|
|
169
|
-
if (!V.isHexadecimal(
|
|
146
|
+
if (!V.isHexadecimal(str)) {
|
|
170
147
|
return false;
|
|
171
148
|
}
|
|
172
149
|
try {
|
|
@@ -180,7 +157,7 @@ const validations = {
|
|
|
180
157
|
return HDPrivateKey.isValidPath(str);
|
|
181
158
|
},
|
|
182
159
|
isScriptHex(str) {
|
|
183
|
-
if (!V.isHexadecimal(
|
|
160
|
+
if (!V.isHexadecimal(str)) {
|
|
184
161
|
return false;
|
|
185
162
|
}
|
|
186
163
|
try {
|
|
@@ -191,7 +168,7 @@ const validations = {
|
|
|
191
168
|
}
|
|
192
169
|
},
|
|
193
170
|
isTxSignature(str) {
|
|
194
|
-
if (!V.isHexadecimal(
|
|
171
|
+
if (!V.isHexadecimal(str)) {
|
|
195
172
|
return false;
|
|
196
173
|
}
|
|
197
174
|
try {
|
|
@@ -211,29 +188,62 @@ const validations = {
|
|
|
211
188
|
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);
|
|
212
189
|
},
|
|
213
190
|
isTxHash(str) {
|
|
214
|
-
if (!V.isHexadecimal(
|
|
191
|
+
if (!V.isHexadecimal(str)) {
|
|
215
192
|
return false;
|
|
216
193
|
}
|
|
217
194
|
return str.length === 64;
|
|
218
195
|
},
|
|
219
196
|
},
|
|
197
|
+
ethereum: {
|
|
198
|
+
isAddress(str) {
|
|
199
|
+
return web3.isAddress(str);
|
|
200
|
+
},
|
|
201
|
+
isBlockHash(str) {
|
|
202
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
203
|
+
},
|
|
204
|
+
isTxHash(str) {
|
|
205
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
206
|
+
},
|
|
207
|
+
isAddressCode(str) {
|
|
208
|
+
return web3.isHexStrict(str);
|
|
209
|
+
},
|
|
210
|
+
isValidWeiAmount(str) {
|
|
211
|
+
try {
|
|
212
|
+
web3.fromWei(str);
|
|
213
|
+
return true;
|
|
214
|
+
} catch (e) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
},
|
|
220
219
|
litecoin: {
|
|
221
220
|
isAddress(str) {
|
|
222
221
|
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}$/.test(str);
|
|
223
222
|
},
|
|
224
223
|
isTxHash(str) {
|
|
225
|
-
if (!V.isHexadecimal(
|
|
224
|
+
if (!V.isHexadecimal(str)) {
|
|
226
225
|
return false;
|
|
227
226
|
}
|
|
228
227
|
return str.length === 64;
|
|
229
228
|
},
|
|
230
|
-
}
|
|
229
|
+
},
|
|
230
|
+
ripple: {
|
|
231
|
+
isAddress(str) {
|
|
232
|
+
return addressValidator.validate(str, 'XRP');
|
|
233
|
+
},
|
|
234
|
+
isTxHash(str) {
|
|
235
|
+
if (!V.isHexadecimal(str)) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
return str.length === 64;
|
|
239
|
+
},
|
|
240
|
+
},
|
|
231
241
|
};
|
|
232
242
|
|
|
233
243
|
Object.keys(V).forEach((k) => {
|
|
234
244
|
const v = V[k];
|
|
235
245
|
// don't trigger validation with null values (prevents swagger 500 error)
|
|
236
|
-
validations[k] = x => (x === null ? false : v(x));
|
|
246
|
+
validations[k] = (x) => (x === null ? false : v(x));
|
|
237
247
|
});
|
|
238
248
|
|
|
239
249
|
module.exports = validations;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ellipticltd/aml-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Utilities, helpers, validations, type-checking, etc",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "10.1.0",
|
|
@@ -13,28 +13,37 @@
|
|
|
13
13
|
"homepage": "https://bitbucket.org/elliptic/aml-utils#readme",
|
|
14
14
|
"main": "index.js",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"test": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
|
|
16
|
+
"test:unit": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
|
|
17
17
|
"compile": "./node_modules/coffee-script/bin/coffee -c index.coffee **/*.coffee",
|
|
18
|
-
"preprocess": "npm run compile"
|
|
18
|
+
"preprocess": "npm run compile",
|
|
19
|
+
"lint": "./node_modules/.bin/eslint --color 'lib/**/*.js' 'test/**/*.js' ",
|
|
20
|
+
"test": "nyc npm run test:unit && nyc report --reporter=html",
|
|
21
|
+
"coverage": "nyc npm run test:unit && nyc report --reporter=lcov --reporter=text-lcov | codecov --pipe"
|
|
19
22
|
},
|
|
20
23
|
"author": "Adam Joyce <adam@ellipitc.co>",
|
|
21
24
|
"license": "MIT",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"bitcore-lib": "
|
|
26
|
+
"bitcore-lib": "^8.10.1",
|
|
24
27
|
"create-error": "0.3.1",
|
|
25
|
-
"lodash": "^4.17.
|
|
28
|
+
"lodash": "^4.17.15",
|
|
26
29
|
"type-check": "0.3.2",
|
|
27
30
|
"validator": "10.10.0",
|
|
28
31
|
"wallet-address-validator": "0.2.4",
|
|
29
32
|
"web3-utils": "1.0.0"
|
|
30
33
|
},
|
|
31
34
|
"devDependencies": {
|
|
32
|
-
"@ellipticltd/eslint-config": "0.0.3",
|
|
33
35
|
"chai": "4.1.1",
|
|
36
|
+
"codecov": "^3.6.1",
|
|
34
37
|
"coffee-script": "1.12.7",
|
|
35
|
-
"eslint": "
|
|
36
|
-
"eslint-config-airbnb
|
|
37
|
-
"eslint-
|
|
38
|
-
"
|
|
38
|
+
"eslint": "^6.6.0",
|
|
39
|
+
"eslint-config-airbnb": "^18.0.1",
|
|
40
|
+
"eslint-config-airbnb-base": "^14.0.0",
|
|
41
|
+
"eslint-plugin-coffeescript": "^1.0.0",
|
|
42
|
+
"eslint-plugin-import": "^2.18.2",
|
|
43
|
+
"eslint-plugin-jsx-a11y": "^6.2.3",
|
|
44
|
+
"eslint-plugin-react": "^7.16.0",
|
|
45
|
+
"mocha": "3.5.0",
|
|
46
|
+
"mocha-lcov-reporter": "^1.3.0",
|
|
47
|
+
"nyc": "^14.1.1"
|
|
39
48
|
}
|
|
40
|
-
}
|
|
49
|
+
}
|
package/.npmignore
DELETED