@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
60 lines • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChallengeResponse = void 0;
/**
*
*
* @class ChallengeResponse
*/
var ChallengeResponse = /** @class */ (function () {
/**
* Challenge Response.
* @constructor
* @param {string} response - response json.
*/
function ChallengeResponse(response) {
this.response = response;
if (!this.isValid()) {
throw new TypeError("Invalid ChallengeResponse properties.");
}
}
/**
*
* Creates a RelayMeta object using a JSON string
* @param {string} json - JSON string.
* @returns {ChallengeResponse} - ChallengeResponse object.
* @memberof ChallengeResponse
*/
ChallengeResponse.fromJSON = function (json) {
try {
var jsonObject = JSON.parse(json);
return new ChallengeResponse(jsonObject.response);
}
catch (error) {
throw error;
}
};
/**
*
* Creates a JSON object with the ChallengeResponse properties
* @returns {JSON} - JSON Object.
* @memberof ChallengeResponse
*/
ChallengeResponse.prototype.toJSON = function () {
return {
response: this.response
};
};
/**
*
* Check if the ChallengeResponse object is valid
* @returns {boolean} - True or false.
* @memberof ChallengeResponse
*/
ChallengeResponse.prototype.isValid = function () {
return (this.response.length > 0);
};
return ChallengeResponse;
}());
exports.ChallengeResponse = ChallengeResponse;
//# sourceMappingURL=challenge-response.js.map