private refreshToken()

in src/directLine.ts [675:704]


    private refreshToken() {
        return this.checkConnection(true)
        .flatMap(_ =>
            this.services.ajax({
                method: "POST",
                url: `${this.domain}/tokens/refresh`,
                timeout: this.timeout,
                headers: {
                    ...this.commonHeaders()
                }
            })
            .map(ajaxResponse => ajaxResponse.response.token as string)
            .retryWhen(error$ => error$
                .mergeMap(error => {
                    if (error.status === 403) {
                        // if the token is expired there's no reason to keep trying
                        this.expiredToken();
                        return Observable.throw(error, this.services.scheduler);
                    } else if (error.status === 404) {
                        // If the bot is gone, we should stop retrying
                        return Observable.throw(error, this.services.scheduler);
                    }

                    return Observable.of(error, this.services.scheduler);
                })
                .delay(this.timeout, this.services.scheduler)
                .take(this.retries)
            )
        )
    }