node-easywechat 3.5.7 → 3.5.8

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/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v3.5.8 (2023-12-18)
5
+
6
+ - Feat: thirdpartyCode2Session方法重命名为code2Session (#54)
7
+ - Feat: 新增将请求响应类转换为标准http响应类的方法toHttpResponse
8
+
9
+ - Fix: 修复验证器类型错误 (#58)
10
+ - Fix: 修复验证器类型错误的问题 (#56)
11
+ - Fix: 修复ts类型错误
12
+
4
13
  ## v3.5.7 (2023-12-18)
5
14
 
6
15
  - Feat: 企业微信工具类增加encrypt、decrypt加解密方法 (#58)
@@ -1,6 +1,7 @@
1
1
  import { AxiosResponse } from "axios";
2
2
  import { HttpClientFailureJudgeClosure, WeixinResponse } from "../../Types/global";
3
3
  import HttpClientResponseInterface from "./Contracts/HttpClientResponseInterface";
4
+ import Response from "../Http/Response";
4
5
  declare class HttpClientResponse implements HttpClientResponseInterface {
5
6
  protected response: AxiosResponse;
6
7
  protected failureJudge: HttpClientFailureJudgeClosure;
@@ -89,5 +90,9 @@ declare class HttpClientResponse implements HttpClientResponseInterface {
89
90
  getInfo(type?: string): import("axios").InternalAxiosRequestConfig<any>;
90
91
  offsetExists(key: any): Promise<boolean>;
91
92
  offsetGet(key: any): Promise<any>;
93
+ /**
94
+ * 转换为标准的 http 响应类
95
+ */
96
+ toHttpResponse(): Response;
92
97
  }
93
98
  export = HttpClientResponse;
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  const fs_1 = __importDefault(require("fs"));
15
15
  const Utils_1 = require("../Support/Utils");
16
+ const Response_1 = __importDefault(require("../Http/Response"));
16
17
  class HttpClientResponse {
17
18
  constructor(response, failureJudge = null, throwError = false) {
18
19
  this.response = response;
@@ -241,5 +242,11 @@ class HttpClientResponse {
241
242
  return (yield this.toObject())[key] || null;
242
243
  });
243
244
  }
245
+ /**
246
+ * 转换为标准的 http 响应类
247
+ */
248
+ toHttpResponse() {
249
+ return new Response_1.default(this.response.status, this.getHeaders(), this.toString());
250
+ }
244
251
  }
245
252
  module.exports = HttpClientResponse;
@@ -9,6 +9,6 @@ declare class Utils extends BaseUtils {
9
9
  * @param code
10
10
  * @returns
11
11
  */
12
- thirdpartyCode2Session(code: string): Promise<import("../../../Types/global").WeixinResponse>;
12
+ code2Session(code: string): Promise<import("../../../Types/global").WeixinResponse>;
13
13
  }
14
14
  export = Utils;
@@ -24,7 +24,7 @@ class Utils extends Utils_1.default {
24
24
  * @param code
25
25
  * @returns
26
26
  */
27
- thirdpartyCode2Session(code) {
27
+ code2Session(code) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  let client = this.app.getHttpClient();
30
30
  let response = yield client.request('GET', '/sns/component/jscode2session', {
@@ -1,5 +1,5 @@
1
1
  import ValidatorInterface from "./Contracts/ValidatorInterface";
2
- import Request from "../Core/Http/Request";
2
+ import MessageInterface from "../Core/Http/Contracts/MessageInterface";
3
3
  import MerchantInterface from "./Contracts/MerchantInterface";
4
4
  declare class Validator implements ValidatorInterface {
5
5
  protected merchant: MerchantInterface;
@@ -9,6 +9,6 @@ declare class Validator implements ValidatorInterface {
9
9
  static HEADER_SERIAL: string;
10
10
  static HEADER_SIGNATURE: string;
11
11
  constructor(merchant: MerchantInterface);
12
- validate(request: Request): boolean;
12
+ validate(request: MessageInterface): boolean;
13
13
  }
14
14
  export = Validator;
@@ -10,6 +10,7 @@ import OpenPlatformMessage from '../OpenPlatform/Message';
10
10
  import OpenWorkMessage from '../OpenWork/Message';
11
11
  import HttpClientResponseInterface from '../Core/HttpClient/Contracts/HttpClientResponseInterface';
12
12
  import { PublicKey } from "../Core/Support/PublicKey";
13
+ import { IAxiosRetryConfig } from 'axios-retry';
13
14
 
14
15
  /**
15
16
  * 微信接口响应数据格式
@@ -75,7 +76,7 @@ export interface HttpConfig extends AxiosRequestConfig {
75
76
  * 是否抛出异常
76
77
  * @see https://github.com/softonic/axios-retry#options
77
78
  */
78
- retry?: axiosRetry.IAxiosRetryConfig;
79
+ retry?: IAxiosRetryConfig;
79
80
  // retry?: {
80
81
  // /**
81
82
  // * 仅以下状态码重试
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "3.5.7",
3
+ "version": "3.5.8",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {