azure-kusto-data 3.3.0 → 3.4.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/README.md CHANGED
@@ -13,6 +13,7 @@ const KustoConnectionStringBuilder = require("azure-kusto-data").KustoConnection
13
13
  const kcsb = KustoConnectionStringBuilder.withAadApplicationKeyAuthentication(`https://${clusterName}.kusto.windows.net`, "appid", "appkey", "authorityId");
14
14
  const client = new KustoClient(kcsb);
15
15
 
16
+ // `execute()` infers the type of command from the query, although you can also specify the type explicitly using the methods `excuteQuery()`,`executeQueryV1()` or `executeMgmt()`
16
17
  const results = await client.execute("db", "TableName | limit 1");
17
18
  console.log(JSON.stringify(results));
18
19
  console.log(results.primaryResults[0].toString());
package/example.js CHANGED
@@ -37,6 +37,7 @@ async function start() {
37
37
  clientRequestProps.clientRequestId = `MyApp.MyActivity;${uuidv4()}`;
38
38
 
39
39
  try {
40
+ // `execute()` infers the type of command from the query, although you can also specify the type explicitly using the methods `excuteQuery()`,`executeQueryV1()` or `executeMgmt()`
40
41
  const results = await kustoClient.execute(database, `['${table}'] | limit 1`, clientRequestProps);
41
42
  console.log(JSON.stringify(results));
42
43
  console.log(results.primaryResults[0].toString());
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import KustoClient from "./source/client";
2
2
  import ClientRequestProperties from "./source/clientRequestProperties";
3
3
  import KustoConnectionStringBuilder from "./source/connectionBuilder";
4
- export { KustoClient as Client, ClientRequestProperties, KustoConnectionStringBuilder };
4
+ import * as KustoDataErrors from "./source/errors";
5
+ export { KustoClient as Client, ClientRequestProperties, KustoConnectionStringBuilder, KustoDataErrors };
package/index.js CHANGED
@@ -1,15 +1,40 @@
1
1
  "use strict";
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
4
27
  var __importDefault = (this && this.__importDefault) || function (mod) {
5
28
  return (mod && mod.__esModule) ? mod : { "default": mod };
6
29
  };
7
30
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.KustoConnectionStringBuilder = exports.ClientRequestProperties = exports.Client = void 0;
31
+ exports.KustoDataErrors = exports.KustoConnectionStringBuilder = exports.ClientRequestProperties = exports.Client = void 0;
9
32
  const client_1 = __importDefault(require("./source/client"));
10
33
  exports.Client = client_1.default;
11
34
  const clientRequestProperties_1 = __importDefault(require("./source/clientRequestProperties"));
12
35
  exports.ClientRequestProperties = clientRequestProperties_1.default;
13
36
  const connectionBuilder_1 = __importDefault(require("./source/connectionBuilder"));
14
37
  exports.KustoConnectionStringBuilder = connectionBuilder_1.default;
38
+ const KustoDataErrors = __importStar(require("./source/errors"));
39
+ exports.KustoDataErrors = KustoDataErrors;
15
40
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "azure-kusto-data",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Azure Data Explorer Query SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc"
9
+ },
7
10
  "engines": {
8
11
  "node": ">= 14.0.0"
9
12
  },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
10
16
  "tags": [
11
17
  "azure",
12
18
  "kusto",
@@ -17,33 +23,32 @@
17
23
  "azure",
18
24
  "kusto"
19
25
  ],
20
- "scripts": {
21
- "build": "tsc -b",
22
- "prepublish": "npm run build ",
23
- "example": "npm run build && node example.js",
24
- "lint": "npx eslint -c .eslintrc.js --ext .ts .",
25
- "test": "npm run build && mocha --parallel",
26
- "testPipeline": "npm run build && nyc --reporter lcovonly mocha --reporter mocha-junit-reporter",
27
- "format": "npx prettier --write .",
28
- "checkFormat": "npx prettier --check --end-of-line lf ."
29
- },
30
26
  "repository": {
31
27
  "type": "git",
32
28
  "url": "https://github.com/Azure/azure-kusto-node.git",
33
29
  "directory": "azure-kusto-data"
34
30
  },
31
+ "files": [
32
+ "source/**/*.js",
33
+ "source/**/*.d.ts",
34
+ "index.js",
35
+ "index.d.ts",
36
+ "tsconfig.tsbuildinfo",
37
+ "example.js"
38
+ ],
35
39
  "author": "",
36
40
  "license": "ISC",
37
41
  "homepage": "https://github.com/Azure/azure-kusto-node/blob/master/azure-kusto-data/README.md",
38
42
  "dependencies": {
39
- "@azure/identity": "^2.0.1",
40
- "@azure/msal-node": "^1.5.0",
41
- "@types/node": "^14.14.13",
42
- "@types/uuid": "^8.3.0",
43
- "axios": "^0.24.0",
44
- "follow-redirects": "^1.14.8",
45
- "moment": "^2.25.3",
43
+ "@azure/identity": "^2.1.0",
44
+ "@azure/msal-node": "^1.12.1",
45
+ "@types/node": "^18.6.4",
46
+ "@types/uuid": "^8.3.4",
47
+ "axios": "^0.27.2",
48
+ "follow-redirects": "^1.15.1",
49
+ "moment": "^2.29.4",
50
+ "ts-node": "^10.9.1",
46
51
  "uuid": "^8.3.2"
47
52
  },
48
- "gitHead": "c0b1e333ceddca341e05b3e0add4ef939d1bcea3"
53
+ "gitHead": "7133736d0867b15b126c62e14dd72bbaa69bf905"
49
54
  }
