botframework-connector
Advanced tools
Comparing version 4.14.1-dev7 to 4.14.1-dev8
import { Activity, InvokeResponse } from 'botframework-schema'; | ||
import { BotFrameworkClient } from '../skills'; | ||
import { ConnectorClientOptions } from '../connectorApi/models'; | ||
import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; | ||
import { AgentSettings } from '@azure/ms-rest-js/es/lib/serviceClient'; | ||
export declare class BotFrameworkClientImpl implements BotFrameworkClient { | ||
private readonly credentialsFactory; | ||
private readonly loginEndpoint; | ||
private readonly botFrameworkClientFetch; | ||
private readonly agentSettings?; | ||
constructor(credentialsFactory: ServiceClientCredentialsFactory, loginEndpoint: string, botFrameworkClientFetch?: (input: RequestInfo, init?: RequestInit, agentSettings?: AgentSettings) => Promise<Response>, agentSettings?: AgentSettings); | ||
private readonly botFrameworkClientFetch?; | ||
private readonly connectorClientOptions?; | ||
constructor(credentialsFactory: ServiceClientCredentialsFactory, loginEndpoint: string, botFrameworkClientFetch?: (input: RequestInfo, init?: RequestInit, options?: ConnectorClientOptions) => Promise<Response>, connectorClientOptions?: ConnectorClientOptions); | ||
private toJSON; | ||
postActivity<T>(fromBotId: string, toBotId: string, toUrl: string, serviceUrl: string, conversationId: string, activity: Activity): Promise<InvokeResponse<T>>; | ||
} | ||
//# sourceMappingURL=botFrameworkClientImpl.d.ts.map |
import { Activity, InvokeResponse } from 'botframework-schema'; | ||
import { BotFrameworkClient } from '../skills'; | ||
import { ConnectorClientOptions } from '../connectorApi/models'; | ||
import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; | ||
import { AgentSettings } from '@azure/ms-rest-js/es/lib/serviceClient'; | ||
export declare class BotFrameworkClientImpl implements BotFrameworkClient { | ||
private readonly credentialsFactory; | ||
private readonly loginEndpoint; | ||
private readonly botFrameworkClientFetch; | ||
private readonly agentSettings?; | ||
constructor(credentialsFactory: ServiceClientCredentialsFactory, loginEndpoint: string, botFrameworkClientFetch?: (input: RequestInfo, init?: RequestInit, agentSettings?: AgentSettings) => Promise<Response>, agentSettings?: AgentSettings); | ||
private readonly botFrameworkClientFetch?; | ||
private readonly connectorClientOptions?; | ||
constructor(credentialsFactory: ServiceClientCredentialsFactory, loginEndpoint: string, botFrameworkClientFetch?: (input: RequestInfo, init?: RequestInit, options?: ConnectorClientOptions) => Promise<Response>, connectorClientOptions?: ConnectorClientOptions); | ||
private toJSON; | ||
postActivity<T>(fromBotId: string, toBotId: string, toUrl: string, serviceUrl: string, conversationId: string, activity: Activity): Promise<InvokeResponse<T>>; | ||
} | ||
//# sourceMappingURL=botFrameworkClientImpl.d.ts.map |
@@ -13,2 +13,13 @@ "use strict"; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -22,27 +33,44 @@ exports.BotFrameworkClientImpl = void 0; | ||
const botbuilder_stdlib_1 = require("botbuilder-stdlib"); | ||
const botFrameworkClientFetchImpl = (input, init, agentSettings) => __awaiter(void 0, void 0, void 0, function* () { | ||
const config = { | ||
headers: init.headers, | ||
const botFrameworkClientFetchImpl = (connectorClientOptions) => { | ||
var _a; | ||
const { http: httpAgent, https: httpsAgent } = (_a = connectorClientOptions === null || connectorClientOptions === void 0 ? void 0 : connectorClientOptions.agentSettings) !== null && _a !== void 0 ? _a : { | ||
http: undefined, | ||
https: undefined, | ||
}; | ||
const axiosInstance = axios_1.default.create({ | ||
httpAgent, | ||
httpsAgent, | ||
validateStatus: () => true, | ||
httpAgent: agentSettings === null || agentSettings === void 0 ? void 0 : agentSettings.http, | ||
httpsAgent: agentSettings === null || agentSettings === void 0 ? void 0 : agentSettings.https, | ||
}; | ||
botbuilder_stdlib_1.assert.string(input, ['input']); | ||
botbuilder_stdlib_1.assert.string(init.body, ['init']); | ||
const activity = JSON.parse(init.body); | ||
const response = yield axios_1.default.post(input, activity, config); | ||
return { | ||
status: response.status, | ||
json: () => __awaiter(void 0, void 0, void 0, function* () { return response.data; }), | ||
}; | ||
}); | ||
}); | ||
return (input, init) => __awaiter(void 0, void 0, void 0, function* () { | ||
const config = { | ||
headers: init.headers, | ||
}; | ||
botbuilder_stdlib_1.assert.string(input, ['input']); | ||
botbuilder_stdlib_1.assert.string(init.body, ['init']); | ||
const activity = JSON.parse(init.body); | ||
const response = yield axiosInstance.post(input, activity, config); | ||
return { | ||
status: response.status, | ||
json: () => __awaiter(void 0, void 0, void 0, function* () { return response.data; }), | ||
}; | ||
}); | ||
}; | ||
// Internal | ||
class BotFrameworkClientImpl { | ||
constructor(credentialsFactory, loginEndpoint, botFrameworkClientFetch = botFrameworkClientFetchImpl, agentSettings) { | ||
constructor(credentialsFactory, loginEndpoint, botFrameworkClientFetch, connectorClientOptions) { | ||
var _a; | ||
this.credentialsFactory = credentialsFactory; | ||
this.loginEndpoint = loginEndpoint; | ||
this.botFrameworkClientFetch = botFrameworkClientFetch; | ||
this.agentSettings = agentSettings; | ||
this.connectorClientOptions = connectorClientOptions; | ||
botbuilder_stdlib_1.assert.maybeFunc(botFrameworkClientFetch, ['botFrameworkClientFetch']); | ||
(_a = this.botFrameworkClientFetch) !== null && _a !== void 0 ? _a : (this.botFrameworkClientFetch = botFrameworkClientFetchImpl(this.connectorClientOptions)); | ||
} | ||
toJSON() { | ||
// Ignore ConnectorClientOptions, as it could contain Circular Structure behavior. | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const _a = this, { connectorClientOptions } = _a, rest = __rest(_a, ["connectorClientOptions"]); | ||
return rest; | ||
} | ||
postActivity(fromBotId, toBotId, toUrl, serviceUrl, conversationId, activity) { | ||
@@ -98,3 +126,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
}; | ||
const response = yield this.botFrameworkClientFetch(request.url, config, this.agentSettings); | ||
const response = yield this.botFrameworkClientFetch(request.url, config, this.connectorClientOptions); | ||
return { status: response.status, body: yield response.json() }; | ||
@@ -101,0 +129,0 @@ } |
@@ -110,4 +110,3 @@ "use strict"; | ||
createBotFrameworkClient() { | ||
var _a; | ||
return new botFrameworkClientImpl_1.BotFrameworkClientImpl(this.credentialsFactory, this.toChannelFromBotLoginUrl, this.botFrameworkClientFetch, (_a = this.connectorClientOptions) === null || _a === void 0 ? void 0 : _a.agentSettings); | ||
return new botFrameworkClientImpl_1.BotFrameworkClientImpl(this.credentialsFactory, this.toChannelFromBotLoginUrl, this.botFrameworkClientFetch, this.connectorClientOptions); | ||
} | ||
@@ -114,0 +113,0 @@ JwtTokenValidation_authenticateRequest(activity, authHeader) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Bot Connector is autorest generated connector client.", | ||
"version": "4.14.1-dev7", | ||
"version": "4.14.1-dev8", | ||
"license": "MIT", | ||
@@ -37,4 +37,4 @@ "keywords": [ | ||
"base64url": "^3.0.0", | ||
"botbuilder-stdlib": "4.14.1-internal.dev7", | ||
"botframework-schema": "4.14.1-dev7", | ||
"botbuilder-stdlib": "4.14.1-internal.dev8", | ||
"botframework-schema": "4.14.1-dev8", | ||
"cross-fetch": "^3.0.5", | ||
@@ -41,0 +41,0 @@ "jsonwebtoken": "8.0.1", |
@@ -7,2 +7,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { BotFrameworkClient } from '../skills'; | ||
import { ConnectorClientOptions } from '../connectorApi/models'; | ||
import { ConversationIdHttpHeaderName } from '../conversationConstants'; | ||
@@ -13,25 +14,29 @@ import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; | ||
import { assert } from 'botbuilder-stdlib'; | ||
import { AgentSettings } from '@azure/ms-rest-js/es/lib/serviceClient'; | ||
const botFrameworkClientFetchImpl = async ( | ||
input: RequestInfo, | ||
init?: RequestInit, | ||
agentSettings?: AgentSettings | ||
): Promise<Response> => { | ||
const config = { | ||
headers: init.headers as Record<string, string>, | ||
const botFrameworkClientFetchImpl = (connectorClientOptions: ConnectorClientOptions) => { | ||
const { http: httpAgent, https: httpsAgent } = connectorClientOptions?.agentSettings ?? { | ||
http: undefined, | ||
https: undefined, | ||
}; | ||
const axiosInstance = axios.create({ | ||
httpAgent, | ||
httpsAgent, | ||
validateStatus: (): boolean => true, | ||
httpAgent: agentSettings?.http, | ||
httpsAgent: agentSettings?.https, | ||
}; | ||
}); | ||
assert.string(input, ['input']); | ||
assert.string(init.body, ['init']); | ||
const activity = JSON.parse(init.body) as Activity; | ||
return async (input: RequestInfo, init?: RequestInit): Promise<Response> => { | ||
const config = { | ||
headers: init.headers as Record<string, string>, | ||
}; | ||
const response = await axios.post(input, activity, config); | ||
return { | ||
status: response.status, | ||
json: async () => response.data, | ||
} as Response; | ||
assert.string(input, ['input']); | ||
assert.string(init.body, ['init']); | ||
const activity = JSON.parse(init.body) as Activity; | ||
const response = await axiosInstance.post(input, activity, config); | ||
return { | ||
status: response.status, | ||
json: async () => response.data, | ||
} as Response; | ||
}; | ||
}; | ||
@@ -44,12 +49,21 @@ | ||
private readonly loginEndpoint: string, | ||
private readonly botFrameworkClientFetch: ( | ||
private readonly botFrameworkClientFetch?: ( | ||
input: RequestInfo, | ||
init?: RequestInit, | ||
agentSettings?: AgentSettings | ||
) => Promise<Response> = botFrameworkClientFetchImpl, | ||
private readonly agentSettings?: AgentSettings | ||
options?: ConnectorClientOptions | ||
) => Promise<Response>, | ||
private readonly connectorClientOptions?: ConnectorClientOptions | ||
) { | ||
assert.maybeFunc(botFrameworkClientFetch, ['botFrameworkClientFetch']); | ||
this.botFrameworkClientFetch ??= botFrameworkClientFetchImpl(this.connectorClientOptions); | ||
} | ||
private toJSON() { | ||
// Ignore ConnectorClientOptions, as it could contain Circular Structure behavior. | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { connectorClientOptions, ...rest } = this; | ||
return rest; | ||
} | ||
async postActivity<T>( | ||
@@ -122,3 +136,3 @@ fromBotId: string, | ||
}; | ||
const response = await this.botFrameworkClientFetch(request.url, config, this.agentSettings); | ||
const response = await this.botFrameworkClientFetch(request.url, config, this.connectorClientOptions); | ||
@@ -125,0 +139,0 @@ return { status: response.status, body: await response.json() }; |
@@ -148,3 +148,3 @@ // Copyright (c) Microsoft Corporation. | ||
this.botFrameworkClientFetch, | ||
this.connectorClientOptions?.agentSettings | ||
this.connectorClientOptions | ||
); | ||
@@ -151,0 +151,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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7860221
117478
+ Addedbotbuilder-stdlib@4.14.1-internal.dev8(transitive)
+ Addedbotframework-schema@4.14.1-dev8(transitive)
- Removedbotbuilder-stdlib@4.14.1-internal.dev7(transitive)
- Removedbotframework-schema@4.14.1-dev7(transitive)