Socket
Socket
Sign inDemoInstall

@clickhouse/client

Package Overview
Dependencies
Maintainers
3
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 0.0.7 to 0.0.8

14

dist/client.d.ts
/// <reference types="node" />
/// <reference types="node" />
import Stream from 'stream';

@@ -31,6 +32,6 @@ import { Logger } from './logger';

database?: string;
/** ClickHouse settings to apply to all requests. Default value: {} */
/** ClickHouse settings to apply to all requests. Default value: {} */
clickhouse_settings?: ClickHouseSettings;
log?: {
/** Enable logging. Default value: false. */
/** Enable logging. Default value: false. */
enable?: boolean;

@@ -40,3 +41,12 @@ /** A class to instantiate a custom logger implementation. */

};
tls?: BasicTLSOptions | MutualTLSOptions;
}
interface BasicTLSOptions {
ca_cert: Buffer;
}
interface MutualTLSOptions {
ca_cert: Buffer;
cert: Buffer;
key: Buffer;
}
export interface BaseParams {

@@ -43,0 +53,0 @@ /** ClickHouse settings that can be applied on query level. */

@@ -29,2 +29,17 @@ "use strict";

var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
let tls = undefined;
if (config.tls) {
if ('cert' in config.tls && 'key' in config.tls) {
tls = {
type: 'Mutual',
...config.tls,
};
}
else {
tls = {
type: 'Basic',
...config.tls,
};
}
}
return {

@@ -35,3 +50,3 @@ url: createUrl((_a = config.host) !== null && _a !== void 0 ? _a : 'http://localhost:8123'),

max_open_connections: (_d = config.max_open_connections) !== null && _d !== void 0 ? _d : Infinity,
// tls: _config.tls,
tls,
compression: {

@@ -38,0 +53,0 @@ decompress_response: (_f = (_e = config.compression) === null || _e === void 0 ? void 0 : _e.response) !== null && _f !== void 0 ? _f : true,

3

dist/connection/adapter/base_http_adapter.d.ts

@@ -16,3 +16,3 @@ /// <reference types="node" />

export declare abstract class BaseHttpAdapter implements Connection {
private readonly config;
protected readonly config: ConnectionParams;
private readonly logger;

@@ -22,2 +22,3 @@ protected readonly agent: Http.Agent;

protected constructor(config: ConnectionParams, logger: Logger, agent: Http.Agent);
protected buildDefaultHeaders(username: string, password: string): Http.OutgoingHttpHeaders;
protected abstract createClientRequest(url: URL, params: RequestParams): Http.ClientRequest;

@@ -24,0 +25,0 @@ protected request(params: RequestParams): Promise<Stream.Readable>;

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

}
function buildDefaultHeaders(username, password) {
return {
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
};
}
function decompressResponse(response) {

@@ -82,4 +77,9 @@ const encoding = response.headers['content-encoding'];

});
this.headers = buildDefaultHeaders(config.username, config.password);
this.headers = this.buildDefaultHeaders(config.username, config.password);
}
buildDefaultHeaders(username, password) {
return {
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
};
}
async request(params) {

@@ -86,0 +86,0 @@ return new Promise((resolve, reject) => {

@@ -9,3 +9,4 @@ /// <reference types="node" />

constructor(config: ConnectionParams, logger: Logger);
protected buildDefaultHeaders(username: string, password: string): Http.OutgoingHttpHeaders;
protected createClientRequest(url: URL, params: RequestParams): Http.ClientRequest;
}

@@ -11,2 +11,3 @@ "use strict";

constructor(config, logger) {
var _a, _b, _c;
const agent = new https_1.default.Agent({

@@ -16,5 +17,25 @@ keepAlive: true,

maxSockets: config.max_open_connections,
ca: (_a = config.tls) === null || _a === void 0 ? void 0 : _a.ca_cert,
key: ((_b = config.tls) === null || _b === void 0 ? void 0 : _b.type) === 'Mutual' ? config.tls.key : undefined,
cert: ((_c = config.tls) === null || _c === void 0 ? void 0 : _c.type) === 'Mutual' ? config.tls.cert : undefined,
});
super(config, logger, agent);
}
buildDefaultHeaders(username, password) {
var _a, _b;
if (((_a = this.config.tls) === null || _a === void 0 ? void 0 : _a.type) === 'Mutual') {
return {
'X-ClickHouse-User': username,
'X-ClickHouse-Key': password,
'X-ClickHouse-SSL-Certificate-Auth': 'on',
};
}
if (((_b = this.config.tls) === null || _b === void 0 ? void 0 : _b.type) === 'Basic') {
return {
'X-ClickHouse-User': username,
'X-ClickHouse-Key': password,
};
}
return super.buildDefaultHeaders(username, password);
}
createClientRequest(url, params) {

@@ -21,0 +42,0 @@ return https_1.default.request(params.url, {

/// <reference types="node" />
/// <reference types="node" />
import type Stream from 'stream';

@@ -14,2 +15,3 @@ import type { Logger } from '../logger';

};
tls?: TLSParams;
username: string;

@@ -19,2 +21,11 @@ password: string;

}
export declare type TLSParams = {
ca_cert: Buffer;
type: 'Basic';
} | {
ca_cert: Buffer;
cert: Buffer;
key: Buffer;
type: 'Mutual';
};
export interface BaseParams {

@@ -21,0 +32,0 @@ query: string;

{
"name": "@clickhouse/client",
"version": "0.0.7",
"version": "0.0.8",
"description": "Official JS client for ClickHouse DB",

@@ -27,2 +27,3 @@ "license": "Apache-2.0",

"test": "jest --reporters jest-silent-reporter --testPathPattern=__tests__ --globalSetup='<rootDir>/__tests__/setup.integration.ts'",
"test:tls": "jest --testMatch='**/__tests__/tls/*.test.ts'",
"test:unit": "jest --reporters jest-silent-reporter --testMatch='**/__tests__/{unit,utils}/*.test.ts'",

@@ -29,0 +30,0 @@ "test:integration": "jest --reporters jest-silent-reporter --runInBand --testPathPattern=__tests__/integration --globalSetup='<rootDir>/__tests__/setup.integration.ts'",

@@ -142,2 +142,15 @@ <p align="center">

}
// TLS settings
tls?:
| {
// Basic TLS without client certificates
ca_cert: Buffer
}
| {
// Mutual TLS with client certificates
ca_cert: Buffer
cert: Buffer
key: Buffer
}
}

@@ -144,0 +157,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

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