UNPKG

@configurator/ravendb

Version:
62 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetCertificateMetadataOperation = void 0; const Exceptions_1 = require("../../../Exceptions"); const RavenCommand_1 = require("../../../Http/RavenCommand"); class GetCertificateMetadataOperation { constructor(thumbprint) { if (!thumbprint) { (0, Exceptions_1.throwError)("InvalidArgumentException", "Thumbprint cannot be null"); } this._thumbprint = thumbprint; } get resultType() { return "CommandResult"; } getCommand(conventions) { return new GetCertificateMetadataCommand(conventions, this._thumbprint); } } exports.GetCertificateMetadataOperation = GetCertificateMetadataOperation; class GetCertificateMetadataCommand extends RavenCommand_1.RavenCommand { constructor(conventions, thumbprint) { super(); this._conventions = conventions; this._thumbprint = thumbprint; } get isReadRequest() { return true; } createRequest(node) { const uri = node.url + "/admin/certificates?thumbprint=" + encodeURIComponent(this._thumbprint) + "&metadataOnly=true"; return { method: "GET", uri }; } async setResponseAsync(bodyStream, fromCache) { if (!bodyStream) { return; } let body = null; const response = await this._defaultPipeline(_ => body = _).process(bodyStream); const dateUtil = this._conventions.dateUtil; const resultsMapped = response.results.map(cert => { const { notAfter, notBefore } = cert; return { ...cert, notAfter: dateUtil.parse(notAfter), notBefore: dateUtil.parse(notBefore) }; }); if (resultsMapped.length !== 1) { this._throwInvalidResponse(); } this.result = resultsMapped[0]; return body; } } //# sourceMappingURL=GetCertificateMetadataOperation.js.map