Socket
Socket
Sign inDemoInstall

@clickhouse/client

Package Overview
Dependencies
Maintainers
4
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickhouse/client - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

9

dist/connection/node_base_connection.d.ts
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type { ConnBaseQueryParams, ConnCommandResult, Connection, ConnectionParams, ConnExecResult, ConnInsertParams, ConnInsertResult, ConnPingResult, ConnQueryResult } from '@clickhouse/client-common';
import type { BaseQueryParams, ConnBaseQueryParams, ConnCommandResult, Connection, ConnectionParams, ConnExecResult, ConnInsertParams, ConnInsertResult, ConnPingResult, ConnQueryResult } from '@clickhouse/client-common';
import type Http from 'http';

@@ -26,2 +26,3 @@ import Stream from 'stream';

url: URL;
headers: Http.OutgoingHttpHeaders;
body?: string | Stream.Readable;

@@ -36,3 +37,5 @@ abort_signal: AbortSignal;

protected readonly agent: Http.Agent;
protected readonly headers: Http.OutgoingHttpHeaders;
protected readonly defaultAuthHeader: string;
protected readonly defaultHeaders: Http.OutgoingHttpHeaders;
protected readonly additionalHTTPHeaders: Record<string, string>;
private readonly logger;

@@ -48,3 +51,3 @@ private readonly knownSockets;

close(): Promise<void>;
protected buildDefaultHeaders(username: string, password: string, additional_http_headers?: Record<string, string>): Http.OutgoingHttpHeaders;
protected buildRequestHeaders(params?: BaseQueryParams): Http.OutgoingHttpHeaders;
protected abstract createClientRequest(params: RequestParams): Http.ClientRequest;

@@ -51,0 +54,0 @@ private getQueryId;

@@ -28,3 +28,3 @@ "use strict";

});
Object.defineProperty(this, "headers", {
Object.defineProperty(this, "defaultAuthHeader", {
enumerable: true,

@@ -35,2 +35,14 @@ configurable: true,

});
Object.defineProperty(this, "defaultHeaders", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "additionalHTTPHeaders", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "logger", {

@@ -54,5 +66,12 @@ enumerable: true,

});
this.additionalHTTPHeaders = params.http_headers ?? {};
this.defaultAuthHeader = `Basic ${Buffer.from(`${params.username}:${params.password}`).toString('base64')}`;
this.defaultHeaders = {
...this.additionalHTTPHeaders,
// KeepAlive agent for some reason does not set this on its own
Connection: this.params.keep_alive.enabled ? 'keep-alive' : 'close',
'User-Agent': (0, utils_1.getUserAgent)(this.params.application_id),
};
this.logger = params.log_writer;
this.idleSocketTTL = params.keep_alive.idle_socket_ttl;
this.headers = this.buildDefaultHeaders(params.username, params.password, params.http_headers);
}

@@ -66,2 +85,3 @@ async ping() {

abort_signal: abortController.signal,
headers: this.buildRequestHeaders(),
}, 'Ping');

@@ -105,2 +125,3 @@ await (0, stream_2.drainStream)(stream);

decompress_response: decompressResponse,
headers: this.buildRequestHeaders(params),
}, 'Query');

@@ -150,2 +171,3 @@ return {

parse_summary: true,
headers: this.buildRequestHeaders(params),
}, 'Insert');

@@ -193,9 +215,8 @@ await (0, stream_2.drainStream)(stream);

}
buildDefaultHeaders(username, password, additional_http_headers) {
buildRequestHeaders(params) {
return {
// KeepAlive agent for some reason does not set this on its own
Connection: this.params.keep_alive.enabled ? 'keep-alive' : 'close',
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
'User-Agent': (0, utils_1.getUserAgent)(this.params.application_id),
...additional_http_headers,
...this.defaultHeaders,
Authorization: params?.auth !== undefined
? `Basic ${Buffer.from(`${params.auth.username}:${params.auth.password}`).toString('base64')}`
: this.defaultAuthHeader,
};

@@ -289,2 +310,3 @@ }

parse_summary: true,
headers: this.buildRequestHeaders(params),
}, params.op);

@@ -291,0 +313,0 @@ return {

@@ -19,2 +19,7 @@ "use strict";

createClientRequest(params) {
const headers = (0, client_common_1.withCompressionHeaders)({
headers: params.headers,
compress_request: params.compress_request,
decompress_response: params.decompress_response,
});
return http_1.default.request(params.url, {

@@ -24,8 +29,4 @@ method: params.method,

timeout: this.params.request_timeout,
headers: (0, client_common_1.withCompressionHeaders)({
headers: this.headers,
compress_request: params.compress_request,
decompress_response: params.decompress_response,
}),
signal: params.abort_signal,
headers,
});

@@ -32,0 +33,0 @@ }

/// <reference types="node" />
import type { BaseQueryParams } from '@clickhouse/client-common';
import type Http from 'http';

@@ -7,4 +8,4 @@ import type { NodeConnectionParams, RequestParams } from './node_base_connection';

constructor(params: NodeConnectionParams);
protected buildDefaultHeaders(username: string, password: string, additional_headers?: Record<string, string>): Http.OutgoingHttpHeaders;
protected buildRequestHeaders(params?: BaseQueryParams): Http.OutgoingHttpHeaders;
protected createClientRequest(params: RequestParams): Http.ClientRequest;
}

@@ -21,19 +21,30 @@ "use strict";

}
buildDefaultHeaders(username, password, additional_headers) {
if (this.params.tls?.type === 'Mutual') {
return {
'X-ClickHouse-User': username,
'X-ClickHouse-Key': password,
'X-ClickHouse-SSL-Certificate-Auth': 'on',
buildRequestHeaders(params) {
if (this.params.tls !== undefined) {
const headers = {
...this.defaultHeaders,
'X-ClickHouse-User': params?.auth?.username ?? this.params.username,
'X-ClickHouse-Key': params?.auth?.password ?? this.params.password,
};
const tlsType = this.params.tls.type;
switch (tlsType) {
case 'Basic':
return headers;
case 'Mutual':
return {
...headers,
'X-ClickHouse-SSL-Certificate-Auth': 'on',
};
default:
throw new Error(`Unknown TLS type: ${tlsType}`);
}
}
if (this.params.tls?.type === 'Basic') {
return {
'X-ClickHouse-User': username,
'X-ClickHouse-Key': password,
};
}
return super.buildDefaultHeaders(username, password, additional_headers);
return super.buildRequestHeaders(params);
}
createClientRequest(params) {
const headers = (0, client_common_1.withCompressionHeaders)({
headers: params.headers,
compress_request: params.compress_request,
decompress_response: params.decompress_response,
});
return https_1.default.request(params.url, {

@@ -43,8 +54,4 @@ method: params.method,

timeout: this.params.request_timeout,
headers: (0, client_common_1.withCompressionHeaders)({
headers: this.headers,
compress_request: params.compress_request,
decompress_response: params.decompress_response,
}),
signal: params.abort_signal,
headers,
});

@@ -51,0 +58,0 @@ }

@@ -1,2 +0,2 @@

declare const _default: "1.0.2";
declare const _default: "1.1.0";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '1.0.2';
exports.default = '1.1.0';
//# sourceMappingURL=version.js.map

@@ -5,3 +5,3 @@ {

"homepage": "https://clickhouse.com",
"version": "1.0.2",
"version": "1.1.0",
"license": "Apache-2.0",

@@ -27,4 +27,4 @@ "keywords": [

"dependencies": {
"@clickhouse/client-common": "1.0.2"
"@clickhouse/client-common": "1.1.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc