@ellipticltd/aml-utils 0.1.2 → 0.2.0-bech32-address
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/.idea/codeStyles/Project.xml +0 -24
- package/.idea/dbnavigator.xml +4 -6
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +0 -40
- package/.idea/workspace.xml +69 -426
- package/lib/validations.js +3 -0
- package/package.json +1 -1
- package/.idea/encodings.xml +0 -4
- package/.idea/markdown-navigator/profiles_settings.xml +0 -3
- package/.idea/markdown-navigator.xml +0 -86
- package/dist/errors.d.ts +0 -12
- package/dist/errors.js +0 -43
- package/dist/formatting.d.ts +0 -10
- package/dist/formatting.js +0 -25
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -14
- package/dist/middleware.d.ts +0 -8
- package/dist/middleware.js +0 -23
- package/dist/ormHelpers.d.ts +0 -4
- package/dist/ormHelpers.js +0 -25
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -2
- package/dist/types.d.ts +0 -14
- package/dist/types.js +0 -207
- package/dist/validations.d.ts +0 -49
- package/dist/validations.js +0 -242
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="MarkdownProjectSettings" wasCopied="false">
|
|
4
|
-
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
|
|
5
|
-
<PanelProvider>
|
|
6
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
|
7
|
-
</PanelProvider>
|
|
8
|
-
</PreviewSettings>
|
|
9
|
-
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
|
|
10
|
-
<PegdownExtensions>
|
|
11
|
-
<option name="ABBREVIATIONS" value="false" />
|
|
12
|
-
<option name="ANCHORLINKS" value="true" />
|
|
13
|
-
<option name="ASIDE" value="false" />
|
|
14
|
-
<option name="ATXHEADERSPACE" value="true" />
|
|
15
|
-
<option name="AUTOLINKS" value="false" />
|
|
16
|
-
<option name="DEFINITIONS" value="false" />
|
|
17
|
-
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
|
18
|
-
<option name="FENCED_CODE_BLOCKS" value="true" />
|
|
19
|
-
<option name="FOOTNOTES" value="false" />
|
|
20
|
-
<option name="HARDWRAPS" value="false" />
|
|
21
|
-
<option name="HTML_DEEP_PARSER" value="false" />
|
|
22
|
-
<option name="INSERTED" value="false" />
|
|
23
|
-
<option name="QUOTES" value="false" />
|
|
24
|
-
<option name="RELAXEDHRULES" value="true" />
|
|
25
|
-
<option name="SMARTS" value="false" />
|
|
26
|
-
<option name="STRIKETHROUGH" value="true" />
|
|
27
|
-
<option name="SUBSCRIPT" value="false" />
|
|
28
|
-
<option name="SUPERSCRIPT" value="false" />
|
|
29
|
-
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
|
30
|
-
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
|
31
|
-
<option name="TABLES" value="true" />
|
|
32
|
-
<option name="TASKLISTITEMS" value="true" />
|
|
33
|
-
<option name="TOC" value="false" />
|
|
34
|
-
<option name="WIKILINKS" value="false" />
|
|
35
|
-
</PegdownExtensions>
|
|
36
|
-
<ParserOptions>
|
|
37
|
-
<option name="ADMONITION_EXT" value="false" />
|
|
38
|
-
<option name="ATTRIBUTES_EXT" value="false" />
|
|
39
|
-
<option name="COMMONMARK_LISTS" value="true" />
|
|
40
|
-
<option name="DUMMY" value="false" />
|
|
41
|
-
<option name="EMOJI_SHORTCUTS" value="true" />
|
|
42
|
-
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
|
|
43
|
-
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
|
44
|
-
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
|
45
|
-
<option name="GFM_TABLE_RENDERING" value="true" />
|
|
46
|
-
<option name="GITBOOK_URL_ENCODING" value="false" />
|
|
47
|
-
<option name="GITHUB_LISTS" value="false" />
|
|
48
|
-
<option name="GITHUB_WIKI_LINKS" value="false" />
|
|
49
|
-
<option name="GITLAB_EXT" value="false" />
|
|
50
|
-
<option name="GITLAB_MATH_EXT" value="false" />
|
|
51
|
-
<option name="GITLAB_MERMAID_EXT" value="false" />
|
|
52
|
-
<option name="HEADER_ID_NON_ASCII_TO_LOWERCASE" value="false" />
|
|
53
|
-
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
|
|
54
|
-
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
|
55
|
-
<option name="MACROS_EXT" value="false" />
|
|
56
|
-
<option name="NO_TEXT_ATTRIBUTES" value="false" />
|
|
57
|
-
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
|
|
58
|
-
<option name="PLANTUML_FENCED_CODE" value="false" />
|
|
59
|
-
<option name="PUML_FENCED_CODE" value="false" />
|
|
60
|
-
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
|
61
|
-
</ParserOptions>
|
|
62
|
-
</ParserSettings>
|
|
63
|
-
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" plantUmlConversion="0" mathConversion="0">
|
|
64
|
-
<GeneratorProvider>
|
|
65
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
|
66
|
-
</GeneratorProvider>
|
|
67
|
-
<headerTop />
|
|
68
|
-
<headerBottom />
|
|
69
|
-
<bodyTop />
|
|
70
|
-
<bodyBottom />
|
|
71
|
-
</HtmlSettings>
|
|
72
|
-
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
|
|
73
|
-
<StylesheetProvider>
|
|
74
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
|
75
|
-
</StylesheetProvider>
|
|
76
|
-
<ScriptProviders />
|
|
77
|
-
<cssText />
|
|
78
|
-
<cssUriHistory />
|
|
79
|
-
</CssSettings>
|
|
80
|
-
<AnnotatorSettings targetHasSpaces="true" linkCaseMismatch="true" wikiCaseMismatch="true" wikiLinkHasDashes="true" notUnderWikiHome="true" targetNotWikiPageExt="true" notUnderSourceWikiHome="true" targetNameHasAnchor="true" targetPathHasAnchor="true" wikiLinkHasSlash="true" wikiLinkHasSubdir="true" wikiLinkHasOnlyAnchor="true" linkTargetsWikiHasExt="true" linkTargetsWikiHasBadExt="true" notUnderSameRepo="true" targetNotUnderVcs="false" linkNeedsExt="true" linkHasBadExt="true" linkTargetNeedsExt="true" linkTargetHasBadExt="true" wikiLinkNotInWiki="true" imageTargetNotInRaw="true" repoRelativeAcrossVcsRoots="true" multipleWikiTargetsMatch="true" unresolvedLinkReference="true" linkIsIgnored="true" anchorIsIgnored="true" anchorIsUnresolved="true" anchorLineReferenceIsUnresolved="true" anchorLineReferenceFormat="true" anchorHasDuplicates="true" abbreviationDuplicates="true" abbreviationNotUsed="true" attributeIdDuplicateDefinition="true" attributeIdNotUsed="true" footnoteDuplicateDefinition="true" footnoteUnresolved="true" footnoteDuplicates="true" footnoteNotUsed="true" macroDuplicateDefinition="true" macroUnresolved="true" macroDuplicates="true" macroNotUsed="true" referenceDuplicateDefinition="true" referenceUnresolved="true" referenceDuplicates="true" referenceNotUsed="true" referenceUnresolvedNumericId="true" enumRefDuplicateDefinition="true" enumRefUnresolved="true" enumRefDuplicates="true" enumRefNotUsed="true" enumRefLinkUnresolved="true" enumRefLinkDuplicates="true" simTocUpdateNeeded="true" simTocTitleSpaceNeeded="true" />
|
|
81
|
-
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="css" scriptDir="js" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetPathType="2" targetExt="" useTargetExt="false" noCssNoScripts="false" useElementStyleAttribute="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
|
82
|
-
<LinkMapSettings>
|
|
83
|
-
<textMaps />
|
|
84
|
-
</LinkMapSettings>
|
|
85
|
-
</component>
|
|
86
|
-
</project>
|
package/dist/errors.d.ts
DELETED
package/dist/errors.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const create = require('create-error');
|
|
4
|
-
const AppError = create('AppError');
|
|
5
|
-
const RequestError = create(AppError, 'RequestError');
|
|
6
|
-
RequestError.toJSON = function () {
|
|
7
|
-
return { message: this.message };
|
|
8
|
-
};
|
|
9
|
-
const Forbidden = create(RequestError, 'ForbiddenError', {
|
|
10
|
-
status: 403,
|
|
11
|
-
});
|
|
12
|
-
const Unauthorized = create(RequestError, 'UnauthorizedError', {
|
|
13
|
-
status: 401,
|
|
14
|
-
});
|
|
15
|
-
const BadRequest = create(RequestError, 'BadRequestError', {
|
|
16
|
-
status: 400,
|
|
17
|
-
});
|
|
18
|
-
const NotFound = create(RequestError, 'NotFoundError', {
|
|
19
|
-
status: 404,
|
|
20
|
-
});
|
|
21
|
-
const ConflictError = create(RequestError, 'ConflictError', {
|
|
22
|
-
status: 409,
|
|
23
|
-
});
|
|
24
|
-
const ServerError = create(RequestError, 'ServerError', {
|
|
25
|
-
status: 500,
|
|
26
|
-
});
|
|
27
|
-
const InvalidArguments = create(RequestError, 'InvalidArgumentsError', {
|
|
28
|
-
status: 500,
|
|
29
|
-
});
|
|
30
|
-
const ServerTimeout = create(RequestError, 'ServerTimeoutError', {
|
|
31
|
-
status: 503,
|
|
32
|
-
});
|
|
33
|
-
exports.default = {
|
|
34
|
-
RequestError,
|
|
35
|
-
Forbidden,
|
|
36
|
-
Unauthorized,
|
|
37
|
-
BadRequest,
|
|
38
|
-
NotFound,
|
|
39
|
-
ConflictError,
|
|
40
|
-
ServerError,
|
|
41
|
-
InvalidArguments,
|
|
42
|
-
ServerTimeout,
|
|
43
|
-
};
|
package/dist/formatting.d.ts
DELETED
package/dist/formatting.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
-
if (mod && mod.__esModule) return mod;
|
|
4
|
-
var result = {};
|
|
5
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
-
result["default"] = mod;
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const _ = __importStar(require("lodash"));
|
|
11
|
-
const rethrowError = (fnName, e) => {
|
|
12
|
-
let formattedError;
|
|
13
|
-
if (_.isPlainObject(e.error) || _.isArray(e.error)) {
|
|
14
|
-
formattedError = `\n${JSON.stringify(e.error, null, 2)}`;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
formattedError = e.error;
|
|
18
|
-
}
|
|
19
|
-
return `${fnName} - ${e.name}: ${e.statusCode} - ${formattedError}`;
|
|
20
|
-
};
|
|
21
|
-
const sqlEscapeWildcard = (str) => str.replace(/_|%|\\/g, x => `\\${x}`);
|
|
22
|
-
exports.default = {
|
|
23
|
-
rethrowError,
|
|
24
|
-
sqlEscapeWildcard,
|
|
25
|
-
};
|
package/dist/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { default as types } from "./types";
|
|
2
|
-
export { default as validations } from "./validations";
|
|
3
|
-
export { default as errors } from "./errors";
|
|
4
|
-
export { default as formatting } from "./formatting";
|
|
5
|
-
export { default as ormHelpers } from "./ormHelpers";
|
|
6
|
-
export { default as middleware } from "./middleware";
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var types_1 = require("./types");
|
|
4
|
-
exports.types = types_1.default;
|
|
5
|
-
var validations_1 = require("./validations");
|
|
6
|
-
exports.validations = validations_1.default;
|
|
7
|
-
var errors_1 = require("./errors");
|
|
8
|
-
exports.errors = errors_1.default;
|
|
9
|
-
var formatting_1 = require("./formatting");
|
|
10
|
-
exports.formatting = formatting_1.default;
|
|
11
|
-
var ormHelpers_1 = require("./ormHelpers");
|
|
12
|
-
exports.ormHelpers = ormHelpers_1.default;
|
|
13
|
-
var middleware_1 = require("./middleware");
|
|
14
|
-
exports.middleware = middleware_1.default;
|
package/dist/middleware.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
declare const _default: {
|
|
3
|
-
ensureType: (type: string) => (req: Request, res: Response, next: NextFunction, id: any, name: string) => void;
|
|
4
|
-
ensureUUID: (req: Request, res: Response, next: NextFunction, id: any, name: string) => void;
|
|
5
|
-
ensureHex32: (req: Request, res: Response, next: NextFunction, id: any, name: string) => void;
|
|
6
|
-
ensureInteger: (req: Request, res: Response, next: NextFunction, id: any, name: string) => void;
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
package/dist/middleware.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const T = require('./types');
|
|
4
|
-
const ensureType = (type) => (req, res, next, id, name) => {
|
|
5
|
-
let error;
|
|
6
|
-
try {
|
|
7
|
-
T.ensureType(type, id, `Invalid ${name}`);
|
|
8
|
-
return next();
|
|
9
|
-
}
|
|
10
|
-
catch (error1) {
|
|
11
|
-
error = error1;
|
|
12
|
-
return next(error);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const ensureUUID = ensureType('UUID');
|
|
16
|
-
const ensureHex32 = ensureType('Hex32');
|
|
17
|
-
const ensureInteger = ensureType('IntString');
|
|
18
|
-
exports.default = {
|
|
19
|
-
ensureType,
|
|
20
|
-
ensureUUID,
|
|
21
|
-
ensureHex32,
|
|
22
|
-
ensureInteger,
|
|
23
|
-
};
|
package/dist/ormHelpers.d.ts
DELETED
package/dist/ormHelpers.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
-
if (mod && mod.__esModule) return mod;
|
|
4
|
-
var result = {};
|
|
5
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
-
result["default"] = mod;
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const _ = __importStar(require("lodash"));
|
|
11
|
-
const includeNested = (orm, models) => _.map(_.toPairs(models), (arg) => {
|
|
12
|
-
const [modelName, inclusion] = arg;
|
|
13
|
-
const include = includeNested(orm, inclusion);
|
|
14
|
-
const model = orm[modelName];
|
|
15
|
-
if (_.isEmpty(include)) {
|
|
16
|
-
return model;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
model,
|
|
20
|
-
include,
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
exports.default = {
|
|
24
|
-
includeNested,
|
|
25
|
-
};
|
package/dist/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test.js
DELETED
package/dist/types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
parseType(str: any): any;
|
|
3
|
-
parsedTypeCheck(type: any, obj: any): any;
|
|
4
|
-
typeCheck(type: any, obj: any): any;
|
|
5
|
-
opts: {
|
|
6
|
-
customTypes: {};
|
|
7
|
-
};
|
|
8
|
-
ensureType(type: any, obj: any, msg: string): any;
|
|
9
|
-
checkArg(obj: any, prop: any, type: any, msg: string): any;
|
|
10
|
-
checkArgs(input: {
|
|
11
|
-
[K: string]: any;
|
|
12
|
-
}, types: any[]): void;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
package/dist/types.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
-
if (mod && mod.__esModule) return mod;
|
|
4
|
-
var result = {};
|
|
5
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
-
result["default"] = mod;
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
const TC = __importStar(require("type-check"));
|
|
15
|
-
const _ = __importStar(require("lodash"));
|
|
16
|
-
const validations_1 = __importDefault(require("./validations"));
|
|
17
|
-
const errors_1 = __importDefault(require("./errors"));
|
|
18
|
-
const customTypes = {
|
|
19
|
-
Integer: {
|
|
20
|
-
typeOf: 'Number',
|
|
21
|
-
validate(x) {
|
|
22
|
-
return x % 1 === 0;
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
IntString: {
|
|
26
|
-
typeOf: 'String',
|
|
27
|
-
validate: validations_1.default.isInt,
|
|
28
|
-
},
|
|
29
|
-
BoolString: {
|
|
30
|
-
typeOf: 'String',
|
|
31
|
-
validate: validations_1.default.isBoolean,
|
|
32
|
-
},
|
|
33
|
-
Hex32: {
|
|
34
|
-
typeOf: 'String',
|
|
35
|
-
validate(x) {
|
|
36
|
-
return validations_1.default.isHexadecimal(x) && x.length === 32;
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
Email: {
|
|
40
|
-
typeOf: 'String',
|
|
41
|
-
validate: validations_1.default.isEmail,
|
|
42
|
-
},
|
|
43
|
-
UUID: {
|
|
44
|
-
typeOf: 'String',
|
|
45
|
-
validate: validations_1.default.isUUID,
|
|
46
|
-
},
|
|
47
|
-
UUIDv4: {
|
|
48
|
-
typeOf: 'String',
|
|
49
|
-
validate(x) {
|
|
50
|
-
return validations_1.default.isUUID(x, 4);
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
JSON: {
|
|
54
|
-
typeOf: 'String',
|
|
55
|
-
validate: validations_1.default.isJSON,
|
|
56
|
-
},
|
|
57
|
-
Url: {
|
|
58
|
-
typeOf: 'String',
|
|
59
|
-
validate: validations_1.default.isURL,
|
|
60
|
-
},
|
|
61
|
-
NonEmptyArray: {
|
|
62
|
-
typeOf: 'Array',
|
|
63
|
-
validate: validations_1.default.nonEmpty,
|
|
64
|
-
},
|
|
65
|
-
NonNullString: {
|
|
66
|
-
typeOf: 'String',
|
|
67
|
-
validate: validations_1.default.nonEmpty,
|
|
68
|
-
},
|
|
69
|
-
CustomerReference: {
|
|
70
|
-
typeOf: 'String',
|
|
71
|
-
validate: validations_1.default.isCustomerReference,
|
|
72
|
-
},
|
|
73
|
-
CustomerLabelName: {
|
|
74
|
-
typeOf: 'String',
|
|
75
|
-
validate: validations_1.default.isCustomerLabelName,
|
|
76
|
-
},
|
|
77
|
-
BitcoinAddress: {
|
|
78
|
-
typeOf: 'String',
|
|
79
|
-
validate: validations_1.default.bitcoin.isAddress,
|
|
80
|
-
},
|
|
81
|
-
EthereumAddress: {
|
|
82
|
-
typeOf: 'String',
|
|
83
|
-
validate: validations_1.default.ethereum.isAddress,
|
|
84
|
-
},
|
|
85
|
-
EthereumTx: {
|
|
86
|
-
typeOf: 'String',
|
|
87
|
-
validate: validations_1.default.ethereum.isTxHash,
|
|
88
|
-
},
|
|
89
|
-
EthereumBlockHash: {
|
|
90
|
-
typeOf: 'String',
|
|
91
|
-
validate: validations_1.default.ethereum.isBlockHash,
|
|
92
|
-
},
|
|
93
|
-
EthereumWeiAmount: {
|
|
94
|
-
typeOf: 'String',
|
|
95
|
-
validate: validations_1.default.ethereum.isValidWeiAmount,
|
|
96
|
-
},
|
|
97
|
-
EthereumAddressCode: {
|
|
98
|
-
typeOf: 'String',
|
|
99
|
-
validate: validations_1.default.ethereum.isAddressCode,
|
|
100
|
-
},
|
|
101
|
-
MineId: {
|
|
102
|
-
typeOf: 'String',
|
|
103
|
-
validate(x) {
|
|
104
|
-
return x === 'mine';
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
BitcoinTxHash: {
|
|
108
|
-
typeOf: 'String',
|
|
109
|
-
validate: validations_1.default.bitcoin.isTxHash,
|
|
110
|
-
},
|
|
111
|
-
BitcoinAddressArray: {
|
|
112
|
-
typeOf: 'Array',
|
|
113
|
-
validate(as) {
|
|
114
|
-
return _.every(as, validations_1.default.bitcoin.isAddress);
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
BitcoinTxHashArray: {
|
|
118
|
-
typeOf: 'Array',
|
|
119
|
-
validate(as) {
|
|
120
|
-
return _.every(as, validations_1.default.bitcoin.isTxHash);
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
BitcoinTxHex: {
|
|
124
|
-
typeOf: 'String',
|
|
125
|
-
validate: validations_1.default.bitcoin.isTxHex,
|
|
126
|
-
},
|
|
127
|
-
BitcoinScriptHex: {
|
|
128
|
-
typeOf: 'String',
|
|
129
|
-
validate: validations_1.default.bitcoin.isScriptHex,
|
|
130
|
-
},
|
|
131
|
-
BitcoinHDPath: {
|
|
132
|
-
typeOf: 'String',
|
|
133
|
-
validate: validations_1.default.bitcoin.isHDPath,
|
|
134
|
-
},
|
|
135
|
-
BitcoinPublicKey: {
|
|
136
|
-
typeOf: 'String',
|
|
137
|
-
validate: validations_1.default.bitcoin.isPublicKey,
|
|
138
|
-
},
|
|
139
|
-
BitcoinXpub: {
|
|
140
|
-
typeOf: 'String',
|
|
141
|
-
validate: validations_1.default.bitcoin.isHDPublicKey,
|
|
142
|
-
},
|
|
143
|
-
BitcoinTxSignature: {
|
|
144
|
-
typeOf: 'String',
|
|
145
|
-
validate: validations_1.default.bitcoin.isTxSignature,
|
|
146
|
-
},
|
|
147
|
-
BitcoinBlockHeight: {
|
|
148
|
-
typeOf: 'Number',
|
|
149
|
-
validate: validations_1.default.bitcoin.isBlockHeight,
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
// add support for nullable properties
|
|
153
|
-
const withNullable = Object.keys(customTypes).reduce((acc, _type) => {
|
|
154
|
-
acc[_type] = customTypes[_type];
|
|
155
|
-
const { typeOf, validate } = customTypes[_type];
|
|
156
|
-
// for every type, add Nullable+type. A nullable string can also be empty
|
|
157
|
-
acc[`Nullable${_type}`] = Object.assign({}, customTypes[_type], {
|
|
158
|
-
validate: (x) => x == null || (typeOf === 'String' && x === '') || validate(x),
|
|
159
|
-
});
|
|
160
|
-
return acc;
|
|
161
|
-
}, {});
|
|
162
|
-
exports.default = {
|
|
163
|
-
parseType(str) {
|
|
164
|
-
return TC.parseType(str);
|
|
165
|
-
},
|
|
166
|
-
parsedTypeCheck(type, obj) {
|
|
167
|
-
return TC.parsedTypeCheck(type, obj, this.opts);
|
|
168
|
-
},
|
|
169
|
-
typeCheck(type, obj) {
|
|
170
|
-
return TC.typeCheck(type, obj, this.opts);
|
|
171
|
-
},
|
|
172
|
-
opts: {
|
|
173
|
-
customTypes: withNullable,
|
|
174
|
-
},
|
|
175
|
-
ensureType(type, obj, msg) {
|
|
176
|
-
return validations_1.default.ensure(this.typeCheck(type, obj), msg);
|
|
177
|
-
},
|
|
178
|
-
checkArg(obj, prop, type, msg) {
|
|
179
|
-
if (msg == null) {
|
|
180
|
-
msg = `Invalid ${prop}`;
|
|
181
|
-
}
|
|
182
|
-
this.ensureType(type, obj[prop], msg);
|
|
183
|
-
return obj[prop];
|
|
184
|
-
},
|
|
185
|
-
checkArgs(input, types) {
|
|
186
|
-
const inputKeys = {};
|
|
187
|
-
const [typ] = types;
|
|
188
|
-
const fields = typ.of;
|
|
189
|
-
let numInputKeys = 0;
|
|
190
|
-
let numKeys;
|
|
191
|
-
Object.keys(input).forEach((k) => {
|
|
192
|
-
inputKeys[k] = true;
|
|
193
|
-
numInputKeys += 1;
|
|
194
|
-
});
|
|
195
|
-
numKeys = 0;
|
|
196
|
-
Object.keys(fields).forEach((key) => {
|
|
197
|
-
types = fields[key];
|
|
198
|
-
validations_1.default.ensure(this.parsedTypeCheck(types, input[key]), `Invalid ${key}`);
|
|
199
|
-
if (inputKeys[key]) {
|
|
200
|
-
numKeys += 1;
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
if (!(typ.subset || numInputKeys === numKeys)) {
|
|
204
|
-
throw new errors_1.default.BadRequest('invalid extra arguments are present');
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
};
|
package/dist/validations.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
declare type ValidatorFunction = (...args: any) => any;
|
|
2
|
-
declare type Validations = {
|
|
3
|
-
_validate: (Err: new (msg: string) => Error, pred: (x: any) => boolean, x: any, msg: string) => any;
|
|
4
|
-
_validateArg: (pred: (x: any) => boolean, x: any, msg: string) => any;
|
|
5
|
-
_tryCheck: (fn: (arg: any) => any, arg: any) => boolean;
|
|
6
|
-
exists: (x: any) => boolean;
|
|
7
|
-
argExists: (x: any, msg: string) => boolean;
|
|
8
|
-
nonEmpty: ValidatorFunction;
|
|
9
|
-
isNonEmptyString: ValidatorFunction;
|
|
10
|
-
ensureShortEnough: ValidatorFunction;
|
|
11
|
-
ensure: ValidatorFunction;
|
|
12
|
-
check: {
|
|
13
|
-
matches: ValidatorFunction;
|
|
14
|
-
wasFound: ValidatorFunction;
|
|
15
|
-
wasCreated: ValidatorFunction;
|
|
16
|
-
isTrue: ValidatorFunction;
|
|
17
|
-
isFalse: ValidatorFunction;
|
|
18
|
-
};
|
|
19
|
-
isCustomerReference: ValidatorFunction;
|
|
20
|
-
isCustomerLabelName: ValidatorFunction;
|
|
21
|
-
ethereum: {
|
|
22
|
-
isAddress: ValidatorFunction;
|
|
23
|
-
isBlockHash: ValidatorFunction;
|
|
24
|
-
isTxHash: ValidatorFunction;
|
|
25
|
-
isAddressCode: ValidatorFunction;
|
|
26
|
-
isValidWeiAmount: ValidatorFunction;
|
|
27
|
-
};
|
|
28
|
-
bitcoin: {
|
|
29
|
-
isAddress: ValidatorFunction;
|
|
30
|
-
isHDPublicKey: ValidatorFunction;
|
|
31
|
-
isPublicKey: ValidatorFunction;
|
|
32
|
-
isTxHash: ValidatorFunction;
|
|
33
|
-
isTxHex: ValidatorFunction;
|
|
34
|
-
isHDPath: ValidatorFunction;
|
|
35
|
-
isScriptHex: ValidatorFunction;
|
|
36
|
-
isTxSignature: ValidatorFunction;
|
|
37
|
-
isBlockHeight: ValidatorFunction;
|
|
38
|
-
};
|
|
39
|
-
bitcoinCash: {
|
|
40
|
-
isAddress: ValidatorFunction;
|
|
41
|
-
isTxHash: ValidatorFunction;
|
|
42
|
-
};
|
|
43
|
-
litecoin: {
|
|
44
|
-
isAddress: ValidatorFunction;
|
|
45
|
-
isTxHash: ValidatorFunction;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
declare const _default: Validations & IValidatorStatic;
|
|
49
|
-
export default _default;
|