ravendb
Version:
RavenDB client for Node.js
65 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetCertificateMetadataOperation = void 0;
const index_js_1 = require("../../../Exceptions/index.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
const DateUtil_js_1 = require("../../../Utility/DateUtil.js");
class GetCertificateMetadataOperation {
_thumbprint;
constructor(thumbprint) {
if (!thumbprint) {
(0, index_js_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_js_1.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_js_1.DateUtil.utc.parse(notAfter),
notBefore: DateUtil_js_1.DateUtil.utc.parse(notBefore)
};
});
if (resultsMapped.length !== 1) {
this._throwInvalidResponse();
}
this.result = resultsMapped[0];
return body;
}
}
//# sourceMappingURL=GetCertificateMetadataOperation.js.map