@clickhouse/client-web
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -20,6 +20,17 @@ "use strict"; | ||
}); | ||
this.defaultHeaders = { | ||
Authorization: `Basic ${btoa(`${params.username}:${params.password}`)}`, | ||
...params?.http_headers, | ||
}; | ||
if (params.auth.type === 'JWT') { | ||
this.defaultHeaders = { | ||
Authorization: `Bearer ${params.auth.access_token}`, | ||
...params?.http_headers, | ||
}; | ||
} | ||
else if (params.auth.type === 'Credentials') { | ||
this.defaultHeaders = { | ||
Authorization: `Basic ${btoa(`${params.auth.username}:${params.auth.password}`)}`, | ||
...params?.http_headers, | ||
}; | ||
} | ||
else { | ||
throw new Error(`Unknown auth type: ${params.auth.type}`); | ||
} | ||
} | ||
@@ -132,7 +143,8 @@ async query(params) { | ||
try { | ||
const authHeaderOverride = getAuthHeaderOverride(params?.auth); | ||
const headers = (0, client_common_1.withCompressionHeaders)({ | ||
headers: params?.auth !== undefined | ||
headers: authHeaderOverride !== undefined | ||
? { | ||
...this.defaultHeaders, | ||
Authorization: `Basic ${btoa(`${params.auth.username}:${params.auth.password}`)}`, | ||
Authorization: authHeaderOverride, | ||
} | ||
@@ -207,2 +219,10 @@ : this.defaultHeaders, | ||
} | ||
function getAuthHeaderOverride(auth) { | ||
if ((0, client_common_1.isJWTAuth)(auth)) { | ||
return `Bearer ${auth.access_token}`; | ||
} | ||
if ((0, client_common_1.isCredentialsAuth)(auth)) { | ||
return `Basic ${btoa(`${auth.username}:${auth.password}`)}`; | ||
} | ||
} | ||
//# sourceMappingURL=web_connection.js.map |
@@ -6,2 +6,2 @@ export { WebClickHouseClient as ClickHouseClient, type QueryResult, } from './client'; | ||
/** Re-export @clickhouse/client-common types */ | ||
export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, ClickHouseError, ClickHouseLogLevel, SettingsMap, SupportedJSONFormats, SupportedRawFormats, StreamableFormats, StreamableJSONFormats, SingleDocumentJSONFormats, RecordsJSONFormats, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, parseColumnType, SimpleColumnTypes, type ProgressRow, isProgressRow, type RowOrProgress, TupleParam, } from '@clickhouse/client-common'; | ||
export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, ClickHouseError, ClickHouseLogLevel, SettingsMap, SupportedJSONFormats, SupportedRawFormats, StreamableFormats, StreamableJSONFormats, SingleDocumentJSONFormats, RecordsJSONFormats, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, parseColumnType, SimpleColumnTypes, type ProgressRow, isProgressRow, type RowOrProgress, type ClickHouseAuth, type ClickHouseJWTAuth, type ClickHouseCredentialsAuth, TupleParam, } from '@clickhouse/client-common'; |
@@ -1,2 +0,2 @@ | ||
declare const _default: "1.9.1"; | ||
declare const _default: "1.10.0"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '1.9.1'; | ||
exports.default = '1.10.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://clickhouse.com", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"license": "Apache-2.0", | ||
@@ -24,4 +24,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@clickhouse/client-common": "1.9.1" | ||
"@clickhouse/client-common": "1.10.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
55509
610
+ Added@clickhouse/client-common@1.10.0(transitive)
- Removed@clickhouse/client-common@1.9.1(transitive)