azure-kusto-data 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +5 -0
- package/.eslintrc.js +247 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +5 -0
- package/README.md +22 -12
- package/example.js +3 -5
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/package.json +63 -51
- package/source/client.d.ts +3 -3
- package/source/client.js +41 -28
- package/source/client.js.map +1 -1
- package/source/clientRequestProperties.d.ts +13 -2
- package/source/clientRequestProperties.js +11 -5
- package/source/clientRequestProperties.js.map +1 -1
- package/source/cloudSettings.js +2 -2
- package/source/cloudSettings.js.map +1 -1
- package/source/connectionBuilder.d.ts +22 -6
- package/source/connectionBuilder.js +120 -50
- package/source/connectionBuilder.js.map +1 -1
- package/source/errors.d.ts +6 -0
- package/source/errors.js +16 -0
- package/source/errors.js.map +1 -0
- package/source/models.d.ts +29 -5
- package/source/models.js +57 -20
- package/source/models.js.map +1 -1
- package/source/response.d.ts +2 -2
- package/source/response.js +15 -13
- package/source/response.js.map +1 -1
- package/source/security.d.ts +2 -2
- package/source/security.js +31 -20
- package/source/security.js.map +1 -1
- package/source/tokenProvider.d.ts +62 -28
- package/source/tokenProvider.js +143 -61
- package/source/tokenProvider.js.map +1 -1
- package/source/typeUtilts.d.ts +3 -0
- package/source/typeUtilts.js +5 -0
- package/source/typeUtilts.js.map +1 -0
- package/tsconfig.json +16 -16
- package/tsconfig.tsbuildinfo +1579 -2247
- package/index.ts +0 -13
- package/tslint.json +0 -18
package/source/client.js
CHANGED
|
@@ -16,10 +16,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.KustoClient = void 0;
|
|
18
18
|
const moment_1 = __importDefault(require("moment"));
|
|
19
|
-
const uuid_1 =
|
|
19
|
+
const uuid_1 = require("uuid");
|
|
20
20
|
const security_1 = __importDefault(require("./security"));
|
|
21
21
|
const response_1 = require("./response");
|
|
22
22
|
const connectionBuilder_1 = __importDefault(require("./connectionBuilder"));
|
|
23
|
+
const clientRequestProperties_1 = __importDefault(require("./clientRequestProperties"));
|
|
23
24
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
24
25
|
const axios_1 = __importDefault(require("axios"));
|
|
25
26
|
const http_1 = __importDefault(require("http"));
|
|
@@ -37,7 +38,7 @@ var ExecutionType;
|
|
|
37
38
|
})(ExecutionType || (ExecutionType = {}));
|
|
38
39
|
class KustoClient {
|
|
39
40
|
constructor(kcsb) {
|
|
40
|
-
this.connectionString = typeof
|
|
41
|
+
this.connectionString = typeof kcsb === "string" ? new connectionBuilder_1.default(kcsb) : kcsb;
|
|
41
42
|
this.cluster = this.connectionString.dataSource;
|
|
42
43
|
this.endpoints = {
|
|
43
44
|
[ExecutionType.Mgmt]: `${this.cluster}/v1/rest/mgmt`,
|
|
@@ -47,14 +48,14 @@ class KustoClient {
|
|
|
47
48
|
};
|
|
48
49
|
this.aadHelper = new security_1.default(this.connectionString);
|
|
49
50
|
const headers = {
|
|
50
|
-
|
|
51
|
+
Accept: "application/json",
|
|
51
52
|
"Accept-Encoding": "gzip,deflate",
|
|
52
53
|
"x-ms-client-version": `Kusto.Node.Client:${package_json_1.default.version}`,
|
|
53
|
-
|
|
54
|
+
Connection: "Keep-Alive",
|
|
54
55
|
};
|
|
55
56
|
this.axiosInstance = axios_1.default.create({
|
|
56
57
|
headers,
|
|
57
|
-
validateStatus: (status) => status
|
|
58
|
+
validateStatus: (status) => status === 200,
|
|
58
59
|
// keepAlive pools and reuses TCP connections, so it's faster
|
|
59
60
|
httpAgent: new http_1.default.Agent({ keepAlive: true }),
|
|
60
61
|
httpsAgent: new https_1.default.Agent({ keepAlive: true }),
|
|
@@ -84,13 +85,18 @@ class KustoClient {
|
|
|
84
85
|
return this._execute(this.endpoints[ExecutionType.Mgmt], ExecutionType.Mgmt, db, query, null, properties);
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
|
-
executeStreamingIngest(db, table, stream, streamFormat, mappingName) {
|
|
88
|
+
executeStreamingIngest(db, table, stream, streamFormat, mappingName, clientRequestId) {
|
|
88
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
90
|
let endpoint = `${this.endpoints[ExecutionType.Ingest]}/${db}/${table}?streamFormat=${streamFormat}`;
|
|
90
91
|
if (mappingName != null) {
|
|
91
92
|
endpoint += `&mappingName=${mappingName}`;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
let properties = null;
|
|
95
|
+
if (clientRequestId) {
|
|
96
|
+
properties = new clientRequestProperties_1.default();
|
|
97
|
+
properties.clientRequestId = clientRequestId;
|
|
98
|
+
}
|
|
99
|
+
return this._execute(endpoint, ExecutionType.Ingest, db, null, stream, properties);
|
|
94
100
|
});
|
|
95
101
|
}
|
|
96
102
|
_execute(endpoint, executionType, db, query, stream, properties) {
|
|
@@ -100,38 +106,44 @@ class KustoClient {
|
|
|
100
106
|
let clientRequestPrefix = "";
|
|
101
107
|
let clientRequestId;
|
|
102
108
|
const timeout = this._getClientTimeout(executionType, properties);
|
|
103
|
-
let
|
|
109
|
+
let payloadContent = "";
|
|
104
110
|
if (query != null) {
|
|
105
111
|
payload = {
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
db,
|
|
113
|
+
csl: query,
|
|
108
114
|
};
|
|
109
115
|
if (properties != null) {
|
|
110
|
-
payload.properties = properties.
|
|
111
|
-
clientRequestId = properties.clientRequestId;
|
|
112
|
-
if (properties.application != null) {
|
|
113
|
-
headers["x-ms-app"] = properties.application;
|
|
114
|
-
}
|
|
115
|
-
if (properties.user != null) {
|
|
116
|
-
headers["x-ms-user"] = properties.user;
|
|
117
|
-
}
|
|
116
|
+
payload.properties = properties.toJSON();
|
|
118
117
|
}
|
|
119
|
-
|
|
118
|
+
payloadContent = JSON.stringify(payload);
|
|
120
119
|
headers["Content-Type"] = "application/json; charset=utf-8";
|
|
121
120
|
clientRequestPrefix = "KNC.execute;";
|
|
122
121
|
}
|
|
123
122
|
else if (stream != null) {
|
|
124
|
-
|
|
123
|
+
payloadContent = stream;
|
|
125
124
|
clientRequestPrefix = "KNC.executeStreamingIngest;";
|
|
126
125
|
headers["Content-Encoding"] = "gzip";
|
|
127
126
|
headers["Content-Type"] = "multipart/form-data";
|
|
128
127
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
if (properties != null) {
|
|
129
|
+
clientRequestId = properties.clientRequestId;
|
|
130
|
+
if (properties.application != null) {
|
|
131
|
+
headers["x-ms-app"] = properties.application;
|
|
132
|
+
}
|
|
133
|
+
if (properties.user != null) {
|
|
134
|
+
headers["x-ms-user"] = properties.user;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
headers["x-ms-client-request-id"] = clientRequestId || clientRequestPrefix + `${uuid_1.v4()}`;
|
|
138
|
+
const authHeader = yield this.aadHelper.getAuthHeader();
|
|
139
|
+
if (authHeader != null) {
|
|
140
|
+
headers.Authorization = authHeader;
|
|
141
|
+
}
|
|
142
|
+
return this._doRequest(endpoint, executionType, headers, payloadContent, timeout, properties);
|
|
132
143
|
});
|
|
133
144
|
}
|
|
134
145
|
_doRequest(endpoint, executionType, headers, payload, timeout, properties) {
|
|
146
|
+
var _a;
|
|
135
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
148
|
const axiosConfig = {
|
|
137
149
|
headers,
|
|
@@ -142,8 +154,9 @@ class KustoClient {
|
|
|
142
154
|
axiosResponse = yield this.axiosInstance.post(endpoint, payload, axiosConfig);
|
|
143
155
|
}
|
|
144
156
|
catch (error) {
|
|
145
|
-
if (error.response) {
|
|
146
|
-
|
|
157
|
+
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
159
|
+
throw ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.error) || error.response.data;
|
|
147
160
|
}
|
|
148
161
|
throw error;
|
|
149
162
|
}
|
|
@@ -152,12 +165,12 @@ class KustoClient {
|
|
|
152
165
|
}
|
|
153
166
|
_parseResponse(response, executionType, properties, status) {
|
|
154
167
|
const { raw } = properties || {};
|
|
155
|
-
if (raw === true || executionType
|
|
168
|
+
if (raw === true || executionType === ExecutionType.Ingest) {
|
|
156
169
|
return response;
|
|
157
170
|
}
|
|
158
171
|
let kustoResponse = null;
|
|
159
172
|
try {
|
|
160
|
-
if (executionType
|
|
173
|
+
if (executionType === ExecutionType.Query) {
|
|
161
174
|
kustoResponse = new response_1.KustoResponseDataSetV2(response);
|
|
162
175
|
}
|
|
163
176
|
else {
|
|
@@ -183,7 +196,7 @@ class KustoClient {
|
|
|
183
196
|
return serverTimeout + CLIENT_SERVER_DELTA_IN_MILLISECS;
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
|
-
return
|
|
199
|
+
return executionType === ExecutionType.Query || executionType === ExecutionType.QueryV1 ? QUERY_TIMEOUT_IN_MILLISECS : COMMAND_TIMEOUT_IN_MILLISECS;
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
202
|
exports.KustoClient = KustoClient;
|
package/source/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;AAElC,oDAA4B;AAC5B
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;AAElC,oDAA4B;AAC5B,+BAAoC;AACpC,0DAAmC;AACnC,yCAAgH;AAChH,4EAA0D;AAC1D,wFAAgE;AAChE,mEAAkC;AAClC,kDAA6C;AAC7C,gDAAwB;AACxB,kDAA0B;AAE1B,MAAM,4BAA4B,GAAG,gBAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,cAAc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AE,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,6BAA6B,aAAa,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;SACjF;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,iBAAiB,CAAC,aAA4B,EAAE,UAA2C;QACvF,IAAI,UAAU,IAAI,IAAI,EAAE;YACpB,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;YACpD,IAAI,aAAa,EAAE;gBACf,OAAO,aAAa,CAAC;aACxB;YAED,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;YAC9C,IAAI,aAAa,EAAE;gBACf,OAAO,aAAa,GAAG,gCAAgC,CAAC;aAC3D;SACJ;QAED,OAAO,aAAa,KAAK,aAAa,CAAC,KAAK,IAAI,aAAa,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,4BAA4B,CAAC;IACxJ,CAAC;CACJ;AArMD,kCAqMC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -6,17 +6,20 @@ export declare class ClientRequestProperties {
|
|
|
6
6
|
user: string | null;
|
|
7
7
|
application: string | null;
|
|
8
8
|
raw?: boolean;
|
|
9
|
-
constructor(options?:
|
|
9
|
+
constructor(options?: Record<string, unknown>, parameters?: Record<string, unknown>, clientRequestId?: string, user?: string, application?: string);
|
|
10
10
|
setOption(name: string, value: any): void;
|
|
11
11
|
getOption(name: string, defaultValue?: any): any;
|
|
12
12
|
setParameter(name: string, value: any): void;
|
|
13
13
|
getParameter(name: string, defaultValue?: any): any;
|
|
14
14
|
clearParameters(): void;
|
|
15
15
|
setTimeout(timeoutMillis: number): void;
|
|
16
|
-
getTimeout():
|
|
16
|
+
getTimeout(): number | undefined;
|
|
17
17
|
setClientTimeout(timeoutMillis: number): void;
|
|
18
18
|
getClientTimeout(): number | undefined;
|
|
19
19
|
clearOptions(): void;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated use the compliant toJSON() instead
|
|
22
|
+
*/
|
|
20
23
|
toJson(): {
|
|
21
24
|
Options?: {
|
|
22
25
|
[option: string]: any;
|
|
@@ -25,6 +28,14 @@ export declare class ClientRequestProperties {
|
|
|
25
28
|
[option: string]: any;
|
|
26
29
|
} | undefined;
|
|
27
30
|
} | null;
|
|
31
|
+
toJSON(): {
|
|
32
|
+
Options?: {
|
|
33
|
+
[option: string]: any;
|
|
34
|
+
} | undefined;
|
|
35
|
+
Parameters?: {
|
|
36
|
+
[option: string]: any;
|
|
37
|
+
} | undefined;
|
|
38
|
+
} | null;
|
|
28
39
|
toString(): string;
|
|
29
40
|
_msToTimespan(duration: number): string;
|
|
30
41
|
}
|
|
@@ -46,7 +46,13 @@ class ClientRequestProperties {
|
|
|
46
46
|
clearOptions() {
|
|
47
47
|
this._options = {};
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated use the compliant toJSON() instead
|
|
51
|
+
*/
|
|
49
52
|
toJson() {
|
|
53
|
+
return this.toJSON();
|
|
54
|
+
}
|
|
55
|
+
toJSON() {
|
|
50
56
|
const json = {};
|
|
51
57
|
if (Object.keys(this._options).length !== 0) {
|
|
52
58
|
json.Options = this._options;
|
|
@@ -60,17 +66,17 @@ class ClientRequestProperties {
|
|
|
60
66
|
return Object.keys(json).length !== 0 ? json : null;
|
|
61
67
|
}
|
|
62
68
|
toString() {
|
|
63
|
-
return JSON.stringify(this.
|
|
69
|
+
return JSON.stringify(this.toJSON());
|
|
64
70
|
}
|
|
65
71
|
_msToTimespan(duration) {
|
|
66
72
|
const milliseconds = Math.floor((duration % 1000) / 100);
|
|
67
73
|
const seconds = Math.floor((duration / 1000) % 60);
|
|
68
74
|
const minutes = Math.floor((duration / (1000 * 60)) % 60);
|
|
69
75
|
const hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
|
|
70
|
-
const hoursStr =
|
|
71
|
-
const minutesStr =
|
|
72
|
-
const secondsStr =
|
|
73
|
-
return hoursStr
|
|
76
|
+
const hoursStr = hours < 10 ? `0${hours}` : String(hours);
|
|
77
|
+
const minutesStr = minutes < 10 ? `0${minutes}` : String(minutes);
|
|
78
|
+
const secondsStr = seconds < 10 ? `0${seconds}` : String(seconds);
|
|
79
|
+
return `${hoursStr}:${minutesStr}:${secondsStr}.${milliseconds}`;
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
exports.ClientRequestProperties = ClientRequestProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientRequestProperties.js","sourceRoot":"","sources":["clientRequestProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,MAAa,uBAAuB;IAShC,YAAY,
|
|
1
|
+
{"version":3,"file":"clientRequestProperties.js","sourceRoot":"","sources":["clientRequestProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,MAAa,uBAAuB;IAShC,YAAY,OAAiC,EAAE,UAAoC,EAAE,eAAwB,EAAE,IAAa,EAAE,WAAoB;QAC9I,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,UAAU,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,eAAe,IAAI,IAAI,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,IAAI,CAAC;IAC3C,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,KAAU;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,YAAkB;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,YAAY,CAAC;QAE7E,OAAO,IAAI,CAAC,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CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAElE,OAAO,GAAG,QAAQ,IAAI,UAAU,IAAI,UAAU,IAAI,YAAY,EAAE,CAAC;IACrE,CAAC;CACJ;AA1GD,0DA0GC;AAED,kBAAe,uBAAuB,CAAC"}
|
package/source/cloudSettings.js
CHANGED
|
@@ -46,7 +46,7 @@ class CloudSettings {
|
|
|
46
46
|
}
|
|
47
47
|
try {
|
|
48
48
|
const response = yield axios_1.default.get(kustoUri + this.METADATA_ENDPOINT);
|
|
49
|
-
if (response.status
|
|
49
|
+
if (response.status === 200) {
|
|
50
50
|
this.cloudCache[kustoUri] = response.data.AzureAD || this.defaultCloudInfo;
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
@@ -54,7 +54,7 @@ class CloudSettings {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
catch (ex) {
|
|
57
|
-
if (((_a = ex.response) === null || _a === void 0 ? void 0 : _a.status)
|
|
57
|
+
if (axios_1.default.isAxiosError(ex) && ((_a = ex.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
58
58
|
// For now as long not all proxies implement the metadata endpoint, if no endpoint exists return public cloud data
|
|
59
59
|
this.cloudCache[kustoUri] = this.defaultCloudInfo;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudSettings.js","sourceRoot":"","sources":["cloudSettings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,kDAA0B;AAW1B;;GAEG;AACH,MAAa,aAAa;IAatB;QAXA,sBAAiB,GAAG,wBAAwB,CAAC;QAC7C,qBAAgB,GAAc;YAC1B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,mCAAmC;YACjF,gBAAgB,EAAE,KAAK;YACvB,gBAAgB,EAAE,sCAAsC;YACxD,sBAAsB,EAAE,+BAA+B;YACvD,s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;aACJ;YAAC,OAAO,EAAE,EAAE;gBACT,IAAI,eAAK,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,OAAA,EAAE,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE;oBACvD,kHAAkH;oBAClH,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC;iBACrD;qBAAM;oBACH,MAAM,IAAI,KAAK,CAAC,wCAAwC,QAAQ,MAAM,EAAE,EAAE,CAAC,CAAC;iBAC/E;aACJ;YACD,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;;KACpC;IAED,MAAM,CAAC,eAAe,CAAC,SAAoB,EAAE,WAAoB;QAC7D,OAAO,SAAS,CAAC,aAAa,GAAG,GAAG,GAAG,CAAC,WAAW,IAAI,eAAe,CAAC,CAAC;IAC5E,CAAC;CACJ;AAjDD,sCAiDC"}
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
import { DeviceCodeResponse } from "@azure/msal-common";
|
|
2
2
|
export declare class KustoConnectionStringBuilder {
|
|
3
|
-
|
|
3
|
+
static readonly SecretReplacement = "****";
|
|
4
|
+
static defaultDeviceCallback: (response: DeviceCodeResponse) => void;
|
|
4
5
|
dataSource?: string;
|
|
6
|
+
aadFederatedSecurity?: boolean;
|
|
5
7
|
aadUserId?: string;
|
|
6
8
|
password?: string;
|
|
7
9
|
applicationClientId?: string;
|
|
10
|
+
msiClientId?: string;
|
|
8
11
|
applicationKey?: string;
|
|
9
12
|
applicationCertificatePrivateKey?: string;
|
|
10
13
|
applicationCertificateThumbprint?: string;
|
|
11
|
-
|
|
14
|
+
applicationCertificateX5c?: string;
|
|
15
|
+
authorityId: string;
|
|
12
16
|
deviceCodeCallback?: (response: DeviceCodeResponse) => void;
|
|
17
|
+
tokenProvider?: () => Promise<string>;
|
|
18
|
+
loginHint?: string;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
accessToken?: string;
|
|
21
|
+
useDeviceCodeAuth?: boolean;
|
|
22
|
+
useUserPromptAuth?: boolean;
|
|
23
|
+
useAzLoginAuth?: boolean;
|
|
24
|
+
useManagedIdentityAuth?: boolean;
|
|
13
25
|
constructor(connectionString: string);
|
|
26
|
+
toString(removeSecrets?: boolean): string;
|
|
27
|
+
static fromExisting(other: KustoConnectionStringBuilder): KustoConnectionStringBuilder;
|
|
14
28
|
static withAadUserPasswordAuthentication(connectionString: string, userId: string, password: string, authorityId?: string): KustoConnectionStringBuilder;
|
|
15
29
|
static withAadApplicationKeyAuthentication(connectionString: string, aadAppId: string, appKey: string, authorityId?: string): KustoConnectionStringBuilder;
|
|
16
30
|
static withAadApplicationCertificateAuthentication(connectionString: string, aadAppId: string, applicationCertificatePrivateKey: string, applicationCertificateThumbprint: string, authorityId?: string, applicationCertificateX5c?: string): KustoConnectionStringBuilder;
|
|
17
|
-
static withAadDeviceAuthentication(connectionString: string, authorityId
|
|
18
|
-
static withAadManagedIdentities(connectionString: string, msiClientId?: string): KustoConnectionStringBuilder;
|
|
19
|
-
static withAzLoginIdentity(connectionString: string): KustoConnectionStringBuilder;
|
|
20
|
-
static withAccessToken(connectionString: string, accessToken
|
|
31
|
+
static withAadDeviceAuthentication(connectionString: string, authorityId?: string, deviceCodeCallback?: (response: DeviceCodeResponse) => void): KustoConnectionStringBuilder;
|
|
32
|
+
static withAadManagedIdentities(connectionString: string, msiClientId?: string, authorityId?: string, timeoutMs?: number): KustoConnectionStringBuilder;
|
|
33
|
+
static withAzLoginIdentity(connectionString: string, authorityId?: string, timeoutMs?: number): KustoConnectionStringBuilder;
|
|
34
|
+
static withAccessToken(connectionString: string, accessToken: string): KustoConnectionStringBuilder;
|
|
35
|
+
static withTokenProvider(connectionString: string, tokenProvider: () => Promise<string>): KustoConnectionStringBuilder;
|
|
36
|
+
static withUserPrompt(connectionString: string, authorityId?: string, clientId?: string, timeoutMs?: number, loginHint?: string): KustoConnectionStringBuilder;
|
|
21
37
|
}
|
|
22
38
|
export default KustoConnectionStringBuilder;
|
|
@@ -5,64 +5,68 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.KustoConnectionStringBuilder = void 0;
|
|
6
6
|
const KeywordMapping = Object.freeze({
|
|
7
7
|
dataSource: {
|
|
8
|
-
propName: "dataSource",
|
|
9
8
|
mappedTo: "Data Source",
|
|
10
|
-
validNames: ["data source", "addr", "address", "network address", "server"]
|
|
9
|
+
validNames: ["data source", "addr", "address", "network address", "server"],
|
|
10
|
+
},
|
|
11
|
+
aadFederatedSecurity: {
|
|
12
|
+
mappedTo: "AAD Federated Security",
|
|
13
|
+
validNames: ["aad federated security", "federated security", "federated", "fed", "aadfed"],
|
|
14
|
+
isBool: true,
|
|
11
15
|
},
|
|
12
16
|
aadUserId: {
|
|
13
|
-
propName: "aadUserId",
|
|
14
17
|
mappedTo: "AAD User ID",
|
|
15
|
-
validNames: ["aad user id"]
|
|
18
|
+
validNames: ["aad user id"],
|
|
16
19
|
},
|
|
17
20
|
password: {
|
|
18
|
-
propName: "password",
|
|
19
21
|
mappedTo: "Password",
|
|
20
|
-
validNames: ["password", "pwd"]
|
|
22
|
+
validNames: ["password", "pwd"],
|
|
23
|
+
isSecret: true,
|
|
21
24
|
},
|
|
22
25
|
applicationClientId: {
|
|
23
|
-
propName: "applicationClientId",
|
|
24
26
|
mappedTo: "Application Client Id",
|
|
25
|
-
validNames: ["application client id", "appclientid"]
|
|
27
|
+
validNames: ["application client id", "appclientid"],
|
|
26
28
|
},
|
|
27
29
|
applicationKey: {
|
|
28
|
-
propName: "applicationKey",
|
|
29
30
|
mappedTo: "Application Key",
|
|
30
|
-
validNames: ["application key", "appkey"]
|
|
31
|
+
validNames: ["application key", "appkey"],
|
|
32
|
+
isSecret: true,
|
|
31
33
|
},
|
|
32
34
|
applicationCertificatePrivateKey: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
mappedTo: "Application Certificate PrivateKey",
|
|
36
|
+
validNames: ["Application Certificate PrivateKey"],
|
|
37
|
+
isSecret: true,
|
|
36
38
|
},
|
|
37
39
|
applicationCertificateThumbprint: {
|
|
38
|
-
propName: "applicationCertificateThumbprint",
|
|
39
40
|
mappedTo: "Application Certificate Thumbprint",
|
|
40
|
-
validNames: ["application certificate thumbprint"]
|
|
41
|
+
validNames: ["application certificate thumbprint", "AppCert"],
|
|
41
42
|
},
|
|
42
43
|
applicationCertificateX5c: {
|
|
43
|
-
propName: "applicationCertificateX5c",
|
|
44
44
|
mappedTo: "Application Certificate x5c",
|
|
45
|
-
validNames: ["application certificate x5c"]
|
|
45
|
+
validNames: ["application certificate x5c", "Application Certificate Send Public Certificate", "Application Certificate SendX5c", "SendX5c"],
|
|
46
46
|
},
|
|
47
47
|
authorityId: {
|
|
48
|
-
propName: "authorityId",
|
|
49
48
|
mappedTo: "Authority Id",
|
|
50
|
-
validNames: ["authority id", "authorityid", "authority", "tenantid", "tenant", "tid"]
|
|
51
|
-
}
|
|
49
|
+
validNames: ["authority id", "authorityid", "authority", "tenantid", "tenant", "tid"],
|
|
50
|
+
},
|
|
52
51
|
});
|
|
53
52
|
const getPropName = (key) => {
|
|
54
53
|
const _key = key.trim().toLowerCase();
|
|
55
54
|
for (const keyword of Object.keys(KeywordMapping)) {
|
|
56
55
|
const k = KeywordMapping[keyword];
|
|
57
|
-
if (k
|
|
58
|
-
|
|
56
|
+
if (!k) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (k.validNames.map((n) => n.trim().toLowerCase()).indexOf(_key) >= 0) {
|
|
60
|
+
return [keyword, k];
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
throw new Error(key);
|
|
63
|
+
throw new Error("Failed to get prop: " + key);
|
|
62
64
|
};
|
|
63
65
|
class KustoConnectionStringBuilder {
|
|
64
66
|
constructor(connectionString) {
|
|
65
|
-
|
|
67
|
+
var _a;
|
|
68
|
+
this.authorityId = "common";
|
|
69
|
+
if (connectionString.trim().length === 0)
|
|
66
70
|
throw new Error("Missing connection string");
|
|
67
71
|
if (connectionString.endsWith("/") || connectionString.endsWith("\\")) {
|
|
68
72
|
connectionString = connectionString.slice(0, -1);
|
|
@@ -70,73 +74,139 @@ class KustoConnectionStringBuilder {
|
|
|
70
74
|
if (!!connectionString && connectionString.split(";")[0].indexOf("=") === -1) {
|
|
71
75
|
connectionString = "Data Source=" + connectionString;
|
|
72
76
|
}
|
|
73
|
-
this[KeywordMapping.authorityId.propName] = "common";
|
|
74
77
|
const params = connectionString.split(";");
|
|
75
78
|
for (const item of params) {
|
|
76
79
|
const kvp = item.split("=");
|
|
77
|
-
|
|
80
|
+
const [mappingTypeName, mappingType] = getPropName(kvp[0]);
|
|
81
|
+
if (mappingType.isBool) {
|
|
82
|
+
this[mappingTypeName] = kvp[1].trim().toLowerCase() === "true";
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this[mappingTypeName] = (_a = kvp[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
86
|
+
}
|
|
78
87
|
}
|
|
79
88
|
}
|
|
89
|
+
toString(removeSecrets = true) {
|
|
90
|
+
return Object.entries(KeywordMapping)
|
|
91
|
+
.map(([key, mappingType]) => {
|
|
92
|
+
const value = this[key];
|
|
93
|
+
if (!mappingType || value === undefined) {
|
|
94
|
+
return "";
|
|
95
|
+
}
|
|
96
|
+
if (mappingType.isSecret && removeSecrets) {
|
|
97
|
+
return `${mappingType.mappedTo}=${KustoConnectionStringBuilder.SecretReplacement}`;
|
|
98
|
+
}
|
|
99
|
+
return `${mappingType.mappedTo}=${value.toString()}`;
|
|
100
|
+
})
|
|
101
|
+
.filter((x) => x !== "")
|
|
102
|
+
.join(";");
|
|
103
|
+
}
|
|
104
|
+
static fromExisting(other) {
|
|
105
|
+
return Object.assign({}, other);
|
|
106
|
+
}
|
|
80
107
|
static withAadUserPasswordAuthentication(connectionString, userId, password, authorityId) {
|
|
81
|
-
if (
|
|
108
|
+
if (userId.trim().length === 0)
|
|
82
109
|
throw new Error("Invalid user");
|
|
83
|
-
if (
|
|
110
|
+
if (password.trim().length === 0)
|
|
84
111
|
throw new Error("Invalid password");
|
|
85
112
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
86
|
-
kcsb
|
|
87
|
-
kcsb
|
|
88
|
-
kcsb
|
|
113
|
+
kcsb.aadFederatedSecurity = true;
|
|
114
|
+
kcsb.aadUserId = userId;
|
|
115
|
+
kcsb.password = password;
|
|
116
|
+
if (authorityId) {
|
|
117
|
+
kcsb.authorityId = authorityId;
|
|
118
|
+
}
|
|
89
119
|
return kcsb;
|
|
90
120
|
}
|
|
91
121
|
static withAadApplicationKeyAuthentication(connectionString, aadAppId, appKey, authorityId) {
|
|
92
|
-
if (
|
|
122
|
+
if (aadAppId.trim().length === 0)
|
|
93
123
|
throw new Error("Invalid app id");
|
|
94
|
-
if (
|
|
124
|
+
if (appKey.trim().length === 0)
|
|
95
125
|
throw new Error("Invalid app key");
|
|
96
126
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
97
|
-
kcsb
|
|
98
|
-
kcsb
|
|
99
|
-
kcsb
|
|
127
|
+
kcsb.aadFederatedSecurity = true;
|
|
128
|
+
kcsb.applicationClientId = aadAppId;
|
|
129
|
+
kcsb.applicationKey = appKey;
|
|
130
|
+
if (authorityId) {
|
|
131
|
+
kcsb.authorityId = authorityId;
|
|
132
|
+
}
|
|
100
133
|
return kcsb;
|
|
101
134
|
}
|
|
102
135
|
static withAadApplicationCertificateAuthentication(connectionString, aadAppId, applicationCertificatePrivateKey, applicationCertificateThumbprint, authorityId, applicationCertificateX5c) {
|
|
103
|
-
if (
|
|
136
|
+
if (aadAppId.trim().length === 0)
|
|
104
137
|
throw new Error("Invalid app id");
|
|
105
|
-
if (
|
|
138
|
+
if (applicationCertificatePrivateKey.trim().length === 0)
|
|
106
139
|
throw new Error("Invalid certificate");
|
|
107
|
-
if (
|
|
140
|
+
if (applicationCertificateThumbprint.trim().length === 0)
|
|
108
141
|
throw new Error("Invalid thumbprint");
|
|
109
142
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
110
|
-
kcsb
|
|
111
|
-
kcsb
|
|
112
|
-
kcsb
|
|
113
|
-
kcsb
|
|
114
|
-
kcsb
|
|
143
|
+
kcsb.aadFederatedSecurity = true;
|
|
144
|
+
kcsb.applicationClientId = aadAppId;
|
|
145
|
+
kcsb.applicationCertificatePrivateKey = applicationCertificatePrivateKey;
|
|
146
|
+
kcsb.applicationCertificateThumbprint = applicationCertificateThumbprint;
|
|
147
|
+
kcsb.applicationCertificateX5c = applicationCertificateX5c;
|
|
148
|
+
if (authorityId) {
|
|
149
|
+
kcsb.authorityId = authorityId;
|
|
150
|
+
}
|
|
115
151
|
return kcsb;
|
|
116
152
|
}
|
|
117
|
-
static withAadDeviceAuthentication(connectionString, authorityId, deviceCodeCallback) {
|
|
153
|
+
static withAadDeviceAuthentication(connectionString, authorityId = "common", deviceCodeCallback = KustoConnectionStringBuilder.defaultDeviceCallback) {
|
|
118
154
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
119
|
-
kcsb
|
|
155
|
+
kcsb.aadFederatedSecurity = true;
|
|
156
|
+
kcsb.authorityId = authorityId;
|
|
120
157
|
kcsb.deviceCodeCallback = deviceCodeCallback;
|
|
158
|
+
kcsb.useDeviceCodeAuth = true;
|
|
121
159
|
return kcsb;
|
|
122
160
|
}
|
|
123
|
-
static withAadManagedIdentities(connectionString, msiClientId) {
|
|
161
|
+
static withAadManagedIdentities(connectionString, msiClientId, authorityId, timeoutMs) {
|
|
124
162
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
163
|
+
kcsb.aadFederatedSecurity = true;
|
|
164
|
+
if (authorityId) {
|
|
165
|
+
kcsb.authorityId = authorityId;
|
|
166
|
+
}
|
|
125
167
|
kcsb.msiClientId = msiClientId;
|
|
126
|
-
kcsb.
|
|
168
|
+
kcsb.timeoutMs = timeoutMs;
|
|
169
|
+
kcsb.useManagedIdentityAuth = true;
|
|
127
170
|
return kcsb;
|
|
128
171
|
}
|
|
129
|
-
static withAzLoginIdentity(connectionString) {
|
|
172
|
+
static withAzLoginIdentity(connectionString, authorityId, timeoutMs) {
|
|
130
173
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
131
|
-
kcsb.
|
|
174
|
+
kcsb.aadFederatedSecurity = true;
|
|
175
|
+
kcsb.useAzLoginAuth = true;
|
|
176
|
+
if (authorityId) {
|
|
177
|
+
kcsb.authorityId = authorityId;
|
|
178
|
+
}
|
|
179
|
+
kcsb.timeoutMs = timeoutMs;
|
|
132
180
|
return kcsb;
|
|
133
181
|
}
|
|
134
182
|
static withAccessToken(connectionString, accessToken) {
|
|
135
183
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
184
|
+
kcsb.aadFederatedSecurity = true;
|
|
136
185
|
kcsb.accessToken = accessToken;
|
|
137
186
|
return kcsb;
|
|
138
187
|
}
|
|
188
|
+
static withTokenProvider(connectionString, tokenProvider) {
|
|
189
|
+
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
190
|
+
kcsb.aadFederatedSecurity = true;
|
|
191
|
+
kcsb.tokenProvider = tokenProvider;
|
|
192
|
+
return kcsb;
|
|
193
|
+
}
|
|
194
|
+
static withUserPrompt(connectionString, authorityId, clientId, timeoutMs, loginHint) {
|
|
195
|
+
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
196
|
+
kcsb.aadFederatedSecurity = true;
|
|
197
|
+
kcsb.useUserPromptAuth = true;
|
|
198
|
+
if (authorityId) {
|
|
199
|
+
kcsb.authorityId = authorityId;
|
|
200
|
+
}
|
|
201
|
+
kcsb.loginHint = loginHint;
|
|
202
|
+
kcsb.applicationClientId = clientId;
|
|
203
|
+
kcsb.timeoutMs = timeoutMs;
|
|
204
|
+
return kcsb;
|
|
205
|
+
}
|
|
139
206
|
}
|
|
140
207
|
exports.KustoConnectionStringBuilder = KustoConnectionStringBuilder;
|
|
208
|
+
KustoConnectionStringBuilder.SecretReplacement = "****";
|
|
209
|
+
// eslint-disable-next-line no-console
|
|
210
|
+
KustoConnectionStringBuilder.defaultDeviceCallback = (response) => console.log(response.message);
|
|
141
211
|
exports.default = KustoConnectionStringBuilder;
|
|
142
212
|
//# sourceMappingURL=connectionBuilder.js.map
|