Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function DirectLine(options) {
this.connectionStatus$ = new rxjs_1.BehaviorSubject(BotConnection_1.ConnectionStatus.Uninitialized);
this.domain = "https://directline.botframework.com/v3/directline";
this.webSocket = false;
this.watermark = '';
this.secret = options.secret;
this.token = options.secret || options.token;
if (options.domain)
this.domain = options.domain;
if (options.webSocket)
this.webSocket = options.webSocket;
this.activity$ = this.webSocket && WebSocket !== undefined
? this.webSocketActivity$()
: this.pollingGetActivity$();
}
// Every time we're about to make a Direct Line REST call, we call this first to see check the current connection status.
function DirectLine(secretOrToken, domain) {
var _this = this;
if (domain === void 0) { domain = "https://directline.botframework.com"; }
this.domain = domain;
this.connected$ = new rxjs_1.BehaviorSubject(false);
this.token = secretOrToken.secret || secretOrToken.token;
rxjs_1.Observable.ajax({
method: "POST",
url: this.domain + "/api/conversations",
headers: {
"Accept": "application/json",
"Authorization": "BotConnector " + this.token
}
})
.map(function (ajaxResponse) { return ajaxResponse.response; })
.retryWhen(function (error$) { return error$.delay(1000); })
.subscribe(function (conversation) {
_this.conversationId = conversation.conversationId;
_this.connected$.next(true);
if (!secretOrToken.secret) {
rxjs_1.Observable.timer(intervalRefreshToken, intervalRefreshToken).flatMap(function (_) {
createStateStream$(model:IReducer, initialState:T, sideEffects?:SideEffectHandler):Rx.BehaviorSubject {
const state$ = new Rx.BehaviorSubject(null);
this.action$
.startWith(null)
.scan(
(state:T, action:ActionPayload) => {
const newState = action !== null ? model.reduce(state, action) : state;
sideEffects && action !== null ?
sideEffects(newState, action, this.dispatch) :
null;
return newState;
},
initialState
)
.subscribe(state$);
return state$;
}
function DirectLine3(secretOrToken, domain, segment) {
if (domain === void 0) { domain = "https://directline.botframework.com"; }
this.domain = domain;
this.segment = segment;
this.connected$ = new rxjs_1.BehaviorSubject(false);
this.secret = secretOrToken.secret;
this.token = secretOrToken.secret || secretOrToken.token;
}
DirectLine3.prototype.start = function () {