@ewsjs/xhr

中文文档
3.1.3发布于 2024/05/13MITTypeScriptCommonJS近 30 天下载 24.2万

alternate XHR methods for ewsjs

原始使用文档
文档目录14 节
  1. 3.1.2
  2. 3.1.1
  3. 3.1.0
  4. 3.0.0
  5. 2.0.0
  6. 1.5.0
  7. constructor
  8. Proxy server support
  9. adding Ntlm authentication (or Windows Integrated Authentic…
  10. adding cookies authentication (usage with TMG/ISA)
  11. using proxy with cookies authentication
  12. Info: No Proxy support with Ntlm (yet!)
  13. License
  14. 1.1.1 changes

@ewsjs/xhr

renaming ews-javascript-api-auth to @ewsjs/xhr

other related libs will also move to @ewsjs scope/org

1.3.0 brings several changes, new api and proxy support. this is also re-written using popular request package

3.1.2

  • Fixed proxy issue with axios

3.1.1

  • Fixed responseType for axios

3.1.0

  • update dependencies

3.0.0

  • Updated @ewsjs/ntlm-client to 3.0.0 to fix node 18+ issues with ntlm

2.0.0

  • Removed deprecated xhr apis (cookieAuthXhrApi, ntlmAuthXhrApi, proxySupportedXhrApi).
  • removed dependency on request, bluebird and fetch.

1.5.0

#15 use pre-call options in stream

Install

npm install @ewsjs/xhr --save

How To

public methods useProxy, useNtlmAuthentication and useCookieAuthentication returns the instance for chaining.

// import 
import { ......,  ConfigurationApi } from "ews-javascript-api";
import { XhrApi } from "@ewsjs/xhr";

// create instance
let xhr = new XhrApi({ headers: { 'custom-header': 'value' }, rejectUnauthorized: false})
    .useCookieAuthentication(credentials.userName, credentials.password)
    .useProxy("http://squidorOtherProxyServer:3128", "proxyUser", "password");

// alternatively 
let xhr = new XhrApi({ headers: { 'custom-header': 'value' }, rejectUnauthorized: false});
xhr.useCookieAuthentication(credentials.userName, credentials.password);
xhr.useProxy("http://squidorOtherProxyServer:3128", "proxyUser", "password");

// use in ews-javascript-api
ConfigurationApi.ConfigureXHR(xhr);

constructor

/**
 * Creates an instance of XhrApi optionally passing options for request
 * @memberof XhrApi
 */
new XhrApi();
/**
 * Creates an instance of XhrApi optionally passing options for request
 * @param {CoreOptions} requestOptions Options for request
 * @memberof XhrApi
 */
new XhrApi(requestOptions: CoreOptions); // CoreOptions is from @types/request, part of request pkg
/**
 * Creates an instance of XhrApi. optionally pass true to bypass remote ssl/tls certificate check
 * @param {boolean} allowUntrustedCertificate whether to allow non trusted certificate or not
 * @memberof XhrApi
 */
new XhrApi(allowUntrustedCertificate: boolean);

Proxy server support

import { XhrApi } from "@ewsjs/xhr";

// without proxy credential
let xhr = new XhrApi({ headers: { 'custom-header': 'value' }, rejectUnauthorized: false})
    .useProxy("http://squidorOtherProxyServer:3128");

// with proxy credential
let xhr = new XhrApi({ headers: { 'custom-header': 'value' }, rejectUnauthorized: false})
    .useProxy("http://squidorOtherProxyServer:3128", "proxyUser", "password");

adding Ntlm authentication (or Windows Integrated Authentication with EWS)

import { XhrApi } from "@ewsjs/xhr";
let xhr = new XhrApi()
    .useNtlmAuthentication(credentials.userName, credentials.password);

adding cookies authentication (usage with TMG/ISA)

import { XhrApi } from "@ewsjs/xhr";
let xhr = new XhrApi({ rejectUnauthorized: false})
    .useCookieAuthentication(credentials.userName, credentials.password);

using proxy with cookies authentication

import { XhrApi } from "@ewsjs/xhr";
let xhr = new XhrApi(true)
    .useCookieAuthentication(credentials.userName, credentials.password)
    .useProxy("http://squidorOtherProxyServer:3128", "proxyUser", "password");

Info: No Proxy support with Ntlm (yet!)

There are issues which needs to be sorted out before Ntlm can be used with proxy, this situation is rarly needed in corporate environment anyways.

License

MIT

1.1.1 changes

  • fixed header check to be case insensitive
  • moved header helper method creation to util.js

版本与发布记录

@ewsjs/xhr 共发布 17 个版本,首次发布于 2018/05/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.3latest2024/05/132 年前
3.1.22024/04/232 年前
3.1.12024/03/252 年前
3.1.02024/03/242 年前
3.0.02024/02/252 年前
2.0.22023/12/052 年前

关于 @ewsjs/xhr 的常见问题

@ewsjs/xhr 是什么?

alternate XHR methods for ewsjs

如何安装 @ewsjs/xhr?

在项目目录运行 npm install @ewsjs/xhr,或使用 pnpm add / yarn add / bun add。

@ewsjs/xhr 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ewsjs/xhr 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@ewsjs/xhr 可以商用吗?

@ewsjs/xhr 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ewsjs/xhr 的下载量有多少?

根据 npm 官方下载统计,@ewsjs/xhr 在 2026/10/14 – 2026/11/12 这 30 天内被下载 241,591 次,日均约 8,053 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ewsjs/xhr 还在维护吗?

最新版本 3.1.3 发布于 2024/05/13(2 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/05/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。