Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@heathmont/lab-flask

Package Overview
Dependencies
Maintainers
130
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@heathmont/lab-flask - npm Package Compare versions

Comparing version 1.0.0-1 to 1.0.0

.husky/pre-commit

1

dist/bigNumberToDecimal.d.ts

@@ -0,1 +1,2 @@

/// <reference types="node" />
import BigNumber from 'bignumber.js';

@@ -2,0 +3,0 @@ import { Proto } from '@heathmont/coingaming-protobuf';

11

dist/bigNumberToDecimal.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Long = require("long");
exports.bigNumberToUDecimal = exports.bigNumberToDecimal = void 0;
var Long = require('long');
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf");
exports.bigNumberToDecimal = function (bigNumber) {
var bigNumberToDecimal = function (bigNumber) {
var decimalPlaces = bigNumber.decimalPlaces();

@@ -13,5 +14,7 @@ return coingaming_protobuf_1.Proto.Global.Decimal.create({

};
exports.bigNumberToUDecimal = function (bigNumber) {
return exports.bigNumberToDecimal(bigNumber.abs());
exports.bigNumberToDecimal = bigNumberToDecimal;
var bigNumberToUDecimal = function (bigNumber) {
return (0, exports.bigNumberToDecimal)(bigNumber.abs());
};
exports.bigNumberToUDecimal = bigNumberToUDecimal;
//# sourceMappingURL=bigNumberToDecimal.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bigNumberToString = void 0;
var bignumber_js_1 = require("bignumber.js");
exports.bigNumberToString = function (data) {
var bigNumberToString = function (data) {
switch (true) {

@@ -12,3 +13,3 @@ case bignumber_js_1.default.isBigNumber(data):

return Object.keys(data).reduce(function (acc, field) {
acc[field] = exports.bigNumberToString(data[field]);
acc[field] = (0, exports.bigNumberToString)(data[field]);
return acc;

@@ -20,2 +21,3 @@ }, {});

};
exports.bigNumberToString = bigNumberToString;
//# sourceMappingURL=bigNumberToString.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -16,3 +17,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -38,3 +39,2 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -51,3 +51,3 @@ var index_1 = require("./index");

var instanceUrl = process.env.FLASK_INSTANCE_URL || 'http://localhost/';
var start = function () { return __awaiter(_this, void 0, void 0, function () {
var start = function () { return __awaiter(void 0, void 0, void 0, function () {
var expressServer, lab;

@@ -58,3 +58,3 @@ return __generator(this, function (_a) {

expressServer = express();
return [4 /*yield*/, index_1.init({
return [4 /*yield*/, (0, index_1.init)({
labPubKey: labPubKey,

@@ -61,0 +61,0 @@ flaskPrivKey: flaskPrivKey,

@@ -0,1 +1,2 @@

/// <reference types="node" />
import { LabConfig, LabContext } from './index';

@@ -2,0 +3,0 @@ import { Proto } from '@heathmont/coingaming-protobuf';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContextFromQueryString = exports.createContextQueryString = exports.createFlaskContext = exports.createLabUrl = exports.createSubstanceActUrl = void 0;
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf");
var querystring = require("querystring");
exports.createSubstanceActUrl = function (substanceEnum, actKindEnum, actEnum) {
var createSubstanceActUrl = function (substanceEnum, actKindEnum, actEnum) {
var substance = substanceEnum.toLowerCase();

@@ -16,11 +17,12 @@ var actKind = actKindEnum.toLowerCase();

else {
throw Error(actKindEnum + " is not implemented.");
throw Error("".concat(actKindEnum, " is not implemented."));
}
return substance + "/" + actKind + "/" + act;
return "".concat(substance, "/").concat(actKind, "/").concat(act);
};
exports.createLabUrl = function (labConfig, labContext, substanceEnum, actKindEnum, actEnum) {
exports.createSubstanceActUrl = createSubstanceActUrl;
var createLabUrl = function (labConfig, labContext, substanceEnum, actKindEnum, actEnum) {
var labUrl = labConfig.labUrl;
var relativePath = exports.createSubstanceActUrl(substanceEnum, actKindEnum, actEnum);
var contextProto = exports.createFlaskContext(labContext, actKindEnum);
var contextQueryString = exports.createContextQueryString(contextProto);
var relativePath = (0, exports.createSubstanceActUrl)(substanceEnum, actKindEnum, actEnum);
var contextProto = (0, exports.createFlaskContext)(labContext, actKindEnum);
var contextQueryString = (0, exports.createContextQueryString)(contextProto);
var queryStringObj = {

@@ -30,5 +32,6 @@ c: contextQueryString,

var queryString = querystring.stringify(queryStringObj);
return labUrl + "/protobuf/" + relativePath + "?" + queryString;
return "".concat(labUrl, "/protobuf/").concat(relativePath, "?").concat(queryString);
};
exports.createFlaskContext = function (labContext, actKindEnum) {
exports.createLabUrl = createLabUrl;
var createFlaskContext = function (labContext, actKindEnum) {
var targetFlaskName = labContext.targetFlaskName;

@@ -44,3 +47,3 @@ return coingaming_protobuf_1.Proto.Global.Context.create({

targetFlaskName: coingaming_protobuf_1.Google.Protobuf.StringValue.create({ value: targetFlaskName }),
targetFlaskInstanceUuid: undefined,
targetFlaskInstanceUuid: undefined, // TODO: when needed
})

@@ -51,3 +54,3 @@ : undefined,

targetFlaskName: coingaming_protobuf_1.Google.Protobuf.StringValue.create({ value: targetFlaskName }),
targetFlaskInstanceUuid: undefined,
targetFlaskInstanceUuid: undefined, // TODO: when needed
})

@@ -57,7 +60,9 @@ : undefined,

};
exports.createContextQueryString = function (contextProto) {
exports.createFlaskContext = createFlaskContext;
var createContextQueryString = function (contextProto) {
var encoded = contextProto.constructor.encode(contextProto).finish();
return encoded.toString('base64');
};
exports.getContextFromQueryString = function (context, actKindEnum) {
exports.createContextQueryString = createContextQueryString;
var getContextFromQueryString = function (context, actKindEnum) {
var contextProto = coingaming_protobuf_1.Proto.Global.Context.decode(Buffer.from(context, 'base64'));

@@ -81,2 +86,3 @@ var targetFlaskName;

};
exports.getContextFromQueryString = getContextFromQueryString;
//# sourceMappingURL=createUrls.js.map

@@ -0,1 +1,2 @@

/// <reference types="node" />
import BigNumber from 'bignumber.js';

@@ -2,0 +3,0 @@ import { Proto } from '@heathmont/coingaming-protobuf';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.udecimalToBigNumber = exports.decimalToBigNumber = void 0;
var bignumber_js_1 = require("bignumber.js");
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf");
exports.decimalToBigNumber = function (decimal) {
var decimalToBigNumber = function (decimal) {
if (decimal.coef === undefined) {

@@ -14,6 +15,8 @@ throw new Error('Cant convert decimal to BigNumber (missing .coef), did you pass undefined/null?');

};
exports.udecimalToBigNumber = function (_a) {
exports.decimalToBigNumber = decimalToBigNumber;
var udecimalToBigNumber = function (_a) {
var exp = _a.exp, coef = _a.coef;
return exports.decimalToBigNumber(coingaming_protobuf_1.Proto.Global.Decimal.create({ coef: coef, exp: exp, negative: false }));
return (0, exports.decimalToBigNumber)(coingaming_protobuf_1.Proto.Global.Decimal.create({ coef: coef, exp: exp, negative: false }));
};
exports.udecimalToBigNumber = udecimalToBigNumber;
//# sourceMappingURL=decimalToBigNumber.js.map

@@ -5,3 +5,3 @@ export interface ParameterError {

}
declare type ErrorType = 'BUSINESS_LOGIC' | 'INTERNAL';
type ErrorType = 'BUSINESS_LOGIC' | 'INTERNAL';
export interface LabError {

@@ -8,0 +8,0 @@ type: ErrorType;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLabError = function (type, errors) {
exports.handleInternalError = exports.handleLabError = exports.addParameterError = exports.createParameterError = exports.createLabError = void 0;
var createLabError = function (type, errors) {
if (type === void 0) { type = 'BUSINESS_LOGIC'; }

@@ -11,3 +12,4 @@ if (errors === void 0) { errors = []; }

};
exports.createParameterError = function (name, value) {
exports.createLabError = createLabError;
var createParameterError = function (name, value) {
return {

@@ -18,11 +20,13 @@ name: name,

};
exports.addParameterError = function (labError, name, value) {
labError.errors.push(exports.createParameterError(name, value));
exports.createParameterError = createParameterError;
var addParameterError = function (labError, name, value) {
labError.errors.push((0, exports.createParameterError)(name, value));
};
exports.handleLabError = function (errorResponse, kind) {
var error = exports.createLabError();
exports.addParameterError = addParameterError;
var handleLabError = function (errorResponse, kind) {
var error = (0, exports.createLabError)();
Object.keys(errorResponse).filter(function (key) { return key !== 'toJSON'; }).forEach(function (name) {
if (errorResponse[name]) {
var value = errorResponse[name].value;
exports.addParameterError(error, name, kind[value]);
(0, exports.addParameterError)(error, name, kind[value]);
}

@@ -32,10 +36,12 @@ });

};
exports.handleInternalError = function (e) {
var error = exports.createLabError('INTERNAL');
exports.handleLabError = handleLabError;
var handleInternalError = function (e) {
var error = (0, exports.createLabError)('INTERNAL');
if (e.message)
exports.addParameterError(error, 'message', e.message);
(0, exports.addParameterError)(error, 'message', e.message);
if (e.stack)
exports.addParameterError(error, 'stack', e.stack);
(0, exports.addParameterError)(error, 'stack', e.stack);
return error;
};
exports.handleInternalError = handleInternalError;
//# sourceMappingURL=errorHandler.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.implementFlaskSubstance = function (labConfig) {
exports.implementFlaskSubstance = void 0;
var implementFlaskSubstance = function (labConfig) {
// const { expressServer } = labConfig;

@@ -8,2 +9,3 @@ // const createSubstanceActUrl

};
exports.implementFlaskSubstance = implementFlaskSubstance;
//# sourceMappingURL=implementFlaskSubstance.js.map
/// <reference types="node" />
import { Context } from './createUrls';
import { ProtobufMessage } from './types/types';
import { LabConfig } from './';
import express = require('express');
export declare const privateImplemenSubstance: (labConfig: LabConfig, substance: string, implementations: Implementations) => void;
export declare const implement: <REQ extends import("./types/types").PartialBy<import("./types/types").ProtobufMessageWithToJSON<REQ>, "$type">, RES extends import("./types/types").PartialBy<import("./types/types").ProtobufMessageWithToJSON<RES>, "$type">>(requestClass: new () => REQ, processor: (req: REQ, context: Context, rawReq: express.Request) => RES | Promise<RES>) => (reqData: Buffer, context: Context, rawReq: express.Request) => Promise<RES>;
export declare const implement: <REQ extends ProtobufMessage<REQ>, RES extends ProtobufMessage<RES>>(requestClass: new () => REQ, processor: (req: REQ, context: Context, rawReq: express.Request) => RES | Promise<RES>) => (reqData: Buffer, context: Context, rawReq: express.Request) => Promise<RES>;
export interface ReactionImplementations {

@@ -8,0 +9,0 @@ [reactionEnum: string]: (reqDataR: Buffer, context: Context, rawReq: express.Request) => any;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -16,3 +17,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -38,4 +39,4 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.implement = exports.privateImplemenSubstance = void 0;
var createUrls_1 = require("./createUrls");

@@ -47,6 +48,6 @@ var node_logger_1 = require("@heathmont/node-logger");

var _loop_1 = function (actEnum) {
var actPath = createUrls_1.createSubstanceActUrl(substance, actKindEnum, actEnum);
var actPath = (0, createUrls_1.createSubstanceActUrl)(substance, actKindEnum, actEnum);
var implementation = implementations[actEnum];
node_logger_1.logger.debug("Attaching binding " + labConfig.flaskPathnameProto + "/" + actPath + " with async function");
expressServer.post(labConfig.flaskPathnameProto + "/" + actPath, function (req, res) { return __awaiter(_this, void 0, void 0, function () {
node_logger_1.logger.debug("Attaching binding ".concat(labConfig.flaskPathnameProto, "/").concat(actPath, " with async function"));
expressServer.post("".concat(labConfig.flaskPathnameProto, "/").concat(actPath), function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
var isSignatureValid, context, responseProtobuf, e_1, responseData;

@@ -56,8 +57,7 @@ return __generator(this, function (_a) {

case 0:
node_logger_1.logger.debug('Handling POST for url', { url: labConfig.flaskPathnameProto + "/" + actPath,
node_logger_1.logger.debug('Handling POST for url', { url: "".concat(labConfig.flaskPathnameProto, "/").concat(actPath),
body: req.body,
queryC: req.query.c,
});
queryC: req.query.c, });
isSignatureValid = labConfig.hmCrypto.isValid(req.body, req.headers['x-lab-signature']);
context = createUrls_1.getContextFromQueryString(req.query.c, actKindEnum);
context = (0, createUrls_1.getContextFromQueryString)(req.query.c.toString(), actKindEnum);
if (!isSignatureValid) {

@@ -95,3 +95,3 @@ node_logger_1.logger.warn('Lab signature invalid', { actPath: actPath, context: context, requestHeaders: req.headers });

};
exports.privateImplemenSubstance = function (labConfig, substance, implementations) {
var privateImplemenSubstance = function (labConfig, substance, implementations) {
if (implementations.element) {

@@ -104,4 +104,5 @@ bindImplementations(labConfig, substance, 'ELEMENT', implementations.element);

};
exports.implement = function (requestClass, processor) {
return function (reqData, context, rawReq) { return __awaiter(_this, void 0, void 0, function () {
exports.privateImplemenSubstance = privateImplemenSubstance;
var implement = function (requestClass, processor) {
return function (reqData, context, rawReq) { return __awaiter(void 0, void 0, void 0, function () {
var req;

@@ -124,2 +125,3 @@ return __generator(this, function (_a) {

};
exports.implement = implement;
var decodeRequestBody = function (requestClass, reqData) {

@@ -126,0 +128,0 @@ var req;

@@ -5,3 +5,2 @@ import 'source-map-support/register';

import { Implementations } from './implementSubstance';
import * as Long from 'long';
export declare const PROTOBUF_URL_PREFIX = "protobuf";

@@ -53,6 +52,6 @@ export declare const implementFlaskMeta: (metaFunction: any) => Proto.Substance.Flask.Reaction.HealthCheck.Request;

}
export declare const init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<LabContext, "sourceFlaskName">, "siteId">) => Promise<Lab>;
export declare const init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<LabContext, 'sourceFlaskName'>, 'siteId'>) => Promise<Lab>;
declare const defaultExport: {
init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<LabContext, "sourceFlaskName">, "siteId">) => Promise<Lab>;
longToBigNumber: (long: Long) => import("bignumber.js").BigNumber;
init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<LabContext, 'sourceFlaskName'>, 'siteId'>) => Promise<Lab>;
longToBigNumber: (long: import("long").default) => import("bignumber.js").BigNumber;
decimalToBigNumber: (decimal: Proto.Global.Decimal) => import("bignumber.js").BigNumber;

@@ -59,0 +58,0 @@ udecimalToBigNumber: ({ exp, coef }: Proto.Global.UDecimal) => import("bignumber.js").BigNumber;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -16,3 +17,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -38,4 +39,4 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.init = exports.implementFlaskMeta = exports.PROTOBUF_URL_PREFIX = void 0;
require("source-map-support/register");

@@ -47,3 +48,3 @@ var sendRequest_1 = require("./sendRequest");

var node_logger_1 = require("@heathmont/node-logger");
var uuidv4 = require("uuid/v4");
var uuid_1 = require("uuid");
var os_1 = require("os");

@@ -61,9 +62,10 @@ var url_1 = require("url");

var path = require("path");
var Long = require('long');
exports.PROTOBUF_URL_PREFIX = 'protobuf';
exports.implementFlaskMeta = function (metaFunction) {
var implementFlaskMeta = function (metaFunction) {
return new coingaming_protobuf_1.Proto.Substance.Flask.Reaction.HealthCheck.Request({});
};
exports.init = function (options, initDefaultContext) { return __awaiter(_this, void 0, void 0, function () {
exports.implementFlaskMeta = implementFlaskMeta;
var init = function (options, initDefaultContext) { return __awaiter(void 0, void 0, void 0, function () {
var requiredOptions, flaskName, flaskUrl, expressServer, labUrl, flaskPrivKey, instanceUuid, instanceUrl, healthCheckFunction, defaultContext, autoStartHealthChecks, pki, privateKey, publicKey, flaskPubKey, flaskPathname, flaskPathnameProto, labConfig, callReaction, callElement, implementFlaskSubstance, implementSubstance, failedHealthChecks, startHealthCheck;
var _this = this;
return __generator(this, function (_a) {

@@ -75,3 +77,3 @@ switch (_a.label) {

if (requiredOptions.includes(optionKey) && !options[optionKey]) {
throw new Error("Missing option \"" + optionKey + "\"");
throw new Error("Missing option \"".concat(optionKey, "\""));
}

@@ -101,5 +103,5 @@ });

};
defaultContext.instanceUuid = instanceUuid ? instanceUuid : os_1.hostname() + "-" + uuidv4();
defaultContext.instanceUuid = instanceUuid ? instanceUuid : "".concat((0, os_1.hostname)(), "-").concat((0, uuid_1.v4)());
if (expressServer) {
expressServer.post(flaskPathnameProto + "*", function (req, res, next) {
expressServer.post("".concat(flaskPathnameProto, "*"), function (req, res, next) {
node_logger_1.logger.debug('Lab request incoming', { reqHeaders: req.headers });

@@ -109,3 +111,3 @@ next();

node_logger_1.logger.debug('Adding body parser for path', { path: flaskPathnameProto });
expressServer.post(flaskPathnameProto + "*", bodyParser.raw({
expressServer.post("".concat(flaskPathnameProto, "*"), bodyParser.raw({
type: 'application/*',

@@ -115,11 +117,11 @@ limit: '10mb',

}
callReaction = function (substanceEnum, reactionEnum, request, responseClass, context) { return __awaiter(_this, void 0, void 0, function () {
callReaction = function (substanceEnum, reactionEnum, request, responseClass, context) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, sendRequest_1.sendRequest(labConfig, substanceEnum, 'REACTION', reactionEnum, request, responseClass, context)];
return [2 /*return*/, (0, sendRequest_1.sendRequest)(labConfig, substanceEnum, 'REACTION', reactionEnum, request, responseClass, context)];
});
}); };
callElement = function (substanceEnum, reactionEnum, request, responseClass, context) { return __awaiter(_this, void 0, void 0, function () {
callElement = function (substanceEnum, reactionEnum, request, responseClass, context) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, sendRequest_1.sendRequest(labConfig, substanceEnum, 'ELEMENT', reactionEnum, request, responseClass, context)];
case 0: return [4 /*yield*/, (0, sendRequest_1.sendRequest)(labConfig, substanceEnum, 'ELEMENT', reactionEnum, request, responseClass, context)];
case 1: return [2 /*return*/, _a.sent()];

@@ -129,5 +131,5 @@ }

}); };
implementFlaskSubstance = function (implementations) { return __awaiter(_this, void 0, void 0, function () {
implementFlaskSubstance = function (implementations) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
implementSubstance_1.privateImplemenSubstance(labConfig, 'FLASK', implementations);
(0, implementSubstance_1.privateImplemenSubstance)(labConfig, 'FLASK', implementations);
return [2 /*return*/];

@@ -137,6 +139,6 @@ });

implementSubstance = function (substanceEnum, implementations) {
return implementSubstance_1.privateImplemenSubstance(labConfig, substanceEnum, implementations);
return (0, implementSubstance_1.privateImplemenSubstance)(labConfig, substanceEnum, implementations);
};
failedHealthChecks = 0;
startHealthCheck = function () { return __awaiter(_this, void 0, void 0, function () {
startHealthCheck = function () { return __awaiter(void 0, void 0, void 0, function () {
var error_1;

@@ -147,3 +149,3 @@ return __generator(this, function (_a) {

_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, sendHealthCheck_1.sendHealthCheck(labConfig, healthCheckFunction(), callReaction)];
return [4 /*yield*/, (0, sendHealthCheck_1.sendHealthCheck)(labConfig, healthCheckFunction(), callReaction)];
case 1:

@@ -190,2 +192,3 @@ _a.sent();

}); };
exports.init = init;
var defaultExport = {

@@ -192,0 +195,0 @@ init: exports.init,

import BigNumber from 'bignumber.js';
import * as Long from 'long';
import Long from 'long';
export declare const longToBigNumber: (long: Long) => BigNumber;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.longToBigNumber = void 0;
var bignumber_js_1 = require("bignumber.js");
exports.longToBigNumber = function (long) {
var longToBigNumber = function (long) {
return new bignumber_js_1.default(long.toString());
};
exports.longToBigNumber = longToBigNumber;
//# sourceMappingURL=longToBigNumber.js.map

@@ -0,1 +1,2 @@

/// <reference types="node" />
import { Proto } from '@heathmont/coingaming-protobuf';

@@ -2,0 +3,0 @@ import BigNumber from 'bignumber.js';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toUMoney = exports.toMoney = exports.umoneyHelper = exports.moneyHelper = void 0;
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf");
var decimalToBigNumber_1 = require("./decimalToBigNumber");
var bigNumberToDecimal_1 = require("./bigNumberToDecimal");
exports.moneyHelper = function (money) {
var moneyHelper = function (money) {
return {
amount: decimalToBigNumber_1.decimalToBigNumber(money.amount),
amount: (0, decimalToBigNumber_1.decimalToBigNumber)(money.amount),
currencyCode: coingaming_protobuf_1.Proto.Global.CurrencyCode[money.currencyCode.value],
};
};
exports.umoneyHelper = function (money) {
exports.moneyHelper = moneyHelper;
var umoneyHelper = function (money) {
return {
amount: decimalToBigNumber_1.udecimalToBigNumber(money.amount),
amount: (0, decimalToBigNumber_1.udecimalToBigNumber)(money.amount),
currencyCode: coingaming_protobuf_1.Proto.Global.CurrencyCode[money.currencyCode.value],
};
};
exports.toMoney = function (amount, currency) {
exports.umoneyHelper = umoneyHelper;
var toMoney = function (amount, currency) {
return coingaming_protobuf_1.Proto.Global.Money.create({
amount: bigNumberToDecimal_1.bigNumberToDecimal(amount),
amount: (0, bigNumberToDecimal_1.bigNumberToDecimal)(amount),
currencyCode: currency ?

@@ -25,5 +28,6 @@ coingaming_protobuf_1.Proto.Global.CurrencyCodeValue.create({ value: coingaming_protobuf_1.Proto.Global.CurrencyCode[currency] }) : null,

};
exports.toUMoney = function (amount, currency) {
exports.toMoney = toMoney;
var toUMoney = function (amount, currency) {
return coingaming_protobuf_1.Proto.Global.UMoney.create({
amount: bigNumberToDecimal_1.bigNumberToUDecimal(amount),
amount: (0, bigNumberToDecimal_1.bigNumberToUDecimal)(amount),
currencyCode: currency ?

@@ -33,2 +37,3 @@ coingaming_protobuf_1.Proto.Global.CurrencyCodeValue.create({ value: coingaming_protobuf_1.Proto.Global.CurrencyCode[currency] }) : null,

};
exports.toUMoney = toUMoney;
//# sourceMappingURL=moneyHelper.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -16,3 +17,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -38,7 +39,7 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendHealthCheck = void 0;
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf");
var node_logger_1 = require("@heathmont/node-logger");
exports.sendHealthCheck = function (labConfig, status, callReaction) { return __awaiter(_this, void 0, void 0, function () {
var sendHealthCheck = function (labConfig, status, callReaction) { return __awaiter(void 0, void 0, void 0, function () {
var heartbeatRequest, response, e_1, message, stack;

@@ -76,2 +77,3 @@ return __generator(this, function (_a) {

}); };
exports.sendHealthCheck = sendHealthCheck;
//# sourceMappingURL=sendHealthCheck.js.map
import { LabConfig } from './index';
import { ClassInstance, ProtobufResponse } from './types/types';
export declare const sendRequest: <REQ extends import("./types/types").PartialBy<import("./types/types").ProtobufMessageWithToJSON<REQ>, "$type">, RESP>(labConfig: LabConfig, substanceEnum: string, actKindEnum: string, actEnum: string, payload: REQ, responseClass: ClassInstance<RESP>, context: any) => Promise<ProtobufResponse<RESP>>;
import { ClassInstance, ProtobufMessage, ProtobufResponse } from './types/types';
export declare const sendRequest: <REQ extends ProtobufMessage<REQ>, RESP>(labConfig: LabConfig, substanceEnum: string, actKindEnum: string, actEnum: string, payload: REQ, responseClass: ClassInstance<RESP>, context: any) => Promise<ProtobufResponse<RESP>>;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -16,3 +17,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -38,4 +39,4 @@ if (y = 0, t) op = [op[0] & 2, t.value];

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendRequest = void 0;
var node_logger_1 = require("@heathmont/node-logger");

@@ -47,6 +48,5 @@ var axios_1 = require("axios");

var promiseRetry = require("promise-retry");
var retryQuery = (function (query) { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
var retryQuery = (function (query) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, promiseRetry({ minTimeout: 50 }, function (retry, ignored) { return __awaiter(_this, void 0, void 0, function () {
return [2 /*return*/, promiseRetry({ minTimeout: 50 }, function (retry, ignored) { return __awaiter(void 0, void 0, void 0, function () {
var error_1;

@@ -71,3 +71,3 @@ return __generator(this, function (_a) {

}); });
exports.sendRequest = function (labConfig, substanceEnum, actKindEnum, actEnum, payload, responseClass, context) { return __awaiter(_this, void 0, void 0, function () {
var sendRequest = function (labConfig, substanceEnum, actKindEnum, actEnum, payload, responseClass, context) { return __awaiter(void 0, void 0, void 0, function () {
var labContext, url, data, headers, axiosResponse, responeDecoded, err_1, responseData;

@@ -78,3 +78,3 @@ return __generator(this, function (_a) {

labContext = Object.assign({}, labConfig.defaultContext, context);
url = createUrls_1.createLabUrl(labConfig, labContext, substanceEnum, actKindEnum, actEnum);
url = (0, createUrls_1.createLabUrl)(labConfig, labContext, substanceEnum, actKindEnum, actEnum);
data = payload.constructor.encode(payload).finish();

@@ -93,3 +93,3 @@ headers = {

});
return [4 /*yield*/, retryQuery(axios_1.default({
return [4 /*yield*/, retryQuery((0, axios_1.default)({
url: url,

@@ -119,2 +119,3 @@ headers: headers,

}); };
exports.sendRequest = sendRequest;
//# sourceMappingURL=sendRequest.js.map
import { Message } from 'protobufjs';
export declare type Newable<T> = {
export type Newable<T> = {
new (...args: any[]): T;
};
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export declare type ProtobufMessageWithToJSON<T extends object> = Message<T> & {
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export type ProtobufMessageWithToJSON<T extends object> = Message<T> & {
toJSON: () => {

@@ -12,4 +12,4 @@ [k: string]: any;

};
export declare type ProtobufMessage<T extends object> = PartialBy<ProtobufMessageWithToJSON<T>, '$type'>;
export declare type ProtobufResponse<T> = T & {
export type ProtobufMessage<T extends object> = PartialBy<ProtobufMessageWithToJSON<T>, '$type'>;
export type ProtobufResponse<T> = T & {
toJSON: () => {

@@ -19,4 +19,4 @@ [k: string]: unknown;

};
export declare type ClassInstance<T> = {
export type ClassInstance<T> = {
new (a: unknown): T;
};
{
"name": "@heathmont/lab-flask",
"version": "1.0.0-1",
"version": "1.0.0",
"author": "Margus Lamp",

@@ -8,37 +8,42 @@ "main": "./dist/index.js",

"engines": {
"node": ">=8"
"node": ">=12"
},
"dependencies": {
"@heathmont/coingaming-protobuf": "1.0.0-1",
"@heathmont/node-logger": "^1.0.23",
"@types/body-parser": "1.17.0",
"axios": "0.19.0",
"bignumber.js": "8.1.1",
"body-parser": "1.19.0",
"hm-crypto-nodejs": "1.0.3",
"node-forge": "0.8.3",
"promise-retry": "1.1.1",
"protobufjs": "6.8.6",
"source-map-support": "0.5.10",
"uuid": "3.3.2"
"@heathmont/coingaming-protobuf": "0.76.0",
"@heathmont/node-logger": "1.0.26",
"@types/body-parser": "1.19.2",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"axios": "1.3.5",
"bignumber.js": "9.1.1",
"body-parser": "1.20.2",
"hm-crypto-nodejs": "1.0.6",
"node-forge": "1.3.1",
"promise-retry": "2.0.1",
"protobufjs": "7.2.3",
"source-map-support": "0.5.21",
"uuid": "9.0.0"
},
"devDependencies": {
"@types/express": "4.0.30",
"@types/jest": "23.3.2",
"@types/node": "10.11.2",
"@types/node-forge": "0.8.3",
"babel-jest": "^24.5.0",
"husky": "^4.2.5",
"jest": "^24.5.0",
"long": "4.0.0",
"semantic-release": "^17.1.1",
"ts-jest": "^24.0.0",
"tslint": "5.11.0",
"tslint-config-airbnb": "^5.11.0",
"typescript": "3.3.4000",
"validate-commit-msg": "^2.14.0"
"@types/express": "~4",
"@types/jest": "^29.5.0",
"@types/node": "~12",
"@types/node-forge": "1.3.2",
"babel-jest": "^29.5.0",
"eslint": "^8.38.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.0",
"jest": "^29.5.0",
"long": "^5.2.3",
"semantic-release": "^21.0.1",
"ts-jest": "29.1.0",
"typescript": "5.0.4",
"validate-commit-msg": "2.14.0"
},
"peerDependencies": {
"express": "~4.0",
"long": "4.0.0"
"long": "~5.0"
},

@@ -56,3 +61,4 @@ "directories": {

"test:coverage": "jest --coverage",
"prepack": "npm run compile"
"prepack": "npm run compile",
"prepare": "husky install"
},

@@ -59,0 +65,0 @@ "jest": {

This repo is for lab-flask library for node
How to use is in test files.
```
npm run test
```
import BigNumber from 'bignumber.js';
import * as Long from 'long';
const Long = require('long');
import { bigNumberToDecimal } from './bigNumberToDecimal';

@@ -4,0 +4,0 @@

import BigNumber from 'bignumber.js';
import * as Long from 'long';
const Long = require('long');
import { Proto } from '@heathmont/coingaming-protobuf';

@@ -4,0 +4,0 @@

import BigNumber from 'bignumber.js';
import { decimalToBigNumber } from './decimalToBigNumber';
import * as Long from 'long';
const Long = require('long');
import { Proto } from '@heathmont/coingaming-protobuf';

@@ -5,0 +5,0 @@

@@ -25,3 +25,3 @@ import { Proto } from '@heathmont/coingaming-protobuf';

const isSignatureValid = labConfig.hmCrypto.isValid(req.body, req.headers['x-lab-signature']);
const context: Context = getContextFromQueryString(req.query.c, actKindEnum);
const context: Context = getContextFromQueryString(req.query.c.toString(), actKindEnum);
if (!isSignatureValid) {

@@ -28,0 +28,0 @@ logger.warn('Lab signature invalid', { actPath, context, requestHeaders: req.headers });

@@ -7,3 +7,3 @@ import 'source-map-support/register';

import { logger } from '@heathmont/node-logger';
import * as uuidv4 from 'uuid/v4';
import { v4 as uuidv4 } from 'uuid';
import { hostname } from 'os';

@@ -22,3 +22,3 @@ import { URL } from 'url';

import * as path from 'path';
import * as Long from 'long';
const Long = require('long');

@@ -25,0 +25,0 @@ export const PROTOBUF_URL_PREFIX = 'protobuf';

import BigNumber from 'bignumber.js';
import { longToBigNumber } from './longToBigNumber';
import * as Long from 'long';
const Long = require('long');

@@ -5,0 +5,0 @@ describe('longToBigNumber', () => {

import BigNumber from 'bignumber.js';
import * as Long from 'long';
import Long from 'long';

@@ -4,0 +4,0 @@ export const longToBigNumber = (long: Long): BigNumber => {

import { Proto } from '@heathmont/coingaming-protobuf';
import BigNumber from 'bignumber.js';
import * as Long from 'long';
const Long = require('long');
import { Money, moneyHelper, UMoney, umoneyHelper } from './moneyHelper';

@@ -5,0 +5,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc