UNPKG

ravendb

Version:
61 lines 1.92 kB
import { throwError } from "../../../Exceptions/index.js"; import { RavenCommand } from "../../../Http/RavenCommand.js"; import { DateUtil } from "../../../Utility/DateUtil.js"; export class GetCertificateMetadataOperation { _thumbprint; constructor(thumbprint) { if (!thumbprint) { throwError("InvalidArgumentException", "Thumbprint cannot be null"); } this._thumbprint = thumbprint; } get resultType() { return "CommandResult"; } getCommand(conventions) { return new GetCertificateMetadataCommand(conventions, this._thumbprint); } } class GetCertificateMetadataCommand extends RavenCommand { _conventions; _thumbprint; 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 resultsMapped = response.results.map(cert => { const { notAfter, notBefore } = cert; return { ...cert, notAfter: DateUtil.utc.parse(notAfter), notBefore: DateUtil.utc.parse(notBefore) }; }); if (resultsMapped.length !== 1) { this._throwInvalidResponse(); } this.result = resultsMapped[0]; return body; } } //# sourceMappingURL=GetCertificateMetadataOperation.js.map