azure-kusto-data
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -15,3 +15,2 @@ "use strict"; | ||
const errors_1 = require("./errors"); | ||
const version_1 = require("./version"); | ||
const axios_1 = __importDefault(require("axios")); | ||
@@ -22,3 +21,3 @@ const http_1 = __importDefault(require("http")); | ||
const kustoTrustedEndpoints_1 = require("./kustoTrustedEndpoints"); | ||
const cloudSettings_1 = require("./cloudSettings"); | ||
const cloudSettings_1 = __importDefault(require("./cloudSettings")); | ||
const timeUtils_1 = require("./timeUtils"); | ||
@@ -45,3 +44,6 @@ const COMMAND_TIMEOUT_IN_MILLISECS = (0, timeUtils_1.toMilliseconds)(0, 10, 30); | ||
const url = new URL(this.connectionString.dataSource); | ||
this.cluster = `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ""}`; | ||
this.cluster = url.toString(); | ||
if (this.cluster.endsWith("/")) { | ||
this.cluster = this.cluster.slice(0, -1); | ||
} | ||
this.defaultDatabase = this.connectionString.initialCatalog; | ||
@@ -58,3 +60,2 @@ this.endpoints = { | ||
"Accept-Encoding": "gzip,deflate", | ||
"x-ms-client-version": `Kusto.Node.Client:${version_1.SDK_VERSION}`, | ||
Connection: "Keep-Alive", | ||
@@ -65,2 +66,5 @@ }; | ||
validateStatus: (status) => status === 200, | ||
maxBodyLength: Infinity, | ||
maxContentLength: Infinity, | ||
maxRedirects: 0, | ||
}; | ||
@@ -74,3 +78,3 @@ // http and https are Node modules and are not found in browsers | ||
axiosProps.cancelToken = this.cancelToken.token; | ||
this.axiosInstance = axios_1.default.create(); | ||
this.axiosInstance = axios_1.default.create(axiosProps); | ||
} | ||
@@ -107,3 +111,3 @@ async execute(db, query, properties) { | ||
this.ensureOpen(); | ||
kustoTrustedEndpoints_1.kustoTrustedEndpoints.validateTrustedEndpoint(endpoint, (await cloudSettings_1.CloudSettings.getInstance().getCloudInfoForCluster(this.cluster)).LoginEndpoint); | ||
kustoTrustedEndpoints_1.kustoTrustedEndpoints.validateTrustedEndpoint(endpoint, (await cloudSettings_1.default.getCloudInfoForCluster(this.cluster)).LoginEndpoint); | ||
db = this.getDb(db); | ||
@@ -167,2 +171,7 @@ const headers = {}; | ||
async _doRequest(endpoint, executionType, headers, payload, timeout, properties) { | ||
var _a; | ||
// replace non-ascii characters with ? in headers | ||
for (const key of Object.keys(headers)) { | ||
headers[key] = headers[key].replace(/[^\x00-\x7F]+/g, "?"); | ||
} | ||
const axiosConfig = { | ||
@@ -177,4 +186,9 @@ headers, | ||
catch (error) { | ||
if (axios_1.default.isAxiosError(error) && error.response) { | ||
if (error.response.status === 429) { | ||
if (axios_1.default.isAxiosError(error)) { | ||
// Since it's impossible to modify the error request object, the only way to censor the Authorization header is to remove it. | ||
error.request = undefined; | ||
if ((_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.headers) { | ||
error.config.headers.Authorization = "<REDACTED>"; | ||
} | ||
if (error.response && error.response.status === 429) { | ||
throw new errors_1.ThrottlingError("POST request failed with status 429 (Too Many Requests)", error); | ||
@@ -181,0 +195,0 @@ } |
@@ -25,8 +25,11 @@ "use strict"; | ||
this.cloudCache = {}; | ||
this.getFromCache = (kustoUri) => this.cloudCache[this.normalizeUrl(kustoUri)]; | ||
this.deleteFromCache = (kustoUri) => delete this.cloudCache[this.normalizeUrl(kustoUri)]; | ||
} | ||
static getInstance() { | ||
return CloudSettings.instance; | ||
writeToCache(url, info) { | ||
this.cloudCache[this.normalizeUrl(url)] = info !== null && info !== void 0 ? info : this.defaultCloudInfo; | ||
} | ||
async getCloudInfoForCluster(kustoUri) { | ||
var _a; | ||
kustoUri = this.normalizeUrl(kustoUri); | ||
if (kustoUri in this.cloudCache) { | ||
@@ -48,2 +51,3 @@ return this.cloudCache[kustoUri]; | ||
}, | ||
maxRedirects: 0, | ||
}); | ||
@@ -68,2 +72,10 @@ if (response.status === 200) { | ||
} | ||
normalizeUrl(kustoUri) { | ||
const url = new URL(kustoUri); | ||
const urlString = url.toString(); | ||
if (urlString.endsWith("/")) { | ||
return urlString.slice(0, urlString.length - 1); | ||
} | ||
return urlString; | ||
} | ||
static getAuthorityUri(cloudInfo, authorityId) { | ||
@@ -73,4 +85,5 @@ return cloudInfo.LoginEndpoint + "/" + (authorityId || "organizations"); | ||
} | ||
exports.CloudSettings = CloudSettings; | ||
CloudSettings.instance = new CloudSettings(); | ||
const cloudSettings = new CloudSettings(); | ||
exports.CloudSettings = cloudSettings; | ||
exports.default = cloudSettings; | ||
//# sourceMappingURL=cloudSettings.js.map |
@@ -68,6 +68,6 @@ "use strict"; | ||
} | ||
exports.KustoConnectionStringBuilder = KustoConnectionStringBuilder; | ||
KustoConnectionStringBuilder.DefaultDatabaseName = "NetDefaultDB"; | ||
KustoConnectionStringBuilder.SecretReplacement = "****"; | ||
exports.KustoConnectionStringBuilder = KustoConnectionStringBuilder; | ||
exports.default = KustoConnectionStringBuilder; | ||
//# sourceMappingURL=connectionBuilder.browser.js.map |
@@ -124,6 +124,6 @@ "use strict"; | ||
} | ||
exports.KustoConnectionStringBuilder = KustoConnectionStringBuilder; | ||
KustoConnectionStringBuilder.DefaultDatabaseName = "NetDefaultDB"; | ||
KustoConnectionStringBuilder.SecretReplacement = "****"; | ||
exports.KustoConnectionStringBuilder = KustoConnectionStringBuilder; | ||
exports.default = KustoConnectionStringBuilder; | ||
//# sourceMappingURL=connectionBuilder.js.map |
@@ -134,6 +134,6 @@ "use strict"; | ||
} | ||
exports.KustoConnectionStringBuilderBase = KustoConnectionStringBuilderBase; | ||
KustoConnectionStringBuilderBase.DefaultDatabaseName = "NetDefaultDB"; | ||
KustoConnectionStringBuilderBase.SecretReplacement = "****"; | ||
exports.KustoConnectionStringBuilderBase = KustoConnectionStringBuilderBase; | ||
exports.default = KustoConnectionStringBuilderBase; | ||
//# sourceMappingURL=connectionBuilderBase.js.map |
@@ -31,3 +31,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TimeUtils = exports.KustoDataErrors = exports.KustoConnectionStringBuilder = exports.ClientRequestProperties = exports.Client = void 0; | ||
exports.MatchRule = exports.kustoTrustedEndpoints = exports.CloudSettings = exports.TimeUtils = exports.KustoDataErrors = exports.KustoConnectionStringBuilder = exports.ClientRequestProperties = exports.Client = void 0; | ||
const client_1 = __importDefault(require("./client")); | ||
@@ -42,4 +42,9 @@ exports.Client = client_1.default; | ||
const timeUtils_1 = require("./timeUtils"); | ||
const cloudSettings_1 = __importDefault(require("./cloudSettings")); | ||
exports.CloudSettings = cloudSettings_1.default; | ||
const kustoTrustedEndpoints_1 = require("./kustoTrustedEndpoints"); | ||
Object.defineProperty(exports, "kustoTrustedEndpoints", { enumerable: true, get: function () { return kustoTrustedEndpoints_1.kustoTrustedEndpoints; } }); | ||
Object.defineProperty(exports, "MatchRule", { enumerable: true, get: function () { return kustoTrustedEndpoints_1.MatchRule; } }); | ||
const TimeUtils = { toMilliseconds: timeUtils_1.toMilliseconds }; | ||
exports.TimeUtils = TimeUtils; | ||
//# sourceMappingURL=index.js.map |
@@ -69,3 +69,3 @@ "use strict"; | ||
if (this.cloudInfo == null) { | ||
this.cloudInfo = await cloudSettings_1.CloudSettings.getInstance().getCloudInfoForCluster(this.kustoUri); | ||
this.cloudInfo = await cloudSettings_1.CloudSettings.getCloudInfoForCluster(this.kustoUri); | ||
let resourceUri = this.cloudInfo.KustoServiceResourceId; | ||
@@ -72,0 +72,0 @@ if (this.cloudInfo.LoginMfaRequired) { |
@@ -21,3 +21,4 @@ { | ||
".playfab.com", | ||
".kusto.data.microsoft.com" | ||
".kusto.data.microsoft.com", | ||
".kusto.fabric.microsoft.com" | ||
], | ||
@@ -24,0 +25,0 @@ "AllowedKustoHostnames": [ |
{ | ||
"name": "azure-kusto-data", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Azure Data Explorer Query SDK", | ||
@@ -10,3 +10,3 @@ "module": "dist-esm/src/index.js", | ||
"clean": "rimraf dist/* dist-esm/* types/*", | ||
"build": "tsc" | ||
"build": "tsc -b" | ||
}, | ||
@@ -72,3 +72,3 @@ "browser": { | ||
}, | ||
"gitHead": "8bc317c4cc1d99952fea819aca77c6e574b9c57e" | ||
"gitHead": "d9ce9b51bd4ec1d0278d8ba4afb08d5f378f542a" | ||
} |
@@ -12,4 +12,3 @@ export type CloudInfo = { | ||
*/ | ||
export declare class CloudSettings { | ||
private static instance; | ||
declare class CloudSettings { | ||
METADATA_ENDPOINT: string; | ||
@@ -20,7 +19,12 @@ defaultCloudInfo: CloudInfo; | ||
}; | ||
private constructor(); | ||
static getInstance(): CloudSettings; | ||
writeToCache(url: string, info?: CloudInfo): void; | ||
getFromCache: (kustoUri: string) => CloudInfo; | ||
deleteFromCache: (kustoUri: string) => boolean; | ||
getCloudInfoForCluster(kustoUri: string): Promise<CloudInfo>; | ||
private normalizeUrl; | ||
static getAuthorityUri(cloudInfo: CloudInfo, authorityId?: string): string; | ||
} | ||
declare const cloudSettings: CloudSettings; | ||
export { cloudSettings as CloudSettings }; | ||
export default cloudSettings; | ||
//# sourceMappingURL=cloudSettings.d.ts.map |
@@ -6,9 +6,9 @@ import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions } from "@azure/identity"; | ||
static readonly SecretReplacement = "****"; | ||
static withAadUserPasswordAuthentication(_connectionString: string, _userId: string, _password: string, _authorityId?: string): void; | ||
static withAadApplicationKeyAuthentication(_connectionString: string, _aadAppId: string, _appKey: string, _authorityId?: string): void; | ||
static withAadApplicationCertificateAuthentication(_connectionString: string, _aadAppId: string, _applicationCertificatePrivateKey: string, _authorityId?: string, _applicationCertificateSendX5c?: boolean): void; | ||
static withAadDeviceAuthentication(_connectionString: string, _authorityId?: string, _deviceCodeCallback?: (response: DeviceCodeInfo) => void): void; | ||
static withSystemManagedIdentity(_connectionString: string, _authorityId?: string, _timeoutMs?: number): void; | ||
static withUserManagedIdentity(_connectionString: string, _msiClientId: string, _authorityId?: string, _timeoutMs?: number): void; | ||
static withAzLoginIdentity(_connectionString: string, _authorityId?: string, _timeoutMs?: number): void; | ||
static withAadUserPasswordAuthentication(_connectionString: string, _userId: string, _password: string, _authorityId?: string): KustoConnectionStringBuilder; | ||
static withAadApplicationKeyAuthentication(_connectionString: string, _aadAppId: string, _appKey: string, _authorityId?: string): KustoConnectionStringBuilder; | ||
static withAadApplicationCertificateAuthentication(_connectionString: string, _aadAppId: string, _applicationCertificatePrivateKey: string, _authorityId?: string, _applicationCertificateSendX5c?: boolean): KustoConnectionStringBuilder; | ||
static withAadDeviceAuthentication(_connectionString: string, _authorityId?: string, _deviceCodeCallback?: (response: DeviceCodeInfo) => void): KustoConnectionStringBuilder; | ||
static withSystemManagedIdentity(_connectionString: string, _authorityId?: string, _timeoutMs?: number): KustoConnectionStringBuilder; | ||
static withUserManagedIdentity(_connectionString: string, _msiClientId: string, _authorityId?: string, _timeoutMs?: number): KustoConnectionStringBuilder; | ||
static withAzLoginIdentity(_connectionString: string, _authorityId?: string, _timeoutMs?: number): KustoConnectionStringBuilder; | ||
static withAccessToken(connectionString: string, accessToken: string): KustoConnectionStringBuilder; | ||
@@ -15,0 +15,0 @@ static withTokenProvider(connectionString: string, tokenProvider: () => Promise<string>): KustoConnectionStringBuilder; |
@@ -6,6 +6,8 @@ import KustoClient from "./client"; | ||
import { toMilliseconds } from "./timeUtils"; | ||
import CloudSettings from "./cloudSettings"; | ||
import { kustoTrustedEndpoints, MatchRule } from "./kustoTrustedEndpoints"; | ||
declare const TimeUtils: { | ||
toMilliseconds: typeof toMilliseconds; | ||
}; | ||
export { KustoClient as Client, ClientRequestProperties, KustoConnectionStringBuilder, KustoDataErrors, TimeUtils }; | ||
export { KustoClient as Client, ClientRequestProperties, KustoConnectionStringBuilder, KustoDataErrors, TimeUtils, CloudSettings, kustoTrustedEndpoints, MatchRule, }; | ||
//# sourceMappingURL=index.d.ts.map |
2374
110596
40