ravendb
Version:
RavenDB client for Node.js
58 lines • 1.81 kB
JavaScript
import { throwError } from "../../../Exceptions/index.js";
import { RavenCommand } from "../../../Http/RavenCommand.js";
export class GetCertificateOperation {
_thumbprint;
constructor(thumbprint) {
if (!thumbprint) {
throwError("InvalidArgumentException", "Thumbprint cannot be null.");
}
this._thumbprint = thumbprint;
}
get resultType() {
return "CommandResult";
}
getCommand(conventions) {
return new GetCertificateCommand(this._thumbprint, conventions);
}
}
class GetCertificateCommand extends RavenCommand {
_thumbprint;
_conventions;
constructor(thumbprint, conventions) {
super();
if (!thumbprint) {
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