@heathmont/lab-flask
Advanced tools
Comparing version 1.24.0 to 2.0.0
import BigNumber from 'bignumber.js'; | ||
import { Proto } from '@heathmont/coingaming-protobuf'; | ||
export declare const bigNumberToDecimal: (bigNumber: BigNumber) => Proto.Global.Decimal; | ||
export declare const bigNumberToUDecimal: (bigNumber: BigNumber) => Proto.Global.UDecimal; | ||
import { Decimal as ProtoDecimal } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/decimal_pb.js'; | ||
import { UDecimal as ProtoUDecimal } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/udecimal_pb.js'; | ||
export declare const bigNumberToDecimal: (bigNumber: BigNumber) => ProtoDecimal; | ||
export declare const bigNumberToUDecimal: (bigNumber: BigNumber) => ProtoUDecimal; |
@@ -1,16 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Long = require("long"); | ||
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf"); | ||
exports.bigNumberToDecimal = function (bigNumber) { | ||
var decimalPlaces = bigNumber.decimalPlaces(); | ||
return coingaming_protobuf_1.Proto.Global.Decimal.create({ | ||
import { Decimal as ProtoDecimal } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/decimal_pb.js'; | ||
export const bigNumberToDecimal = (bigNumber) => { | ||
const decimalPlaces = bigNumber.decimalPlaces(); | ||
return ProtoDecimal.fromJson({ | ||
negative: bigNumber.s === -1, | ||
exp: decimalPlaces ? -decimalPlaces : 0, | ||
coef: Long.fromString(bigNumber.abs().shiftedBy(decimalPlaces).toString(10)), | ||
coef: bigNumber.abs().shiftedBy(decimalPlaces).toString(10), | ||
}); | ||
}; | ||
exports.bigNumberToUDecimal = function (bigNumber) { | ||
return exports.bigNumberToDecimal(bigNumber.abs()); | ||
export const bigNumberToUDecimal = (bigNumber) => { | ||
return bigNumberToDecimal(bigNumber.abs()); | ||
}; | ||
//# sourceMappingURL=bigNumberToDecimal.js.map |
@@ -1,13 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bignumber_js_1 = require("bignumber.js"); | ||
exports.bigNumberToString = function (data) { | ||
import BigNumber from 'bignumber.js'; | ||
export const bigNumberToString = (data) => { | ||
switch (true) { | ||
case bignumber_js_1.default.isBigNumber(data): | ||
case BigNumber.isBigNumber(data): | ||
return data.toString(); | ||
case Array.isArray(data): | ||
return data.map(exports.bigNumberToString); | ||
return data.map(bigNumberToString); | ||
case data && typeof data === 'object': | ||
return Object.keys(data).reduce(function (acc, field) { | ||
acc[field] = exports.bigNumberToString(data[field]); | ||
return Object.keys(data).reduce((acc, field) => { | ||
acc[field] = bigNumberToString(data[field]); | ||
return acc; | ||
@@ -14,0 +12,0 @@ }, {}); |
168
dist/cli.js
@@ -1,75 +0,97 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
import { logger } from '@heathmont/node-logger'; | ||
// import express = require('express'); | ||
const labPubKey = process.env.LAB_PUBLIC_KEY || ` | ||
-----BEGIN RSA PUBLIC KEY----- | ||
MIGJAoGBAOqi5fidE4ZaYHydHNZTqvEB42L4hmdA0sNsHpOUKvjgqW05MGn6X5i7 | ||
0MWsScKfxZPFgGF9OnLTp9kf6aiBtHz1evv9WO0Eg+Hyezq53VSPWdlh9KNznnVV | ||
JOIPttEWsX0gkuZMZIqOlz8L2RTcJjDtEAieiBfavGUA30gzRDGfAgMBAAE= | ||
-----END RSA PUBLIC KEY----- | ||
`; | ||
const flaskPrivKey = process.env.FLASK_PRIVATE_KEY || ` | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIICXQIBAAKBgQDqouX4nROGWmB8nRzWU6rxAeNi+IZnQNLDbB6TlCr44KltOTBp | ||
+l+Yu9DFrEnCn8WTxYBhfTpy06fZH+mogbR89Xr7/VjtBIPh8ns6ud1Uj1nZYfSj | ||
c551VSTiD7bRFrF9IJLmTGSKjpc/C9kU3CYw7RAInogX2rxlAN9IM0QxnwIDAQAB | ||
AoGBAOivYyCJpTM3rTfnFxH1JzCajsU3cRI0Vs82CZyQ84ycP2jxrfFrOiJdH0zo | ||
7rzzdRx2YDpN1gjJnUrVOwLAnhrnhXb2V8fMuvb54WVeJ28MzI5UkOg/RvAwsIPB | ||
5oaAhiGBl/addjsArAOR55A2AHqwSakjv7tCvuOxUrDoUaoBAkEA/Hfoh6SVJdoF | ||
i8T7O8fK8cVtqgjRxRhKIlq1Wjye+sh22E8N6zuqVhuL6+t0MfDMrl2k6k6zHmH9 | ||
ZhTxTjkLyQJBAO3rIhkAm8p8N7Ph3O0Umm0Rut7/nvKHfoxHot4mV4RaVQfhj1B4 | ||
kRlyu9SCOlMrvw7ofT0TVNgbOuufuhzfNicCQHDThW9Y9e58iI318fC9UMzLVj7u | ||
whA60qaXswQoo0Of4ry4V5gQigcBOH6uMrc+zbn+z3yGvzWMxRmhslUq2UECQQCR | ||
f52fqrabszGhiXxBZLs3/oLIw4ziByjGAz1AHDSjVVbw9eleLg2WgYsK4AVpPbSf | ||
GmEUy9C0RJrY5Bq+c2c7AkBTaDQta5HgP7UoUv7CcK9KreGrIZA1P8Q8dNeDlfQF | ||
Br6hO0fCJjpgJC/Bl7ssUiMijS8jRY0mjRhrC7i2Z6iF | ||
-----END RSA PRIVATE KEY----- | ||
`; | ||
const labUrl = process.env.LAB_URL; | ||
const flaskUrl = process.env.FLASK_URL; | ||
const flaskName = process.env.FLASK_NAME || 'legacy_cashier_flask'; | ||
const instanceUrl = process.env.FLASK_INSTANCE_URL || 'http://localhost/'; | ||
const start = async () => { | ||
// const expressServer = express(); | ||
// const lab = await init( | ||
// { | ||
// labPubKey, | ||
// flaskPrivKey, | ||
// expressServer, | ||
// labUrl, | ||
// flaskUrl, | ||
// flaskName, | ||
// instanceUrl, | ||
// autoStartHealthChecks: true, | ||
// healthCheckFunction: () => Proto.Substance.Lab.Reaction.Heartbeat.Request.Status.RUNNING, | ||
// }, | ||
// { siteId: 1 }); | ||
// try { | ||
// const listSupportedPaymentsRequest = Proto.Substance.Payments.Reaction.ListSupportedPayments.Request.create( | ||
// { | ||
// countryCode: Proto.Global.CountryCodeValue.create({ | ||
// value: Proto.Global.CountryCode.CN, | ||
// }), | ||
// currencyCode: Proto.Global.CurrencyCodeValue.create({ | ||
// value: Proto.Global.CurrencyCode.CNY, | ||
// }), | ||
// }, | ||
// ); | ||
// const listSupportedPaymentsResponse = await lab.callReaction <Proto.Substance.Payments.Reaction.ListSupportedPayments.Request, | ||
// Proto.Substance.Payments.Reaction.ListSupportedPayments.Response>( | ||
// Proto.Global.Substance.PAYMENTS, Proto.Global.Reaction.LIST_SUPPORTED_PAYMENTS, | ||
// listSupportedPaymentsRequest, Proto.Substance.Payments.Reaction.ListSupportedPayments.Response); | ||
// logger.info( | ||
// 'Proto.Global.Substance.PAYMENTS -> Proto.Global.Reaction.LIST_SUPPORTED_PAYMENTS', | ||
// { response: listSupportedPaymentsResponse }, | ||
// ); | ||
// const [supportedPayment] = listSupportedPaymentsResponse.ok.supportedPayments; | ||
// | ||
// const requestPaymentRequest = Proto.Substance.Payments.Reaction.RequestPayment.Request.create( | ||
// { | ||
// countryCode: Proto.Global.CountryCodeValue.create( | ||
// { | ||
// value: supportedPayment.countryCode.value, | ||
// }, | ||
// ), | ||
// paymentMethod: supportedPayment.paymentMethod, | ||
// paymentProvider: supportedPayment.paymentProvider, | ||
// umoney: toUMoney(new BigNumber('10000'), supportedPayment.currencyCode), | ||
// }, | ||
// ); | ||
// const requestPaymentResponse = await lab.callReaction <Proto.Substance.Payments.Reaction.RequestPayment.Request, | ||
// Proto.Substance.Payments.Reaction.RequestPayment.Response>( | ||
// Proto.Global.Substance.PAYMENTS, Proto.Global.Reaction.REQUEST_PAYMENT, | ||
// requestPaymentRequest, Proto.Substance.Payments.Reaction.RequestPayment.Response); | ||
// logger.info( | ||
// 'Proto.Global.Substance.PAYMENTS -> Proto.Global.Reaction.REQUEST_PAYMENT', | ||
// { response: requestPaymentResponse }, | ||
// ); | ||
// console.log(requestPaymentResponse.ok); | ||
// } catch (e) { | ||
// logger.error('I failed, my master.'); | ||
// } | ||
// | ||
// console.log(response.toJSON()); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) 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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = require("./index"); | ||
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf"); | ||
var node_logger_1 = require("@heathmont/node-logger"); | ||
var express = require("express"); | ||
var labPubKey = process.env.LAB_PUBLIC_KEY || "\n-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBAOqi5fidE4ZaYHydHNZTqvEB42L4hmdA0sNsHpOUKvjgqW05MGn6X5i7\n0MWsScKfxZPFgGF9OnLTp9kf6aiBtHz1evv9WO0Eg+Hyezq53VSPWdlh9KNznnVV\nJOIPttEWsX0gkuZMZIqOlz8L2RTcJjDtEAieiBfavGUA30gzRDGfAgMBAAE=\n-----END RSA PUBLIC KEY-----\n"; | ||
var flaskPrivKey = process.env.FLASK_PRIVATE_KEY || "\n-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDqouX4nROGWmB8nRzWU6rxAeNi+IZnQNLDbB6TlCr44KltOTBp\n+l+Yu9DFrEnCn8WTxYBhfTpy06fZH+mogbR89Xr7/VjtBIPh8ns6ud1Uj1nZYfSj\nc551VSTiD7bRFrF9IJLmTGSKjpc/C9kU3CYw7RAInogX2rxlAN9IM0QxnwIDAQAB\nAoGBAOivYyCJpTM3rTfnFxH1JzCajsU3cRI0Vs82CZyQ84ycP2jxrfFrOiJdH0zo\n7rzzdRx2YDpN1gjJnUrVOwLAnhrnhXb2V8fMuvb54WVeJ28MzI5UkOg/RvAwsIPB\n5oaAhiGBl/addjsArAOR55A2AHqwSakjv7tCvuOxUrDoUaoBAkEA/Hfoh6SVJdoF\ni8T7O8fK8cVtqgjRxRhKIlq1Wjye+sh22E8N6zuqVhuL6+t0MfDMrl2k6k6zHmH9\nZhTxTjkLyQJBAO3rIhkAm8p8N7Ph3O0Umm0Rut7/nvKHfoxHot4mV4RaVQfhj1B4\nkRlyu9SCOlMrvw7ofT0TVNgbOuufuhzfNicCQHDThW9Y9e58iI318fC9UMzLVj7u\nwhA60qaXswQoo0Of4ry4V5gQigcBOH6uMrc+zbn+z3yGvzWMxRmhslUq2UECQQCR\nf52fqrabszGhiXxBZLs3/oLIw4ziByjGAz1AHDSjVVbw9eleLg2WgYsK4AVpPbSf\nGmEUy9C0RJrY5Bq+c2c7AkBTaDQta5HgP7UoUv7CcK9KreGrIZA1P8Q8dNeDlfQF\nBr6hO0fCJjpgJC/Bl7ssUiMijS8jRY0mjRhrC7i2Z6iF\n-----END RSA PRIVATE KEY-----\n"; | ||
var labUrl = process.env.LAB_URL; | ||
var flaskUrl = process.env.FLASK_URL; | ||
var flaskName = process.env.FLASK_NAME || 'legacy_cashier_flask'; | ||
var instanceUrl = process.env.FLASK_INSTANCE_URL || 'http://localhost/'; | ||
var start = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var expressServer, lab; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
expressServer = express(); | ||
return [4 /*yield*/, index_1.init({ | ||
labPubKey: labPubKey, | ||
flaskPrivKey: flaskPrivKey, | ||
expressServer: expressServer, | ||
labUrl: labUrl, | ||
flaskUrl: flaskUrl, | ||
flaskName: flaskName, | ||
instanceUrl: instanceUrl, | ||
autoStartHealthChecks: true, | ||
healthCheckFunction: function () { return coingaming_protobuf_1.Proto.Substance.Lab.Reaction.Heartbeat.Request.Status.RUNNING; }, | ||
}, { siteId: 1 })]; | ||
case 1: | ||
lab = _a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
start().then(function () { | ||
node_logger_1.logger.info('Then is done.'); | ||
}).catch(node_logger_1.logger.error); | ||
start().then(() => { | ||
logger.info('Then is done.'); | ||
}).catch(logger.error); | ||
//# sourceMappingURL=cli.js.map |
@@ -1,12 +0,7 @@ | ||
import { LabConfig, LabContext } from './index'; | ||
import { Proto } from '@heathmont/coingaming-protobuf'; | ||
export interface Context { | ||
sourceFlaskName?: string; | ||
siteId?: number; | ||
targetFlaskName?: string; | ||
} | ||
import { Context } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/context_pb.js'; | ||
import { LabConfig, LabContext } from './index.js'; | ||
export declare const createSubstanceActUrl: (substanceEnum: string, actKindEnum: string, actEnum: string) => string; | ||
export declare const createLabUrl: (labConfig: Partial<LabConfig>, labContext: LabContext, substanceEnum: string, actKindEnum: string, actEnum: string) => string; | ||
export declare const createFlaskContext: (labContext: any, actKindEnum: string) => Proto.Global.Context; | ||
export declare const createContextQueryString: (contextProto: Proto.Global.Context) => string; | ||
export declare const createFlaskContext: (labContext: LabContext, actKindEnum: string) => Context; | ||
export declare const createContextQueryString: (contextProto: Context) => string; | ||
export declare const getContextFromQueryString: (context: string, actKindEnum: string) => Context; |
@@ -1,9 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf"); | ||
var querystring = require("querystring"); | ||
exports.createSubstanceActUrl = function (substanceEnum, actKindEnum, actEnum) { | ||
var substance = substanceEnum.toLowerCase(); | ||
var actKind = actKindEnum.toLowerCase(); | ||
var act; | ||
import { Context, Context_ElementContext as ProtoElementContext, Context_ReactionContext as ProtoReactionContext, Context_ObservationContext as ProtoObservationContext, Context_EffectContext as ProtoEffectContext, } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/context_pb.js'; | ||
export const createSubstanceActUrl = (substanceEnum, actKindEnum, actEnum) => { | ||
const substance = substanceEnum.toLowerCase(); | ||
const actKind = actKindEnum.toLowerCase(); | ||
let act; | ||
if (actKindEnum === 'REACTION') { | ||
@@ -16,23 +13,36 @@ act = actEnum.toLowerCase(); | ||
else { | ||
throw Error(actKindEnum + " is not implemented."); | ||
throw Error(`${actKindEnum} is not implemented.`); | ||
} | ||
return substance + "/" + actKind + "/" + act; | ||
return `${substance}/${actKind}/${act}`; | ||
}; | ||
exports.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 queryStringObj = { | ||
export const createLabUrl = (labConfig, labContext, substanceEnum, actKindEnum, actEnum) => { | ||
const { labUrl } = labConfig; | ||
const relativePath = createSubstanceActUrl(substanceEnum, actKindEnum, actEnum); | ||
const contextProto = createFlaskContext(labContext, actKindEnum); | ||
const contextQueryString = createContextQueryString(contextProto); | ||
const queryStringObj = { | ||
c: contextQueryString, | ||
}; | ||
var queryString = querystring.stringify(queryStringObj); | ||
return labUrl + "/protobuf/" + relativePath + "?" + queryString; | ||
const queryString = new URLSearchParams(queryStringObj).toString(); | ||
return `${labUrl}/protobuf/${relativePath}?${queryString}`; | ||
}; | ||
exports.createFlaskContext = function (labContext, actKindEnum) { | ||
var targetFlaskName = labContext.targetFlaskName; | ||
return coingaming_protobuf_1.Proto.Global.Context.create({ | ||
siteId: labContext.siteId ? coingaming_protobuf_1.Google.Protobuf.UInt64Value.create({ | ||
value: labContext.siteId, | ||
}) : undefined, | ||
export const createFlaskContext = (labContext, actKindEnum) => { | ||
const targetFlaskName = labContext.targetFlaskName; | ||
let either; | ||
switch (actKindEnum) { | ||
case 'ELEMENT': | ||
either = { case: 'element', value: new ProtoElementContext({ targetFlaskName: { value: targetFlaskName } }), }; | ||
break; | ||
case 'REACTION': | ||
either = { case: 'reaction', value: new ProtoReactionContext({ targetFlaskName: { value: targetFlaskName } }), }; | ||
break; | ||
case 'OBSERVATION': | ||
either = { case: 'observation', value: new ProtoObservationContext({ targetFlaskName: { value: targetFlaskName } }), }; | ||
break; | ||
case 'EFFECT': | ||
either = { case: 'effect', value: new ProtoEffectContext({ targetFlaskName }), }; | ||
break; | ||
} | ||
const context = new Context({ | ||
siteId: { value: BigInt(labContext.siteId) }, | ||
operatorId: labContext.operatorId ? labContext.operatorId : undefined, | ||
@@ -42,39 +52,12 @@ subjectInfo: labContext.subjectInfo ? labContext.subjectInfo : undefined, | ||
sourceFlaskInstanceUuid: Buffer.from(labContext.instanceUuid), | ||
element: actKindEnum === 'ELEMENT' ? | ||
coingaming_protobuf_1.Proto.Global.Context.ElementContext.create({ | ||
targetFlaskName: coingaming_protobuf_1.Google.Protobuf.StringValue.create({ value: targetFlaskName }), | ||
targetFlaskInstanceUuid: undefined, | ||
}) | ||
: undefined, | ||
reaction: actKindEnum === 'REACTION' ? | ||
coingaming_protobuf_1.Proto.Global.Context.ReactionContext.create({ | ||
targetFlaskName: coingaming_protobuf_1.Google.Protobuf.StringValue.create({ value: targetFlaskName }), | ||
targetFlaskInstanceUuid: undefined, | ||
}) | ||
: undefined, | ||
either | ||
}); | ||
return context; | ||
}; | ||
exports.createContextQueryString = function (contextProto) { | ||
var encoded = contextProto.constructor.encode(contextProto).finish(); | ||
return encoded.toString('base64'); | ||
export const createContextQueryString = (contextProto) => { | ||
return Buffer.from(contextProto.toBinary()).toString('base64'); | ||
}; | ||
exports.getContextFromQueryString = function (context, actKindEnum) { | ||
var contextProto = coingaming_protobuf_1.Proto.Global.Context.decode(Buffer.from(context, 'base64')); | ||
var targetFlaskName; | ||
switch (actKindEnum) { | ||
case 'ELEMENT': | ||
targetFlaskName = contextProto.element.targetFlaskName ? | ||
contextProto.element.targetFlaskName.value : undefined; | ||
break; | ||
case 'REACTION': | ||
targetFlaskName = contextProto.reaction.targetFlaskName ? | ||
contextProto.reaction.targetFlaskName.value : undefined; | ||
break; | ||
} | ||
return { | ||
siteId: contextProto.siteId ? parseInt(contextProto.siteId.value.toString(), 10) : undefined, | ||
sourceFlaskName: contextProto.sourceFlaskName, | ||
targetFlaskName: targetFlaskName, | ||
}; | ||
export const getContextFromQueryString = (context, actKindEnum) => { | ||
return Context.fromBinary(Buffer.from(context, 'base64')); | ||
}; | ||
//# sourceMappingURL=createUrls.js.map |
import BigNumber from 'bignumber.js'; | ||
import { Proto } from '@heathmont/coingaming-protobuf'; | ||
export declare const decimalToBigNumber: (decimal: Proto.Global.Decimal) => BigNumber; | ||
export declare const udecimalToBigNumber: ({ exp, coef }: Proto.Global.UDecimal) => BigNumber; | ||
import { Decimal as ProtoDecimal } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/decimal_pb.js'; | ||
import { UDecimal as ProtoUDecimal } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/udecimal_pb.js'; | ||
export declare const decimalToBigNumber: (decimal: ProtoDecimal) => BigNumber; | ||
export declare const udecimalToBigNumber: ({ exp, coef }: ProtoUDecimal) => BigNumber; |
@@ -1,6 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bignumber_js_1 = require("bignumber.js"); | ||
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf"); | ||
exports.decimalToBigNumber = function (decimal) { | ||
import BigNumber from 'bignumber.js'; | ||
import { Decimal as ProtoDecimal } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/decimal_pb.js'; | ||
export const decimalToBigNumber = (decimal) => { | ||
if (decimal.coef === undefined) { | ||
@@ -12,8 +10,7 @@ throw new Error('Cant convert decimal to BigNumber (missing .coef), did you pass undefined/null?'); | ||
} | ||
return new bignumber_js_1.default(decimal.negative ? -1 : 1).times(decimal.coef.toString()).shiftedBy(decimal.exp); | ||
return new BigNumber(decimal.negative ? -1 : 1).times(decimal.coef.toString()).shiftedBy(decimal.exp); | ||
}; | ||
exports.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 })); | ||
export const udecimalToBigNumber = ({ exp, coef }) => { | ||
return decimalToBigNumber(new ProtoDecimal({ coef, exp, negative: false })); | ||
}; | ||
//# 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; |
@@ -1,26 +0,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLabError = function (type, errors) { | ||
if (type === void 0) { type = 'BUSINESS_LOGIC'; } | ||
if (errors === void 0) { errors = []; } | ||
export const createLabError = (type = 'BUSINESS_LOGIC', errors = []) => { | ||
return { | ||
type: type, | ||
errors: errors, | ||
type, | ||
errors, | ||
}; | ||
}; | ||
exports.createParameterError = function (name, value) { | ||
export const createParameterError = (name, value) => { | ||
return { | ||
name: name, | ||
value: value, | ||
name, | ||
value, | ||
}; | ||
}; | ||
exports.addParameterError = function (labError, name, value) { | ||
labError.errors.push(exports.createParameterError(name, value)); | ||
export const addParameterError = (labError, name, value) => { | ||
labError.errors.push(createParameterError(name, value)); | ||
}; | ||
exports.handleLabError = function (errorResponse, kind) { | ||
var error = exports.createLabError(); | ||
Object.keys(errorResponse).filter(function (key) { return key !== 'toJSON'; }).forEach(function (name) { | ||
export const handleLabError = (errorResponse, kind) => { | ||
const error = createLabError(); | ||
Object.keys(errorResponse).filter(key => key !== 'toJSON').forEach((name) => { | ||
if (errorResponse[name]) { | ||
var value = errorResponse[name].value; | ||
exports.addParameterError(error, name, kind[value]); | ||
const value = errorResponse[name].value; | ||
addParameterError(error, name, kind[value]); | ||
} | ||
@@ -30,10 +26,10 @@ }); | ||
}; | ||
exports.handleInternalError = function (e) { | ||
var error = exports.createLabError('INTERNAL'); | ||
export const handleInternalError = (e) => { | ||
const error = createLabError('INTERNAL'); | ||
if (e.message) | ||
exports.addParameterError(error, 'message', e.message); | ||
addParameterError(error, 'message', e.message); | ||
if (e.stack) | ||
exports.addParameterError(error, 'stack', e.stack); | ||
addParameterError(error, 'stack', e.stack); | ||
return error; | ||
}; | ||
//# sourceMappingURL=errorHandler.js.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.implementFlaskSubstance = function (labConfig) { | ||
export const implementFlaskSubstance = (labConfig) => { | ||
// const { expressServer } = labConfig; | ||
@@ -5,0 +3,0 @@ // const createSubstanceActUrl |
/// <reference types="node" /> | ||
import { Context } from './createUrls'; | ||
/// <reference types="node" /> | ||
import { Context } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/context_pb.js'; | ||
import { Message } from "@bufbuild/protobuf"; | ||
import { LabConfig } from './'; | ||
import express = require('express'); | ||
import express from '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 Message<REQ>, RES extends Message<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 +10,0 @@ [reactionEnum: string]: (reqDataR: Buffer, context: Context, rawReq: express.Request) => any; |
@@ -1,92 +0,39 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) 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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
import { createSubstanceActUrl, getContextFromQueryString } from './createUrls'; | ||
import { logger } from '@heathmont/node-logger'; | ||
const bindImplementations = (labConfig, substance, actKindEnum, implementations) => { | ||
const { expressServer } = labConfig; | ||
const implementationKeys = Object.keys(implementations); | ||
for (const actEnum of implementationKeys) { | ||
const actPath = createSubstanceActUrl(substance, actKindEnum, actEnum); | ||
const implementation = implementations[actEnum]; | ||
logger.debug(`Attaching binding ${labConfig.flaskPathnameProto}/${actPath} with async function`); | ||
expressServer.post(`${labConfig.flaskPathnameProto}/${actPath}`, async (req, res) => { | ||
logger.debug('Handling POST for url', { url: `${labConfig.flaskPathnameProto}/${actPath}`, | ||
body: req.body, | ||
queryC: req.query.c, | ||
}); | ||
const isSignatureValid = labConfig.hmCrypto.isValid(req.body, req.headers['x-lab-signature']); | ||
const context = getContextFromQueryString(req.query.c, actKindEnum); | ||
if (!isSignatureValid) { | ||
logger.warn('Lab signature invalid', { actPath, context, requestHeaders: req.headers }); | ||
return res.sendStatus(400); | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
let responseProtobuf; | ||
try { | ||
logger.debug('Before executing implementation', { SOMETHING: responseProtobuf }); | ||
responseProtobuf = await implementation(req.body, context, req); | ||
logger.info('After executing implementation', responseProtobuf); | ||
} | ||
catch (e) { | ||
logger.error('Got error on executing implementation', e); | ||
res.sendStatus(400, 'Impossible to process'); | ||
return; | ||
} | ||
const responseData = Buffer.from(responseProtobuf.toBinary()); | ||
res.set('content-type', 'application/x-protobuf'); | ||
res.send(responseData); | ||
}); | ||
} | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var createUrls_1 = require("./createUrls"); | ||
var node_logger_1 = require("@heathmont/node-logger"); | ||
var bindImplementations = function (labConfig, substance, actKindEnum, implementations) { | ||
var expressServer = labConfig.expressServer; | ||
var implementationKeys = Object.keys(implementations); | ||
var _loop_1 = function (actEnum) { | ||
var actPath = 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 () { | ||
var isSignatureValid, context, responseProtobuf, e_1, responseData; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
node_logger_1.logger.debug('Handling POST for url', { url: labConfig.flaskPathnameProto + "/" + actPath, | ||
body: req.body, | ||
queryC: req.query.c, | ||
}); | ||
isSignatureValid = labConfig.hmCrypto.isValid(req.body, req.headers['x-lab-signature']); | ||
context = createUrls_1.getContextFromQueryString(req.query.c, actKindEnum); | ||
if (!isSignatureValid) { | ||
node_logger_1.logger.warn('Lab signature invalid', { actPath: actPath, context: context, requestHeaders: req.headers }); | ||
return [2 /*return*/, res.sendStatus(400)]; | ||
} | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
node_logger_1.logger.debug('Before executing implementation', { SOMETHING: responseProtobuf }); | ||
return [4 /*yield*/, implementation(req.body, context, req)]; | ||
case 2: | ||
responseProtobuf = _a.sent(); | ||
node_logger_1.logger.info('After executing implementation', responseProtobuf); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
node_logger_1.logger.error('Got error on executing implementation', e_1); | ||
res.sendStatus(400, 'Impossible to process'); | ||
return [2 /*return*/]; | ||
case 4: | ||
responseData = responseProtobuf.constructor.encode(responseProtobuf).finish(); | ||
res.set('content-type', 'application/x-protobuf'); | ||
res.send(responseData); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}; | ||
for (var _i = 0, implementationKeys_1 = implementationKeys; _i < implementationKeys_1.length; _i++) { | ||
var actEnum = implementationKeys_1[_i]; | ||
_loop_1(actEnum); | ||
} | ||
}; | ||
exports.privateImplemenSubstance = function (labConfig, substance, implementations) { | ||
export const privateImplemenSubstance = (labConfig, substance, implementations) => { | ||
if (implementations.element) { | ||
@@ -99,28 +46,22 @@ bindImplementations(labConfig, substance, 'ELEMENT', implementations.element); | ||
}; | ||
exports.implement = function (requestClass, processor) { | ||
return function (reqData, context, rawReq) { return __awaiter(_this, void 0, void 0, function () { | ||
var req; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
try { | ||
req = decodeRequestBody(requestClass, reqData); | ||
} | ||
catch (e) { | ||
node_logger_1.logger.error('Error decoding body', { reqBodyLength: rawReq.body.toString().length }); | ||
throw e; | ||
} | ||
return [4 /*yield*/, processor(req, context, rawReq)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
export const implement = (requestClass, processor) => { | ||
return async (reqData, context, rawReq) => { | ||
let req; | ||
try { | ||
req = decodeRequestBody(requestClass, reqData); | ||
} | ||
catch (e) { | ||
logger.error('Error decoding body', { reqBodyLength: rawReq.body.toString().length }); | ||
throw e; | ||
} | ||
return await processor(req, context, rawReq); | ||
}; | ||
}; | ||
var decodeRequestBody = function (requestClass, reqData) { | ||
var req; | ||
const decodeRequestBody = (requestClass, reqData) => { | ||
let req; | ||
try { | ||
req = requestClass.decode(reqData); | ||
req = requestClass.fromBinary(reqData); | ||
} | ||
catch (e) { | ||
node_logger_1.logger.error('Failed to decode request', { reqData: reqData }); | ||
logger.error('Failed to decode request', { reqData }); | ||
throw e; | ||
@@ -127,0 +68,0 @@ } |
@@ -1,8 +0,9 @@ | ||
import 'source-map-support/register'; | ||
import { Google, Proto } from '@heathmont/coingaming-protobuf'; | ||
import { ClassInstance, PartialBy, ProtobufMessage, ProtobufResponse } from './types/types'; | ||
import { Message, PartialMessage } from "@bufbuild/protobuf"; | ||
import { PartialBy } from './types/types'; | ||
import { Implementations } from './implementSubstance'; | ||
import * as Long from 'long'; | ||
import Long from 'long'; | ||
import { Request as HealthCheckRequest, Request_Status } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/substance/lab/reaction/heartbeat_pb.js'; | ||
import { Context_SubjectInfo } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/context_pb.js'; | ||
export declare const PROTOBUF_URL_PREFIX = "protobuf"; | ||
export declare const implementFlaskMeta: (metaFunction: any) => Proto.Substance.Flask.Reaction.HealthCheck.Request; | ||
export declare const implementFlaskMeta: (metaFunction: any) => HealthCheckRequest; | ||
export interface InitOptions { | ||
@@ -17,3 +18,3 @@ flaskName: string; | ||
instanceUrl: string; | ||
healthCheckFunction: () => Proto.Substance.Lab.Reaction.Heartbeat.Request.Status; | ||
healthCheckFunction: () => Request_Status; | ||
autoStartHealthChecks?: boolean; | ||
@@ -27,3 +28,3 @@ } | ||
instanceUrl: string; | ||
healthCheckFunction: () => Proto.Substance.Lab.Reaction.Heartbeat.Request.Status; | ||
healthCheckFunction: () => Request_Status; | ||
flaskPrivKey: string; | ||
@@ -39,3 +40,3 @@ flaskPubKey: string; | ||
operatorId: number; | ||
subjectInfo?: Proto.Global.Context.SubjectInfo; | ||
subjectInfo?: Context_SubjectInfo; | ||
targetFlaskName?: string; | ||
@@ -52,21 +53,23 @@ instanceUuid?: string; | ||
export interface CallElementFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>>(substanceEnum: string, reactionEnum: string, request: REQ, responseClass: ClassInstance<RESP>, context?: Partial<LabContext>): Promise<RESP>; | ||
<REQ extends Message<REQ>, RESP extends Message<RESP>>(substanceEnum: string, reactionEnum: string, request: REQ, responseClass: { | ||
new (data?: PartialMessage<RESP>): RESP; | ||
}, context?: Partial<LabContext>): Promise<RESP>; | ||
} | ||
export interface CallReactionFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP>(substanceEnum: string, reactionEnum: string, request: REQ, responseClass: ClassInstance<RESP>, context?: Partial<LabContext>): Promise<ProtobufResponse<RESP>>; | ||
<REQ extends Message<REQ>, RESP extends Message<RESP>>(substanceEnum: string, reactionEnum: string, request: REQ, responseClass: { | ||
new (data?: PartialMessage<RESP>): RESP; | ||
}, context?: Partial<LabContext>): Promise<RESP>; | ||
} | ||
export declare const init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<PartialBy<PartialBy<LabContext, "sourceFlaskName">, "siteId">, "operatorId">, "subjectInfo">) => Promise<Lab>; | ||
export declare const init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<PartialBy<PartialBy<LabContext, 'sourceFlaskName'>, 'siteId'>, 'operatorId'>, 'subjectInfo'>) => Promise<Lab>; | ||
declare const defaultExport: { | ||
init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<PartialBy<PartialBy<LabContext, "sourceFlaskName">, "siteId">, "operatorId">, "subjectInfo">) => Promise<Lab>; | ||
longToBigNumber: (long: Long) => import("bignumber.js").BigNumber; | ||
decimalToBigNumber: (decimal: Proto.Global.Decimal) => import("bignumber.js").BigNumber; | ||
udecimalToBigNumber: ({ exp, coef }: Proto.Global.UDecimal) => import("bignumber.js").BigNumber; | ||
moneyHelper: (money: Proto.Global.Money) => import("./moneyHelper").Money; | ||
umoneyHelper: (money: Proto.Global.UMoney) => import("./moneyHelper").Money; | ||
bigNumberToDecimal: (bigNumber: import("bignumber.js").BigNumber) => Proto.Global.Decimal; | ||
bigNumberToUDecimal: (bigNumber: import("bignumber.js").BigNumber) => Proto.Global.UDecimal; | ||
toMoney: (amount: import("bignumber.js").BigNumber, currency: string) => Proto.Global.Money; | ||
toUMoney: (amount: import("bignumber.js").BigNumber, currency: string) => Proto.Global.UMoney; | ||
Google: typeof Google; | ||
Proto: typeof Proto; | ||
init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<PartialBy<PartialBy<LabContext, 'sourceFlaskName'>, 'siteId'>, 'operatorId'>, 'subjectInfo'>) => Promise<Lab>; | ||
longToBigNumber: (long: Long) => import("bignumber.js").default; | ||
decimalToBigNumber: (decimal: import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/decimal_pb").Decimal) => import("bignumber.js").default; | ||
udecimalToBigNumber: ({ exp, coef }: import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/udecimal_pb").UDecimal) => import("bignumber.js").default; | ||
moneyHelper: (money: import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/money_pb").Money) => import("./moneyHelper").Money; | ||
umoneyHelper: (money: import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/umoney_pb").UMoney) => import("./moneyHelper").Money; | ||
bigNumberToDecimal: (bigNumber: import("bignumber.js").default) => import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/decimal_pb").Decimal; | ||
bigNumberToUDecimal: (bigNumber: import("bignumber.js").default) => import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/udecimal_pb").UDecimal; | ||
toMoney: (amount: import("bignumber.js").default, currency: string) => import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/money_pb").Money; | ||
toUMoney: (amount: import("bignumber.js").default, currency: string) => import("@heathmont/coingaming-protobuf/dist/lab_protobuf/global/umoney_pb").UMoney; | ||
handleLabError: <T>(errorResponse: T, kind: any) => import("./errorHandler").LabError; | ||
@@ -73,0 +76,0 @@ createLabError: (type?: "BUSINESS_LOGIC" | "INTERNAL", errors?: import("./errorHandler").ParameterError[]) => import("./errorHandler").LabError; |
@@ -1,197 +0,129 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
import sourceMapSupport from 'source-map-support'; | ||
import { sendRequest } from './sendRequest'; | ||
import HmCrypto from 'hm-crypto-nodejs'; | ||
import { sendHealthCheck } from './sendHealthCheck'; | ||
import { logger } from '@heathmont/node-logger'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { hostname } from 'os'; | ||
import { URL } from 'url'; | ||
import forge from 'node-forge'; | ||
import bodyParser from 'body-parser'; | ||
import { privateImplemenSubstance } from './implementSubstance'; | ||
import { longToBigNumber } from './longToBigNumber'; | ||
import { decimalToBigNumber, udecimalToBigNumber } from './decimalToBigNumber'; | ||
import { moneyHelper, toMoney, toUMoney, umoneyHelper } from './moneyHelper'; | ||
import { bigNumberToDecimal, bigNumberToUDecimal } from './bigNumberToDecimal'; | ||
import { createLabError, handleLabError } from './errorHandler'; | ||
import { bigNumberToString } from './bigNumberToString'; | ||
import path from 'path'; | ||
import { Request as HealthCheckRequest } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/substance/lab/reaction/heartbeat_pb.js'; | ||
sourceMapSupport.install(); | ||
export const PROTOBUF_URL_PREFIX = 'protobuf'; | ||
export const implementFlaskMeta = (metaFunction) => { | ||
return new HealthCheckRequest({}); | ||
}; | ||
export const init = async (options, initDefaultContext) => { | ||
const requiredOptions = ['flaskName', 'labUrl', 'labPubKey', 'flaskPrivKey', 'instanceUrl', 'healthCheckFunction']; | ||
Object.keys(options).forEach((optionKey) => { | ||
if (requiredOptions.includes(optionKey) && !options[optionKey]) { | ||
throw new Error(`Missing option "${optionKey}"`); | ||
} | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) 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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
const { flaskName, flaskUrl, expressServer, labUrl, flaskPrivKey, instanceUuid, instanceUrl, healthCheckFunction, } = options; | ||
const defaultContext = Object.assign({}, initDefaultContext, { sourceFlaskName: flaskName }); | ||
const autoStartHealthChecks = options.autoStartHealthChecks !== undefined ? options.autoStartHealthChecks : true; | ||
const pki = forge.pki; | ||
const privateKey = pki.privateKeyFromPem(flaskPrivKey); | ||
const publicKey = pki.setRsaPublicKey(privateKey.n, privateKey.e); | ||
const flaskPubKey = pki.publicKeyToPem(publicKey); | ||
const { pathname: flaskPathname } = new URL(flaskUrl); | ||
const flaskPathnameProto = path.join(flaskPathname, PROTOBUF_URL_PREFIX); | ||
const labConfig = { | ||
flaskName, | ||
expressServer, | ||
labUrl, | ||
instanceUrl, | ||
healthCheckFunction, | ||
flaskPrivKey, | ||
flaskPubKey, | ||
flaskPathname, | ||
flaskPathnameProto, | ||
hmCrypto: HmCrypto('RSA-SHA256', flaskPrivKey, options.labPubKey), | ||
defaultContext, | ||
}; | ||
defaultContext.instanceUuid = instanceUuid ? instanceUuid : `${hostname()}-${uuidv4()}`; | ||
if (expressServer) { | ||
expressServer.post(`${flaskPathnameProto}*`, (req, res, next) => { | ||
logger.debug('Lab request incoming', { reqHeaders: req.headers }); | ||
next(); | ||
}); | ||
logger.debug('Adding body parser for path', { path: flaskPathnameProto }); | ||
expressServer.post(`${flaskPathnameProto}*`, bodyParser.raw({ | ||
type: 'application/*', | ||
limit: '10mb', | ||
})); | ||
} | ||
const callReaction = async (substanceEnum, reactionEnum, request, responseClass, context) => { | ||
return sendRequest(labConfig, substanceEnum, 'REACTION', reactionEnum, request, responseClass, context); | ||
}; | ||
const callElement = async (substanceEnum, reactionEnum, request, responseClass, context) => { | ||
return await sendRequest(labConfig, substanceEnum, 'ELEMENT', reactionEnum, request, responseClass, context); | ||
}; | ||
const implementFlaskSubstance = async (implementations) => { | ||
privateImplemenSubstance(labConfig, 'FLASK', implementations); | ||
}; | ||
const implementSubstance = (substanceEnum, implementations) => { | ||
return privateImplemenSubstance(labConfig, substanceEnum, implementations); | ||
}; | ||
let failedHealthChecks = 0; | ||
const startHealthCheck = async () => { | ||
try { | ||
await sendHealthCheck(labConfig, healthCheckFunction(), callReaction); | ||
failedHealthChecks = 0; | ||
setTimeout(startHealthCheck, 10000); | ||
} | ||
catch (error) { | ||
failedHealthChecks = failedHealthChecks + 1; | ||
logger.error('Error sending health check to LAB', { | ||
errMessage: error.message, | ||
errStack: error.stack, | ||
failedHealthChecks, | ||
}); | ||
if (failedHealthChecks > 3 && !process.env.SURVIVE_WITHOUT_LAB) { | ||
logger.error('Health checks failed with LAB, bailing out.'); | ||
process.exit(1); | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
else { | ||
setTimeout(startHealthCheck, 10000); | ||
} | ||
} | ||
}; | ||
if (autoStartHealthChecks) { | ||
await startHealthCheck(); | ||
} | ||
return { | ||
callReaction, | ||
callElement, | ||
implementSubstance, | ||
// implementFlaskSubstance, | ||
getInstanceUrl: () => labConfig.instanceUrl, | ||
getInstanceUuid: () => defaultContext.instanceUuid, | ||
}; | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("source-map-support/register"); | ||
var sendRequest_1 = require("./sendRequest"); | ||
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf"); | ||
var HmCrypto = require("hm-crypto-nodejs"); | ||
var sendHealthCheck_1 = require("./sendHealthCheck"); | ||
var node_logger_1 = require("@heathmont/node-logger"); | ||
var uuidv4 = require("uuid/v4"); | ||
var os_1 = require("os"); | ||
var url_1 = require("url"); | ||
var forge = require("node-forge"); | ||
var bodyParser = require("body-parser"); | ||
var implementSubstance_1 = require("./implementSubstance"); | ||
var longToBigNumber_1 = require("./longToBigNumber"); | ||
var decimalToBigNumber_1 = require("./decimalToBigNumber"); | ||
var moneyHelper_1 = require("./moneyHelper"); | ||
var bigNumberToDecimal_1 = require("./bigNumberToDecimal"); | ||
var errorHandler_1 = require("./errorHandler"); | ||
var bigNumberToString_1 = require("./bigNumberToString"); | ||
var path = require("path"); | ||
exports.PROTOBUF_URL_PREFIX = 'protobuf'; | ||
exports.implementFlaskMeta = function (metaFunction) { | ||
return new coingaming_protobuf_1.Proto.Substance.Flask.Reaction.HealthCheck.Request({}); | ||
const defaultExport = { | ||
init, | ||
longToBigNumber, | ||
decimalToBigNumber, | ||
udecimalToBigNumber, | ||
moneyHelper, | ||
umoneyHelper, | ||
bigNumberToDecimal, | ||
bigNumberToUDecimal, | ||
toMoney, | ||
toUMoney, | ||
handleLabError, | ||
createLabError, | ||
bigNumberToString, | ||
}; | ||
exports.init = function (options, initDefaultContext) { return __awaiter(_this, 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) { | ||
switch (_a.label) { | ||
case 0: | ||
requiredOptions = ['flaskName', 'labUrl', 'labPubKey', 'flaskPrivKey', 'instanceUrl', 'healthCheckFunction']; | ||
Object.keys(options).forEach(function (optionKey) { | ||
if (requiredOptions.includes(optionKey) && !options[optionKey]) { | ||
throw new Error("Missing option \"" + optionKey + "\""); | ||
} | ||
}); | ||
flaskName = options.flaskName, flaskUrl = options.flaskUrl, expressServer = options.expressServer, labUrl = options.labUrl, flaskPrivKey = options.flaskPrivKey, instanceUuid = options.instanceUuid, instanceUrl = options.instanceUrl, healthCheckFunction = options.healthCheckFunction; | ||
defaultContext = Object.assign({}, initDefaultContext, { sourceFlaskName: flaskName }); | ||
autoStartHealthChecks = options.autoStartHealthChecks !== undefined ? options.autoStartHealthChecks : true; | ||
pki = forge.pki; | ||
privateKey = pki.privateKeyFromPem(flaskPrivKey); | ||
publicKey = pki.setRsaPublicKey(privateKey.n, privateKey.e); | ||
flaskPubKey = pki.publicKeyToPem(publicKey); | ||
flaskPathname = new url_1.URL(flaskUrl).pathname; | ||
flaskPathnameProto = path.join(flaskPathname, exports.PROTOBUF_URL_PREFIX); | ||
labConfig = { | ||
flaskName: flaskName, | ||
expressServer: expressServer, | ||
labUrl: labUrl, | ||
instanceUrl: instanceUrl, | ||
healthCheckFunction: healthCheckFunction, | ||
flaskPrivKey: flaskPrivKey, | ||
flaskPubKey: flaskPubKey, | ||
flaskPathname: flaskPathname, | ||
flaskPathnameProto: flaskPathnameProto, | ||
hmCrypto: HmCrypto('RSA-SHA256', flaskPrivKey, options.labPubKey), | ||
defaultContext: defaultContext, | ||
}; | ||
defaultContext.instanceUuid = instanceUuid ? instanceUuid : os_1.hostname() + "-" + uuidv4(); | ||
if (expressServer) { | ||
expressServer.post(flaskPathnameProto + "*", function (req, res, next) { | ||
node_logger_1.logger.debug('Lab request incoming', { reqHeaders: req.headers }); | ||
next(); | ||
}); | ||
node_logger_1.logger.debug('Adding body parser for path', { path: flaskPathnameProto }); | ||
expressServer.post(flaskPathnameProto + "*", bodyParser.raw({ | ||
type: 'application/*', | ||
limit: '10mb', | ||
})); | ||
} | ||
callReaction = function (substanceEnum, reactionEnum, request, responseClass, context) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, 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 () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, sendRequest_1.sendRequest(labConfig, substanceEnum, 'ELEMENT', reactionEnum, request, responseClass, context)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
implementFlaskSubstance = function (implementations) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
implementSubstance_1.privateImplemenSubstance(labConfig, 'FLASK', implementations); | ||
return [2 /*return*/]; | ||
}); | ||
}); }; | ||
implementSubstance = function (substanceEnum, implementations) { | ||
return implementSubstance_1.privateImplemenSubstance(labConfig, substanceEnum, implementations); | ||
}; | ||
failedHealthChecks = 0; | ||
startHealthCheck = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, sendHealthCheck_1.sendHealthCheck(labConfig, healthCheckFunction(), callReaction)]; | ||
case 1: | ||
_a.sent(); | ||
failedHealthChecks = 0; | ||
setTimeout(startHealthCheck, 10000); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
error_1 = _a.sent(); | ||
failedHealthChecks = failedHealthChecks + 1; | ||
node_logger_1.logger.error('Error sending health check to LAB', { | ||
errMessage: error_1.message, | ||
errStack: error_1.stack, | ||
failedHealthChecks: failedHealthChecks, | ||
}); | ||
if (failedHealthChecks > 3 && !process.env.SURVIVE_WITHOUT_LAB) { | ||
node_logger_1.logger.error('Health checks failed with LAB, bailing out.'); | ||
process.exit(1); | ||
} | ||
else { | ||
setTimeout(startHealthCheck, 10000); | ||
} | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
if (!autoStartHealthChecks) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, startHealthCheck()]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, { | ||
callReaction: callReaction, | ||
callElement: callElement, | ||
implementSubstance: implementSubstance, | ||
// implementFlaskSubstance, | ||
getInstanceUrl: function () { return labConfig.instanceUrl; }, | ||
getInstanceUuid: function () { return defaultContext.instanceUuid; }, | ||
}]; | ||
} | ||
}); | ||
}); }; | ||
var defaultExport = { | ||
init: exports.init, | ||
longToBigNumber: longToBigNumber_1.longToBigNumber, | ||
decimalToBigNumber: decimalToBigNumber_1.decimalToBigNumber, | ||
udecimalToBigNumber: decimalToBigNumber_1.udecimalToBigNumber, | ||
moneyHelper: moneyHelper_1.moneyHelper, | ||
umoneyHelper: moneyHelper_1.umoneyHelper, | ||
bigNumberToDecimal: bigNumberToDecimal_1.bigNumberToDecimal, | ||
bigNumberToUDecimal: bigNumberToDecimal_1.bigNumberToUDecimal, | ||
toMoney: moneyHelper_1.toMoney, | ||
toUMoney: moneyHelper_1.toUMoney, | ||
Google: coingaming_protobuf_1.Google, | ||
Proto: coingaming_protobuf_1.Proto, | ||
handleLabError: errorHandler_1.handleLabError, | ||
createLabError: errorHandler_1.createLabError, | ||
bigNumberToString: bigNumberToString_1.bigNumberToString, | ||
}; | ||
exports.default = defaultExport; | ||
export default defaultExport; | ||
//# sourceMappingURL=index.js.map |
import BigNumber from 'bignumber.js'; | ||
import * as Long from 'long'; | ||
import Long from 'long'; | ||
export declare const longToBigNumber: (long: Long) => BigNumber; |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bignumber_js_1 = require("bignumber.js"); | ||
exports.longToBigNumber = function (long) { | ||
return new bignumber_js_1.default(long.toString()); | ||
import BigNumber from 'bignumber.js'; | ||
export const longToBigNumber = (long) => { | ||
return new BigNumber(long.toString()); | ||
}; | ||
//# sourceMappingURL=longToBigNumber.js.map |
@@ -1,2 +0,3 @@ | ||
import { Proto } from '@heathmont/coingaming-protobuf'; | ||
import { Money as ProtoMoney } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/money_pb.js'; | ||
import { UMoney as ProtoUMoney } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/umoney_pb.js'; | ||
import BigNumber from 'bignumber.js'; | ||
@@ -11,5 +12,5 @@ export interface Money { | ||
} | ||
export declare const moneyHelper: (money: Proto.Global.Money) => Money; | ||
export declare const umoneyHelper: (money: Proto.Global.UMoney) => Money; | ||
export declare const toMoney: (amount: BigNumber, currency: string) => Proto.Global.Money; | ||
export declare const toUMoney: (amount: BigNumber, currency: string) => Proto.Global.UMoney; | ||
export declare const moneyHelper: (money: ProtoMoney) => Money; | ||
export declare const umoneyHelper: (money: ProtoUMoney) => Money; | ||
export declare const toMoney: (amount: BigNumber, currency: string) => ProtoMoney; | ||
export declare const toUMoney: (amount: BigNumber, currency: string) => ProtoUMoney; |
@@ -1,32 +0,30 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var coingaming_protobuf_1 = require("@heathmont/coingaming-protobuf"); | ||
var decimalToBigNumber_1 = require("./decimalToBigNumber"); | ||
var bigNumberToDecimal_1 = require("./bigNumberToDecimal"); | ||
exports.moneyHelper = function (money) { | ||
import { Money as ProtoMoney } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/money_pb.js'; | ||
import { UMoney as ProtoUMoney } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/umoney_pb.js'; | ||
import { CurrencyCode } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/global/currency_code_pb.js'; | ||
import { decimalToBigNumber, udecimalToBigNumber } from './decimalToBigNumber'; | ||
import { bigNumberToDecimal, bigNumberToUDecimal } from './bigNumberToDecimal'; | ||
export const moneyHelper = (money) => { | ||
return { | ||
amount: decimalToBigNumber_1.decimalToBigNumber(money.amount), | ||
currencyCode: coingaming_protobuf_1.Proto.Global.CurrencyCode[money.currencyCode.value], | ||
amount: decimalToBigNumber(money.amount), | ||
currencyCode: CurrencyCode[money.currencyCode.value], | ||
}; | ||
}; | ||
exports.umoneyHelper = function (money) { | ||
export const umoneyHelper = (money) => { | ||
return { | ||
amount: decimalToBigNumber_1.udecimalToBigNumber(money.amount), | ||
currencyCode: coingaming_protobuf_1.Proto.Global.CurrencyCode[money.currencyCode.value], | ||
amount: udecimalToBigNumber(money.amount), | ||
currencyCode: CurrencyCode[money.currencyCode.value], | ||
}; | ||
}; | ||
exports.toMoney = function (amount, currency) { | ||
return coingaming_protobuf_1.Proto.Global.Money.create({ | ||
amount: bigNumberToDecimal_1.bigNumberToDecimal(amount), | ||
currencyCode: currency ? | ||
coingaming_protobuf_1.Proto.Global.CurrencyCodeValue.create({ value: coingaming_protobuf_1.Proto.Global.CurrencyCode[currency] }) : null, | ||
export const toMoney = (amount, currency) => { | ||
return new ProtoMoney({ | ||
amount: bigNumberToDecimal(amount), | ||
currencyCode: currency ? CurrencyCode[currency] : null, | ||
}); | ||
}; | ||
exports.toUMoney = function (amount, currency) { | ||
return coingaming_protobuf_1.Proto.Global.UMoney.create({ | ||
amount: bigNumberToDecimal_1.bigNumberToUDecimal(amount), | ||
currencyCode: currency ? | ||
coingaming_protobuf_1.Proto.Global.CurrencyCodeValue.create({ value: coingaming_protobuf_1.Proto.Global.CurrencyCode[currency] }) : null, | ||
export const toUMoney = (amount, currency) => { | ||
return new ProtoUMoney({ | ||
amount: bigNumberToUDecimal(amount), | ||
currencyCode: currency ? CurrencyCode[currency] : null, | ||
}); | ||
}; | ||
//# sourceMappingURL=moneyHelper.js.map |
@@ -1,3 +0,3 @@ | ||
import { Proto } from '@heathmont/coingaming-protobuf'; | ||
import { CallReactionFunction, LabConfig } from './index'; | ||
export declare const sendHealthCheck: (labConfig: LabConfig, status: Proto.Substance.Lab.Reaction.Heartbeat.Request.Status, callReaction: CallReactionFunction) => Promise<void>; | ||
import { Request_Status } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/substance/lab/reaction/heartbeat_pb.js'; | ||
export declare const sendHealthCheck: (labConfig: LabConfig, status: Request_Status, callReaction: CallReactionFunction) => Promise<void>; |
@@ -1,74 +0,25 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
import { logger } from '@heathmont/node-logger'; | ||
import { Request, Response } from '@heathmont/coingaming-protobuf/dist/lab_protobuf/substance/lab/reaction/heartbeat_pb.js'; | ||
export const sendHealthCheck = async (labConfig, status, callReaction) => { | ||
const heartbeatRequest = new Request({ | ||
status, | ||
flaskInstanceUuid: Buffer.from(labConfig.defaultContext.instanceUuid), | ||
flaskApi: { case: 'url', value: labConfig.instanceUrl }, | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) 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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
try { | ||
const response = await callReaction('LAB', 'HEARTBEAT', heartbeatRequest, Response); | ||
if (response) { | ||
logger.error('Error on heartbeat', { proto: response }); | ||
throw new Error('Error on heartbeat.'); | ||
} | ||
else { | ||
logger.debug('Healthcheck successful.', { response }); | ||
} | ||
} | ||
catch (e) { | ||
const { message, stack } = e; | ||
logger.error('Error sending heartbeat to LAB', { message, stack }); | ||
throw e; | ||
} | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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 heartbeatRequest, response, e_1, message, stack; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
heartbeatRequest = coingaming_protobuf_1.Proto.Substance.Lab.Reaction.Heartbeat.Request.create({ | ||
status: status, | ||
flaskInstanceUuid: Buffer.from(labConfig.defaultContext.instanceUuid), | ||
url: labConfig.instanceUrl, | ||
}); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, callReaction('LAB', 'HEARTBEAT', heartbeatRequest, coingaming_protobuf_1.Proto.Substance.Lab.Reaction.Heartbeat.Response)]; | ||
case 2: | ||
response = _a.sent(); | ||
if (response.error) { | ||
node_logger_1.logger.error('Error on heartbeat', { proto: response.toJSON() }); | ||
throw new Error('Error on heartbeat.'); | ||
} | ||
else { | ||
node_logger_1.logger.debug('Healthcheck successful.', { response: response }); | ||
} | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
message = e_1.message, stack = e_1.stack; | ||
node_logger_1.logger.error('Error sending heartbeat to LAB', { message: message, stack: stack }); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
//# sourceMappingURL=sendHealthCheck.js.map |
@@ -0,3 +1,3 @@ | ||
import { Message } from "@bufbuild/protobuf"; | ||
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>>; | ||
export declare const sendRequest: <REQ extends Message<REQ>, RESP extends Message<Message<import("@bufbuild/protobuf").AnyMessage>>>(labConfig: LabConfig, substanceEnum: string, actKindEnum: string, actEnum: string, payload: REQ, responseClass: RESP, context: any) => Promise<RESP>; |
@@ -1,113 +0,55 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
import { logger } from '@heathmont/node-logger'; | ||
import axios from 'axios'; | ||
import http from 'http'; | ||
import https from 'https'; | ||
import { createLabUrl } from './createUrls'; | ||
import promiseRetry from 'promise-retry'; | ||
const retryQuery = (async (query) => { | ||
return promiseRetry({ minTimeout: 50 }, async (retry, ignored) => { | ||
try { | ||
return await query; | ||
} | ||
catch (error) { | ||
if (error.code && error.code >= 500) { | ||
return retry(error); | ||
} | ||
throw error; | ||
} | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) 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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
}); | ||
export const sendRequest = async (labConfig, substanceEnum, actKindEnum, actEnum, payload, responseClass, context) => { | ||
const labContext = Object.assign({}, labConfig.defaultContext, context); | ||
const url = createLabUrl(labConfig, labContext, substanceEnum, actKindEnum, actEnum); | ||
const data = payload.toBinary(); | ||
const headers = { | ||
'content-type': 'application/x-protobuf', | ||
'x-lab-signature': labConfig.hmCrypto.sign(data), | ||
}; | ||
try { | ||
logger.debug('Sending request to lab', { | ||
url, | ||
headers, | ||
payload: JSON.stringify(payload), | ||
}); | ||
const axiosResponse = await retryQuery(axios({ | ||
url, | ||
headers, | ||
data, | ||
httpAgent: new http.Agent({ keepAlive: true }), | ||
httpsAgent: new https.Agent({ keepAlive: true }), | ||
method: 'post', | ||
responseType: 'arraybuffer', | ||
})); | ||
const responeDecoded = responseClass.fromBinary(axiosResponse.data); | ||
logger.debug('Got response from lab', { | ||
respone: JSON.stringify(responeDecoded), | ||
}); | ||
return responeDecoded; | ||
} | ||
catch (err) { | ||
const responseData = err.response && err.response.data ? err.response.data.toString() : undefined; | ||
logger.error('Error calling lab', { errMessage: err.message, errStack: err.stack, responseData }); | ||
throw err; | ||
} | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var node_logger_1 = require("@heathmont/node-logger"); | ||
var axios_1 = require("axios"); | ||
var http = require("http"); | ||
var https = require("https"); | ||
var createUrls_1 = require("./createUrls"); | ||
var promiseRetry = require("promise-retry"); | ||
var retryQuery = (function (query) { return __awaiter(_this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, promiseRetry({ minTimeout: 50 }, function (retry, ignored) { return __awaiter(_this, void 0, void 0, function () { | ||
var error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, query]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
error_1 = _a.sent(); | ||
if (error_1.code && error_1.code >= 500) { | ||
return [2 /*return*/, retry(error_1)]; | ||
} | ||
throw error_1; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); })]; | ||
}); | ||
}); }); | ||
exports.sendRequest = function (labConfig, substanceEnum, actKindEnum, actEnum, payload, responseClass, context) { return __awaiter(_this, void 0, void 0, function () { | ||
var labContext, url, data, headers, axiosResponse, responeDecoded, err_1, responseData; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
labContext = Object.assign({}, labConfig.defaultContext, context); | ||
url = createUrls_1.createLabUrl(labConfig, labContext, substanceEnum, actKindEnum, actEnum); | ||
data = payload.constructor.encode(payload).finish(); | ||
headers = { | ||
'content-type': 'application/x-protobuf', | ||
'x-lab-signature': labConfig.hmCrypto.sign(data), | ||
}; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
node_logger_1.logger.debug('Sending request to lab', { | ||
url: url, | ||
headers: headers, | ||
payload: JSON.stringify(payload), | ||
}); | ||
return [4 /*yield*/, retryQuery(axios_1.default({ | ||
url: url, | ||
headers: headers, | ||
data: data, | ||
httpAgent: new http.Agent({ keepAlive: true }), | ||
httpsAgent: new https.Agent({ keepAlive: true }), | ||
method: 'post', | ||
responseType: 'arraybuffer', | ||
}))]; | ||
case 2: | ||
axiosResponse = _a.sent(); | ||
responeDecoded = responseClass.decode(axiosResponse.data); | ||
node_logger_1.logger.debug('Got response from lab', { | ||
respone: JSON.stringify(responeDecoded), | ||
}); | ||
return [2 /*return*/, responeDecoded]; | ||
case 3: | ||
err_1 = _a.sent(); | ||
responseData = err_1.response && err_1.response.data ? err_1.response.data.toString() : undefined; | ||
node_logger_1.logger.error('Error calling lab', { errMessage: err_1.message, errStack: err_1.stack, responseData: responseData }); | ||
throw err_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
//# sourceMappingURL=sendRequest.js.map |
@@ -1,20 +0,4 @@ | ||
import { Message } from 'protobufjs'; | ||
export declare 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> & { | ||
toJSON: () => { | ||
[k: string]: any; | ||
}; | ||
}; | ||
export declare type ProtobufMessage<T extends object> = PartialBy<ProtobufMessageWithToJSON<T>, '$type'>; | ||
export declare type ProtobufResponse<T> = T & { | ||
toJSON: () => { | ||
[k: string]: unknown; | ||
}; | ||
}; | ||
export declare type ClassInstance<T> = { | ||
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export type ClassInstance<T> = { | ||
new (a: unknown): T; | ||
}; |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import { Message } from 'protobufjs'; | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@heathmont/lab-flask", | ||
"version": "1.24.0", | ||
"version": "2.0.0", | ||
"author": "Margus Lamp", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"engines": { | ||
@@ -11,35 +12,43 @@ "node": ">=8" | ||
"dependencies": { | ||
"@heathmont/coingaming-protobuf": "0.99.0", | ||
"@heathmont/node-logger": "^1.0.23", | ||
"@bufbuild/protobuf": "^1.7.2", | ||
"@heathmont/coingaming-protobuf": "1.0.0-alpha.10", | ||
"@heathmont/node-logger": "^0.1.12", | ||
"@types/body-parser": "1.17.0", | ||
"axios": "0.19.0", | ||
"@types/source-map-support": "^0.5.10", | ||
"axios": "~1.6", | ||
"bignumber.js": "8.1.1", | ||
"body-parser": "1.19.0", | ||
"body-parser": "^1.20.2", | ||
"hm-crypto-nodejs": "1.0.3", | ||
"node-forge": "0.8.3", | ||
"node-forge": "^1.3.1", | ||
"promise-retry": "1.1.1", | ||
"protobufjs": "6.8.6", | ||
"source-map-support": "0.5.10", | ||
"uuid": "3.3.2" | ||
"uuid": "~9.0", | ||
"validate-commit-msg": "^2.14.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.24.0", | ||
"@babel/preset-typescript": "^7.23.3", | ||
"@eslint/js": "^9.0.0", | ||
"@types/express": "4.0.30", | ||
"@types/jest": "23.3.2", | ||
"@types/node": "10.11.2", | ||
"@types/jest": "~29", | ||
"@types/node": "~20", | ||
"@types/node-forge": "0.8.3", | ||
"babel-jest": "^24.5.0", | ||
"babel-jest": "~29.0", | ||
"eslint": "^8.57.0", | ||
"globals": "^15.0.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" | ||
"jest": "^29.7", | ||
"long": "5.2.3", | ||
"semantic-release": "^23.0.2", | ||
"ts-jest": "~29.1", | ||
"typescript": "~5.2", | ||
"typescript-eslint": "^7.7.0" | ||
}, | ||
"peerDependencies": { | ||
"express": "~4.0", | ||
"express": "~4.18", | ||
"long": "4.0.0" | ||
}, | ||
"files": [ | ||
"./dist" | ||
], | ||
"directories": { | ||
@@ -52,3 +61,3 @@ "lib": "./dist" | ||
"compile:watch": "tsc -p ./ --watch", | ||
"lint": "tslint -p ./ \"src/**/*.ts\"", | ||
"lint": "eslint ./src", | ||
"test": "jest", | ||
@@ -59,22 +68,2 @@ "test:watch": "jest --watch", | ||
}, | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "ts-jest" | ||
}, | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$", | ||
"testEnvironment": "node", | ||
"roots": [ | ||
"<rootDir>/src/" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/src/tests/setup.ts" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsm", | ||
"mjs" | ||
] | ||
}, | ||
"validate-commit-msg": { | ||
@@ -98,3 +87,9 @@ "types": [ | ||
} | ||
}, | ||
"release": { | ||
"branches": [ | ||
"master", | ||
"alpha" | ||
] | ||
} | ||
} |
This repo is for lab-flask library for node | ||
To create a new version.- | ||
```bash | ||
$ npm run compile | ||
``` | ||
How to use is in test files. | ||
``` | ||
npm run test | ||
$ npm run test | ||
``` |
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
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
14
Yes
55498
16
17
47
705
3
+ Added@bufbuild/protobuf@^1.7.2
+ Addedvalidate-commit-msg@^2.14.0
+ Added@bufbuild/protobuf@1.10.0(transitive)
+ Added@types/source-map-support@0.5.10(transitive)
+ Addedaccepts@1.3.8(transitive)
+ Addedarray-flatten@1.1.1(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.6.8(transitive)
+ Addedbody-parser@1.20.21.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedcolors@0.6.2(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcommander@2.1.0(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedconventional-commit-types@2.3.0(transitive)
+ Addedcookie@0.5.0(transitive)
+ Addedcookie-signature@1.0.6(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedencodeurl@1.0.2(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedes-set-tostringtag@2.1.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@4.18.3(transitive)
+ Addedfinalhandler@1.2.0(transitive)
+ Addedfind-parent-dir@0.3.1(transitive)
+ Addedfindup@0.1.5(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.2(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmerge-descriptors@1.0.1(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addednode-forge@1.3.1(transitive)
+ Addedobject-inspect@1.13.4(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@0.1.7(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedqs@6.11.06.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver-regex@1.0.0(transitive)
+ Addedsend@0.18.0(transitive)
+ Addedserve-static@1.15.0(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addeduuid@9.0.1(transitive)
+ Addedvalidate-commit-msg@2.14.0(transitive)
+ Addedvary@1.1.2(transitive)
- Removedprotobufjs@6.8.6
- Removed@protobufjs/aspromise@1.1.2(transitive)
- Removed@protobufjs/base64@1.1.2(transitive)
- Removed@protobufjs/codegen@2.0.4(transitive)
- Removed@protobufjs/eventemitter@1.1.0(transitive)
- Removed@protobufjs/fetch@1.1.0(transitive)
- Removed@protobufjs/float@1.0.2(transitive)
- Removed@protobufjs/inquire@1.1.0(transitive)
- Removed@protobufjs/path@1.1.2(transitive)
- Removed@protobufjs/pool@1.1.0(transitive)
- Removed@protobufjs/utf8@1.1.0(transitive)
- Removed@types/long@3.0.32(transitive)
- Removed@types/node@8.10.66(transitive)
- Removedaccepts@1.0.0(transitive)
- Removedaxios@0.19.0(transitive)
- Removedbody-parser@1.19.0(transitive)
- Removedbuffer-crc32@0.2.1(transitive)
- Removedbytes@3.1.0(transitive)
- Removedcookie@0.1.0(transitive)
- Removedcookie-signature@1.0.3(transitive)
- Removeddebug@0.8.1(transitive)
- Removeddepd@1.1.2(transitive)
- Removedescape-html@1.0.1(transitive)
- Removedexpress@4.0.0(transitive)
- Removedfollow-redirects@1.5.10(transitive)
- Removedfresh@0.2.00.2.2(transitive)
- Removedhttp-errors@1.7.2(transitive)
- Removedinherits@2.0.3(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedmerge-descriptors@0.0.2(transitive)
- Removedmethods@0.1.0(transitive)
- Removedmime@1.2.11(transitive)
- Removednegotiator@0.3.0(transitive)
- Removednode-forge@0.8.3(transitive)
- Removedon-finished@2.3.0(transitive)
- Removedparseurl@1.0.1(transitive)
- Removedpath-to-regexp@0.1.2(transitive)
- Removedprotobufjs@6.8.6(transitive)
- Removedqs@0.6.66.7.0(transitive)
- Removedrange-parser@0.0.41.0.0(transitive)
- Removedraw-body@2.4.0(transitive)
- Removedsend@0.1.40.2.0(transitive)
- Removedserve-static@1.0.1(transitive)
- Removedsetprototypeof@1.1.1(transitive)
- Removedstatuses@1.5.0(transitive)
- Removedtoidentifier@1.0.0(transitive)
- Removedtype-is@1.0.0(transitive)
- Removedutils-merge@1.0.0(transitive)
- Removeduuid@3.3.2(transitive)
Updatedaxios@~1.6
Updatedbody-parser@^1.20.2
Updatednode-forge@^1.3.1
Updateduuid@~9.0