mysterium-vpn-js
Version:
Javascript SDK for Mysterium node
31 lines (30 loc) • 1.28 kB
JavaScript
;
/**
* Copyright (c) 2020 BlockDev AG
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseServiceListResponse = exports.parseServiceInfo = void 0;
const validation_1 = require("../fmt/validation");
const proposal_1 = require("../proposal/proposal");
function parseServiceInfo(data) {
// TODO: validate that status has value from ServiceStatus enum
(0, validation_1.validateMultiple)('ServiceInfo', data, [
{ name: 'id', type: 'string', optional: true },
{ name: 'providerId', type: 'string', optional: true },
{ name: 'type', type: 'string' },
{ name: 'options', type: 'object', optional: true },
{ name: 'status', type: 'string' },
{ name: 'proposal', type: 'object', optional: true },
]);
data.proposal && (0, proposal_1.parseProposal)(data.proposal);
return data;
}
exports.parseServiceInfo = parseServiceInfo;
function parseServiceListResponse(responseData) {
(0, validation_1.validateArray)('ServiceInfo[]', responseData);
return responseData.map(parseServiceInfo);
}
exports.parseServiceListResponse = parseServiceListResponse;