mysterium-vpn-js
Version:
Javascript SDK for Mysterium node
47 lines (46 loc) • 2.05 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.parseIdentity = exports.IdentityRegistrationStatus = exports.parseIdentityList = exports.parseIdentityRef = void 0;
const validation_1 = require("../fmt/validation");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseIdentityRef(data) {
(0, validation_1.validate)('IdentityRef', data, { name: 'id', type: 'string' });
return data;
}
exports.parseIdentityRef = parseIdentityRef;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseIdentityList(responseData) {
if (!(responseData && Array.isArray(responseData.identities))) {
return { identities: [] };
}
return { identities: responseData.identities.map(parseIdentityRef) };
}
exports.parseIdentityList = parseIdentityList;
var IdentityRegistrationStatus;
(function (IdentityRegistrationStatus) {
IdentityRegistrationStatus["Unknown"] = "Unknown";
IdentityRegistrationStatus["Unregistered"] = "Unregistered";
IdentityRegistrationStatus["InProgress"] = "InProgress";
IdentityRegistrationStatus["Registered"] = "Registered";
IdentityRegistrationStatus["RegistrationError"] = "RegistrationError";
})(IdentityRegistrationStatus = exports.IdentityRegistrationStatus || (exports.IdentityRegistrationStatus = {}));
function parseIdentity(data) {
(0, validation_1.validateMultiple)('Identity', data, [
{ name: 'id', type: 'string' },
{ name: 'registrationStatus', type: 'string' },
{ name: 'channelAddress', type: 'string' },
{ name: 'balance', type: 'number' },
{ name: 'balanceTokens', type: 'object' },
{ name: 'earnings', type: 'number' },
{ name: 'earningsTotal', type: 'number' },
{ name: 'stake', type: 'number' },
]);
return data;
}
exports.parseIdentity = parseIdentity;