package/source/client.js CHANGED
@@ -21,6 +21,7 @@ const security_1 = __importDefault(require("./security"));
21
21
  const response_1 = require("./response");
22
22
  const connectionBuilder_1 = __importDefault(require("./connectionBuilder"));
23
23
  const clientRequestProperties_1 = __importDefault(require("./clientRequestProperties"));
24
+ const errors_1 = require("./errors");
24
25
  const package_json_1 = __importDefault(require("../package.json"));
25
26
  const axios_1 = __importDefault(require("axios"));
26
27
  const http_1 = __importDefault(require("http"));
@@ -39,7 +40,11 @@ var ExecutionType;
39
40
  class KustoClient {
40
41
  constructor(kcsb) {
41
42
  this.connectionString = typeof kcsb === "string" ? new connectionBuilder_1.default(kcsb) : kcsb;
42
- this.cluster = this.connectionString.dataSource;
43
+ if (!this.connectionString.dataSource) {
44
+ throw new Error("Cluster url is required");
45
+ }
46
+ const url = new URL(this.connectionString.dataSource);
47
+ this.cluster = `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ""}`;
43
48
  this.defaultDatabase = this.connectionString.initialCatalog;
44
49
  this.endpoints = {
45
50
  [ExecutionType.Mgmt]: `${this.cluster}/v1/rest/mgmt`,
@@ -157,7 +162,6 @@ class KustoClient {
157
162
  return db;
158
163
  }
159
164
  _doRequest(endpoint, executionType, headers, payload, timeout, properties) {
160
- var _a;
161
165
  return __awaiter(this, void 0, void 0, function* () {
162
166
  const axiosConfig = {
163
167
  headers,
@@ -169,8 +173,9 @@ class KustoClient {
169
173
  }
170
174
  catch (error) {
171
175
  if (axios_1.default.isAxiosError(error) && error.response) {
172
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
173
- throw ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.error) || error.response.data;
176
+ if (error.response.status === 429) {
177
+ throw new errors_1.ThrottlingError("POST request failed with status 429 (Too Many Requests)", error);
178
+ }
174
179
  }
175
180
  throw error;
176
181
  }
@@ -55,13 +55,13 @@ class ClientRequestProperties {
55
55
  toJSON() {
56
56
  const json = {};
57
57
  if (Object.keys(this._options).length !== 0) {
58
- json.Options = this._options;
58
+ json.Options = Object.assign({}, this._options);
59
59
  if (json.Options.servertimeout) {
60
60
  json.Options.servertimeout = this._msToTimespan(json.Options.servertimeout);
61
61
  }
62
62
  }
63
63
  if (Object.keys(this._parameters).length !== 0) {
64
- json.Parameters = this._parameters;
64
+ json.Parameters = Object.assign({}, this._parameters);
65
65
  }
66
66
  return Object.keys(json).length !== 0 ? json : null;
67
67
  }
@@ -69,7 +69,7 @@ const getPropName = (key) => {
69
69
  class KustoConnectionStringBuilder {
70
70
  constructor(connectionString) {
71
71
  var _a;
72
- this.authorityId = "common";
72
+ this.authorityId = "organizations";
73
73
  if (connectionString.trim().length === 0)
74
74
  throw new Error("Missing connection string");
75
75
  if (connectionString.endsWith("/") || connectionString.endsWith("\\")) {
@@ -157,10 +157,12 @@ class KustoConnectionStringBuilder {
157
157
  }
158
158
  return kcsb;
159
159
  }
160
- static withAadDeviceAuthentication(connectionString, authorityId = "common", deviceCodeCallback = KustoConnectionStringBuilder.defaultDeviceCallback) {
160
+ static withAadDeviceAuthentication(connectionString, authorityId, deviceCodeCallback = KustoConnectionStringBuilder.defaultDeviceCallback) {
161
161
  const kcsb = new KustoConnectionStringBuilder(connectionString);
162
162
  kcsb.aadFederatedSecurity = true;
163
- kcsb.authorityId = authorityId;
163
+ if (authorityId) {
164
+ kcsb.authorityId = authorityId;
165
+ }
164
166
  kcsb.deviceCodeCallback = deviceCodeCallback;
165
167
  kcsb.useDeviceCodeAuth = true;
166
168
  return kcsb;
@@ -4,3 +4,7 @@ export declare class KustoAuthenticationError extends Error {
4
4
  context: Record<string, any>;
5
5
  constructor(message: string, inner: Error | undefined, tokenProviderName: string, context: Record<string, any>);
6
6
  }
7
+ export declare class ThrottlingError extends Error {
8
+ inner: Error | undefined;
9
+ constructor(message: string, inner: Error | undefined);
10
+ }
package/source/errors.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.KustoAuthenticationError = void 0;
5
+ exports.ThrottlingError = exports.KustoAuthenticationError = void 0;
6
6
  class KustoAuthenticationError extends Error {
7
7
  constructor(message, inner, tokenProviderName, context) {
8
8
  super(message);
@@ -13,4 +13,12 @@ class KustoAuthenticationError extends Error {
13
13
  }
14
14
  }
15
15
  exports.KustoAuthenticationError = KustoAuthenticationError;
16
+ class ThrottlingError extends Error {
17
+ constructor(message, inner) {
18
+ super(message);
19
+ this.inner = inner;
20
+ this.name = "ThrottlingError";
21
+ }
22
+ }
23
+ exports.ThrottlingError = ThrottlingError;
16
24
  //# sourceMappingURL=errors.js.map
package/source/models.js CHANGED
@@ -6,8 +6,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.KustoResultTable = exports.KustoResultColumn = exports.KustoResultRow = exports.WellKnownDataSet = void 0;
9
- // We want all the Kusto table models in this file
10
- /* eslint-disable max-classes-per-file */
11
9
  const moment_1 = __importDefault(require("moment"));
12
10
  var WellKnownDataSet;
13
11
  (function (WellKnownDataSet) {
@@ -3,8 +3,6 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.KustoResponseDataSetV2 = exports.KustoResponseDataSetV1 = exports.KustoResponseDataSet = void 0;
6
- // We want all the Response models to be in this file
7
- /* eslint-disable max-classes-per-file */
8
6
  const models_1 = require("./models");
9
7
  var ErrorLevels;
10
8
  (function (ErrorLevels) {
@@ -1,4 +1,4 @@
1
- import { ConfidentialClientApplication, PublicClientApplication } from "@azure/msal-node";
1
+ import { ConfidentialClientApplication, PublicClientApplication, Configuration } from "@azure/msal-node";
2
2
  import { DeviceCodeResponse } from "@azure/msal-common";
3
3
  import { CloudInfo } from "./cloudSettings";
4
4
  import { TokenCredential } from "@azure/core-auth";
@@ -41,22 +41,23 @@ export declare class CallbackTokenProvider extends TokenProviderBase {
41
41
  * Acquire a token from MSAL
42
42
  */
43
43
  declare abstract class MsalTokenProvider extends TokenProviderBase {
44
- cloudInfo: CloudInfo;
45
- authorityId: string;
46
- initialized: boolean;
47
- authorityUri: string;
48
- abstract initClient(): void;
44
+ protected cloudInfo: CloudInfo;
45
+ protected authorityId: string;
46
+ protected initialized: boolean;
47
+ protected authorityUri: string;
48
+ protected clientId: string | undefined;
49
+ abstract initClient(commonOptions: Configuration): void;
49
50
  abstract acquireMsalToken(): Promise<TokenType | null>;
50
- protected constructor(kustoUri: string, authorityId: string);
51
+ protected constructor(kustoUri: string, authorityId: string, clientId: string | undefined);
52
+ commonOptions(): Configuration;
51
53
  acquireToken(): Promise<TokenResponse>;
52
54
  context(): Record<string, any>;
53
55
  }
54
56
  export declare abstract class AzureIdentityProvider extends MsalTokenProvider {
55
- protected clientId?: string | undefined;
56
57
  private timeoutMs?;
57
58
  private credential;
58
59
  protected authorityHost: string;
59
- constructor(kustoUri: string, authorityId: string, clientId?: string | undefined, timeoutMs?: number | undefined);
60
+ constructor(kustoUri: string, authorityId: string, clientId?: string, timeoutMs?: number | undefined);
60
61
  initClient(): void;
61
62
  getCommonOptions(): {
62
63
  authorityHost: string;
@@ -85,9 +86,11 @@ export declare class AzCliTokenProvider extends AzureIdentityProvider {
85
86
  */
86
87
  export declare class UserPromptProvider extends AzureIdentityProvider {
87
88
  private loginHint?;
88
- readonly BrowserPort = 23145;
89
+ readonly MinPort = 20000;
90
+ readonly MaxPort = 65536;
89
91
  constructor(kustoUri: string, authorityId: string, clientId?: string, timeoutMs?: number, loginHint?: string | undefined);
90
92
  getCredential(): TokenCredential;
93
+ private getRandomPortInRange;
91
94
  context(): Record<string, any>;
92
95
  }
93
96
  /**
@@ -99,7 +102,7 @@ export declare class UserPassTokenProvider extends MsalTokenProvider {
99
102
  homeAccountId?: string;
100
103
  msalClient: PublicClientApplication;
101
104
  constructor(kustoUri: string, userName: string, password: string, authorityId: string);
102
- initClient(): void;
105
+ initClient(commonOptions: Configuration): void;
103
106
  acquireMsalToken(): Promise<TokenType | null>;
104
107
  context(): Record<string, any>;
105
108
  }
@@ -111,18 +114,17 @@ export declare class DeviceLoginTokenProvider extends MsalTokenProvider {
111
114
  homeAccountId?: string;
112
115
  msalClient: PublicClientApplication;
113
116
  constructor(kustoUri: string, deviceCodeCallback: (response: DeviceCodeResponse) => void, authorityId: string);
114
- initClient(): void;
117
+ initClient(commonOptions: Configuration): void;
115
118
  acquireMsalToken(): Promise<TokenType | null>;
116
119
  }
117
120
  /**
118
121
  * Acquire a token from MSAL with application Id and Key
119
122
  */
120
123
  export declare class ApplicationKeyTokenProvider extends MsalTokenProvider {
121
- appClientId: string;
122
124
  appKey: string;
123
125
  msalClient: ConfidentialClientApplication;
124
126
  constructor(kustoUri: string, appClientId: string, appKey: string, authorityId: string);
125
- initClient(): void;
127
+ initClient(commonOptions: Configuration): void;
126
128
  acquireMsalToken(): Promise<TokenType | null>;
127
129
  context(): Record<string, any>;
128
130
  }
@@ -131,13 +133,12 @@ export declare class ApplicationKeyTokenProvider extends MsalTokenProvider {
131
133
  * Passing the public certificate is optional and will result in Subject Name & Issuer Authentication
132
134
  */
133
135
  export declare class ApplicationCertificateTokenProvider extends MsalTokenProvider {
134
- appClientId: string;
135
136
  certThumbprint: string;
136
137
  certPrivateKey: string;
137
138
  certX5c?: string;
138
139
  msalClient: ConfidentialClientApplication;
139
140
  constructor(kustoUri: string, appClientId: string, certThumbprint: string, certPrivateKey: string, certX5c?: string, authorityId?: string);
140
- initClient(): void;
141
+ initClient(commonOptions: Configuration): void;
141
142
  acquireMsalToken(): Promise<TokenType | null>;
142
143
  context(): Record<string, any>;
143
144
  }
@@ -12,7 +12,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.ApplicationCertificateTokenProvider = exports.ApplicationKeyTokenProvider = exports.DeviceLoginTokenProvider = exports.UserPassTokenProvider = exports.UserPromptProvider = exports.AzCliTokenProvider = exports.MsiTokenProvider = exports.AzureIdentityProvider = exports.CallbackTokenProvider = exports.BasicTokenProvider = exports.TokenProviderBase = void 0;
15
- /* eslint-disable max-classes-per-file -- We want all the Token Providers in this file */
16
15
  const msal_node_1 = require("@azure/msal-node");
17
16
  const identity_1 = require("@azure/identity");
18
17
  const cloudSettings_1 = require("./cloudSettings");
@@ -70,11 +69,21 @@ exports.CallbackTokenProvider = CallbackTokenProvider;
70
69
  * Acquire a token from MSAL
71
70
  */
72
71
  class MsalTokenProvider extends TokenProviderBase {
73
- constructor(kustoUri, authorityId) {
72
+ constructor(kustoUri, authorityId, clientId) {
74
73
  super(kustoUri);
74
+ this.clientId = clientId;
75
75
  this.initialized = false;
76
76
  this.authorityId = authorityId;
77
77
  }
78
+ commonOptions() {
79
+ return {
80
+ auth: {
81
+ clientId: this.clientId,
82
+ knownAuthorities: [this.cloudInfo.LoginEndpoint],
83
+ authority: this.authorityUri,
84
+ },
85
+ };
86
+ }
78
87
  acquireToken() {
79
88
  return __awaiter(this, void 0, void 0, function* () {
80
89
  if (!this.initialized) {
@@ -86,7 +95,10 @@ class MsalTokenProvider extends TokenProviderBase {
86
95
  }
87
96
  this.scopes = [resourceUri + "/.default"];
88
97
  this.authorityUri = cloudSettings_1.CloudSettings.getAuthorityUri(this.cloudInfo, this.authorityId);
89
- this.initClient();
98
+ if (!this.clientId) {
99
+ this.clientId = this.cloudInfo.KustoClientAppId;
100
+ }
101
+ this.initClient(this.commonOptions());
90
102
  }
91
103
  this.initialized = true;
92
104
  }
@@ -103,8 +115,7 @@ class MsalTokenProvider extends TokenProviderBase {
103
115
  }
104
116
  class AzureIdentityProvider extends MsalTokenProvider {
105
117
  constructor(kustoUri, authorityId, clientId, timeoutMs) {
106
- super(kustoUri, authorityId);
107
- this.clientId = clientId;
118
+ super(kustoUri, authorityId, clientId);
108
119
  this.timeoutMs = timeoutMs;
109
120
  }
110
121
  initClient() {
@@ -172,10 +183,14 @@ class UserPromptProvider extends AzureIdentityProvider {
172
183
  super(kustoUri, authorityId, clientId, timeoutMs);
173
184
  this.loginHint = loginHint;
174
185
  // The default port is 80, which can lead to permission errors, so we'll choose another port
175
- this.BrowserPort = 23145;
186
+ this.MinPort = 20000;
187
+ this.MaxPort = 65536;
176
188
  }
177
189
  getCredential() {
178
- return new identity_1.InteractiveBrowserCredential(Object.assign(Object.assign({}, this.getCommonOptions()), { loginHint: this.loginHint, redirectUri: `http://localhost:${this.BrowserPort}/` }));
190
+ return new identity_1.InteractiveBrowserCredential(Object.assign(Object.assign({}, this.getCommonOptions()), { loginHint: this.loginHint, redirectUri: `http://localhost:${this.getRandomPortInRange()}/` }));
191
+ }
192
+ getRandomPortInRange() {
193
+ return Math.floor(Math.random() * (this.MaxPort - this.MinPort) + this.MinPort);
179
194
  }
180
195
  context() {
181
196
  let base = super.context();
@@ -191,18 +206,12 @@ exports.UserPromptProvider = UserPromptProvider;
191
206
  */
192
207
  class UserPassTokenProvider extends MsalTokenProvider {
193
208
  constructor(kustoUri, userName, password, authorityId) {
194
- super(kustoUri, authorityId);
209
+ super(kustoUri, authorityId, undefined);
195
210
  this.userName = userName;
196
211
  this.password = password;
197
212
  }
198
- initClient() {
199
- const clientConfig = {
200
- auth: {
201
- clientId: this.cloudInfo.KustoClientAppId,
202
- authority: this.authorityUri,
203
- },
204
- };
205
- this.msalClient = new msal_node_1.PublicClientApplication(clientConfig);
213
+ initClient(commonOptions) {
214
+ this.msalClient = new msal_node_1.PublicClientApplication(commonOptions);
206
215
  }
207
216
  acquireMsalToken() {
208
217
  var _a;
@@ -238,17 +247,11 @@ exports.UserPassTokenProvider = UserPassTokenProvider;
238
247
  */
239
248
  class DeviceLoginTokenProvider extends MsalTokenProvider {
240
249
  constructor(kustoUri, deviceCodeCallback, authorityId) {
241
- super(kustoUri, authorityId);
250
+ super(kustoUri, authorityId, undefined);
242
251
  this.deviceCodeCallback = deviceCodeCallback;
243
252
  }
244
- initClient() {
245
- const clientConfig = {
246
- auth: {
247
- clientId: this.cloudInfo.KustoClientAppId,
248
- authority: this.authorityUri,
249
- },
250
- };
251
- this.msalClient = new msal_node_1.PublicClientApplication(clientConfig);
253
+ initClient(commonOptions) {
254
+ this.msalClient = new msal_node_1.PublicClientApplication(commonOptions);
252
255
  }
253
256
  acquireMsalToken() {
254
257
  var _a;
@@ -280,18 +283,11 @@ exports.DeviceLoginTokenProvider = DeviceLoginTokenProvider;
280
283
  */
281
284
  class ApplicationKeyTokenProvider extends MsalTokenProvider {
282
285
  constructor(kustoUri, appClientId, appKey, authorityId) {
283
- super(kustoUri, authorityId);
284
- this.appClientId = appClientId;
286
+ super(kustoUri, authorityId, appClientId);
285
287
  this.appKey = appKey;
286
288
  }
287
- initClient() {
288
- const clientConfig = {
289
- auth: {
290
- clientId: this.appClientId,
291
- clientSecret: this.appKey,
292
- authority: this.authorityUri,
293
- },
294
- };
289
+ initClient(commonOptions) {
290
+ const clientConfig = Object.assign(Object.assign({}, commonOptions), { auth: Object.assign(Object.assign({}, commonOptions.auth), { clientSecret: this.appKey }) });
295
291
  this.msalClient = new msal_node_1.ConfidentialClientApplication(clientConfig);
296
292
  }
297
293
  acquireMsalToken() {
@@ -300,7 +296,7 @@ class ApplicationKeyTokenProvider extends MsalTokenProvider {
300
296
  });
301
297
  }
302
298
  context() {
303
- return Object.assign(Object.assign({}, super.context()), { clientId: this.appClientId });
299
+ return Object.assign(Object.assign({}, super.context()), { clientId: this.clientId });
304
300
  }
305
301
  }
306
302
  exports.ApplicationKeyTokenProvider = ApplicationKeyTokenProvider;
@@ -310,24 +306,17 @@ exports.ApplicationKeyTokenProvider = ApplicationKeyTokenProvider;
310
306
  */
311
307
  class ApplicationCertificateTokenProvider extends MsalTokenProvider {
312
308
  constructor(kustoUri, appClientId, certThumbprint, certPrivateKey, certX5c, authorityId) {
313
- super(kustoUri, authorityId);
314
- this.appClientId = appClientId;
309
+ super(kustoUri, authorityId, appClientId);
315
310
  this.certThumbprint = certThumbprint;
316
311
  this.certPrivateKey = certPrivateKey;
317
312
  this.certX5c = certX5c;
318
313
  }
319
- initClient() {
320
- const clientConfig = {
321
- auth: {
322
- clientId: this.appClientId,
323
- authority: this.authorityUri,
324
- clientCertificate: {
314
+ initClient(commonOptions) {
315
+ const clientConfig = Object.assign(Object.assign({}, commonOptions), { auth: Object.assign(Object.assign({}, commonOptions.auth), { clientCertificate: {
325
316
  thumbprint: this.certThumbprint,
326
317
  privateKey: this.certPrivateKey,
327
318
  x5c: this.certX5c,
328
- },
329
- },
330
- };
319
+ } }) });
331
320
  this.msalClient = new msal_node_1.ConfidentialClientApplication(clientConfig);
332
321
  }
333
322
  acquireMsalToken() {
@@ -336,7 +325,7 @@ class ApplicationCertificateTokenProvider extends MsalTokenProvider {
336
325
  });
337
326
  }
338
327
  context() {
339
- return Object.assign(Object.assign({}, super.context()), { clientId: this.appClientId, thumbprint: this.certThumbprint });
328
+ return Object.assign(Object.assign({}, super.context()), { clientId: this.clientId, thumbprint: this.certThumbprint });
340
329
  }
341
330
  }
342
331
  exports.ApplicationCertificateTokenProvider = ApplicationCertificateTokenProvider;