ravendb
Version:
RavenDB client for Node.js
62 lines • 2.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetCertificateOperation = void 0;
const index_js_1 = require("../../../Exceptions/index.js");
const RavenCommand_js_1 = require("../../../Http/RavenCommand.js");
class GetCertificateOperation {
_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 GetCertificateCommand(this._thumbprint, conventions);
}
}
exports.GetCertificateOperation = GetCertificateOperation;
class GetCertificateCommand extends RavenCommand_js_1.RavenCommand {
_thumbprint;
_conventions;
constructor(thumbprint, conventions) {
super();
if (!thumbprint) {
(0, index_js_1.throwError)("InvalidArgumentException", "Thumbprint cannot be null.");
}
this._thumbprint = thumbprint;
this._conventions = conventions;
}
get isReadRequest() {
return false;
}
createRequest(node) {
const uri = node.url + "/admin/certificates?thumbprint=" + encodeURIComponent(this._thumbprint);
return {
method: "GET",
uri
};
}
async setResponseAsync(bodyStream, fromCache) {
if (!bodyStream) {
return;
}
let body = null;
const results = await this._defaultPipeline(_ => body = _).process(bodyStream);
const mapped = this._conventions.objectMapper.fromObjectLiteral(results, {
nestedTypes: {
"results[].notAfter": "date",
"results[].notBefore": "date"
}
}).results;
if (mapped.length !== 1) {
this._throwInvalidResponse();
}
this.result = mapped[0];
return body;
}
}
//# sourceMappingURL=GetCertificateOperation.js.map