node-easywechat 3.7.9 → 3.7.11

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,14 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v3.7.11 (2025-09-15)
5
+
6
+ - Fix: 更新依赖包
7
+
8
+ ## v3.7.10 (2025-08-06)
9
+
10
+ - Fix: 更新node-socialite,并调整使用方法
11
+
4
12
  ## v3.7.9 (2025-07-24)
5
13
 
6
14
  - Fix: 更新依赖包,修复安全漏洞
@@ -1,4 +1,4 @@
1
- import ProviderInterface from 'node-socialite/dist/Core/ProviderInterface';
1
+ import { WeChat } from 'node-socialite/dist/Providers/WeChat';
2
2
  import ConfigInterface from '../Core/Contracts/ConfigInterface';
3
3
  import Encryptor from '../Core/Encryptor';
4
4
  import AccessTokenAwareClient from '../Core/HttpClient/AccessTokenAwareClient';
@@ -55,7 +55,7 @@ declare class Application implements ApplicationInterface {
55
55
  */
56
56
  setAccessToken(accessToken: AccessTokenInterface): this;
57
57
  setOAuthFactory(oauthFactory: OfficialAccountOAuthFactory): this;
58
- getOAuth(): ProviderInterface;
58
+ getOAuth(): WeChat;
59
59
  getTicket(): JsApiTicket;
60
60
  /**
61
61
  * 设置JsApiTicket实例
@@ -3,8 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  const merge_1 = __importDefault(require("merge"));
6
- const ProviderInterface_1 = __importDefault(require("node-socialite/dist/Core/ProviderInterface"));
7
- const WeChat_1 = __importDefault(require("node-socialite/dist/Providers/WeChat"));
6
+ const WeChat_1 = require("node-socialite/dist/Providers/WeChat");
8
7
  const Config_1 = __importDefault(require("./Config"));
9
8
  const ConfigInterface_1 = __importDefault(require("../Core/Contracts/ConfigInterface"));
10
9
  const Encryptor_1 = __importDefault(require("../Core/Encryptor"));
@@ -114,7 +113,7 @@ class Application {
114
113
  getOAuth() {
115
114
  if (!this.oauthFactory) {
116
115
  this.oauthFactory = ((app) => {
117
- return (new WeChat_1.default({
116
+ return (new WeChat_1.WeChat({
118
117
  client_id: app.getAccount().getAppId(),
119
118
  client_secret: app.getAccount().getSecret(),
120
119
  redirect: app.getConfig().get('oauth.redirect_url'),
@@ -122,8 +121,8 @@ class Application {
122
121
  });
123
122
  }
124
123
  let provider = this.oauthFactory.call(null, this);
125
- if (!(provider instanceof ProviderInterface_1.default)) {
126
- throw new Error(`The factory must return a \`ProviderInterface\` instance.`);
124
+ if (!(provider instanceof WeChat_1.WeChat)) {
125
+ throw new Error(`The factory must return a \`BaseProvider\` instance.`);
127
126
  }
128
127
  return provider;
129
128
  }
@@ -1,4 +1,3 @@
1
- import ProviderInterface from "node-socialite/dist/Core/ProviderInterface";
2
1
  import CacheInterface from "../../Core/Contracts/CacheInterface";
3
2
  import ConfigInterface from "../../Core/Contracts/ConfigInterface";
4
3
  import AccessTokenAwareClient from "../../Core/HttpClient/AccessTokenAwareClient";
@@ -11,6 +10,7 @@ import { OfficialAccountOAuthFactory } from "../../Types/global";
11
10
  import JsApiTicket from "../JsApiTicket";
12
11
  import Utils from "../Utils";
13
12
  import AccessTokenInterface from "../../Core/Contracts/AccessTokenInterface";
13
+ import { WeChat } from "node-socialite/dist/Providers/WeChat";
14
14
  declare abstract class ApplicationInterface {
15
15
  /**
16
16
  * 获取当前账户实例
@@ -66,7 +66,7 @@ declare abstract class ApplicationInterface {
66
66
  * 获取OAuth实例
67
67
  * @returns
68
68
  */
69
- getOAuth(): ProviderInterface;
69
+ getOAuth(): WeChat;
70
70
  /**
71
71
  * 获取JsApiTicket实例
72
72
  * @returns
@@ -1,4 +1,4 @@
1
- import ProviderInterface from 'node-socialite/dist/Core/ProviderInterface';
1
+ import { WeChat } from 'node-socialite/dist/Providers/WeChat';
2
2
  import ConfigInterface from '../Core/Contracts/ConfigInterface';
3
3
  import Encryptor from '../Core/Encryptor';
4
4
  import AccessTokenAwareClient from '../Core/HttpClient/AccessTokenAwareClient';
@@ -105,7 +105,7 @@ declare class Application implements ApplicationInterface {
105
105
  createPreAuthorizationUrl(callbackUrl: string, optional?: string | {
106
106
  pre_auth_code: string;
107
107
  }): Promise<string>;
108
- getOAuth(): ProviderInterface;
108
+ getOAuth(): WeChat;
109
109
  /**
110
110
  * 根据刷新令牌获取公众号实例
111
111
  * @param appId
@@ -3,8 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  const merge_1 = __importDefault(require("merge"));
6
- const ProviderInterface_1 = __importDefault(require("node-socialite/dist/Core/ProviderInterface"));
7
- const WeChat_1 = __importDefault(require("node-socialite/dist/Providers/WeChat"));
6
+ const WeChat_1 = require("node-socialite/dist/Providers/WeChat");
8
7
  const Config_1 = __importDefault(require("./Config"));
9
8
  const ConfigInterface_1 = __importDefault(require("../Core/Contracts/ConfigInterface"));
10
9
  const Encryptor_1 = __importDefault(require("../Core/Encryptor"));
@@ -209,15 +208,15 @@ class Application {
209
208
  }
210
209
  getOAuth() {
211
210
  let oauthFactory = ((app) => {
212
- return (new WeChat_1.default({
211
+ return (new WeChat_1.WeChat({
213
212
  client_id: app.getAccount().getAppId(),
214
213
  client_secret: app.getAccount().getSecret(),
215
214
  redirect: app.getConfig().get('oauth.redirect_url'),
216
215
  })).scopes(this.getConfig().get('oauth.scopes', 'snsapi_userinfo'));
217
216
  });
218
217
  let provider = oauthFactory.call(null, this);
219
- if (!(provider instanceof ProviderInterface_1.default)) {
220
- throw new Error(`The factory must return a \`ProviderInterface\` instance.`);
218
+ if (!(provider instanceof WeChat_1.WeChat)) {
219
+ throw new Error(`The factory must return a \`WeChat\` instance.`);
221
220
  }
222
221
  return provider;
223
222
  }
@@ -277,7 +276,7 @@ class Application {
277
276
  */
278
277
  createAuthorizerOAuthFactory(authorizerAppId, config) {
279
278
  return ((app) => {
280
- return (new WeChat_1.default({
279
+ return (new WeChat_1.WeChat({
281
280
  client_id: authorizerAppId,
282
281
  component: {
283
282
  component_app_id: this.getAccount().getSecret(),
@@ -1,4 +1,3 @@
1
- import ProviderInterface from "node-socialite/dist/Core/ProviderInterface";
2
1
  import CacheInterface from "../../Core/Contracts/CacheInterface";
3
2
  import ConfigInterface from "../../Core/Contracts/ConfigInterface";
4
3
  import AccessTokenAwareClient from "../../Core/HttpClient/AccessTokenAwareClient";
@@ -8,6 +7,7 @@ import ServerRequestInterface from "../../Core/Http/Contracts/ServerRequestInter
8
7
  import Encryptor from "../../Core/Encryptor";
9
8
  import AccountInterface from "./AccountInterface";
10
9
  import AccessTokenInterface from "../../Core/Contracts/AccessTokenInterface";
10
+ import { WeChat } from "node-socialite/dist/Providers/WeChat";
11
11
  declare abstract class ApplicationInterface {
12
12
  /**
13
13
  * 获取当前账户实例
@@ -63,6 +63,6 @@ declare abstract class ApplicationInterface {
63
63
  * 获取OAuth实例
64
64
  * @returns
65
65
  */
66
- getOAuth(): ProviderInterface;
66
+ getOAuth(): WeChat;
67
67
  }
68
68
  export = ApplicationInterface;
@@ -1,4 +1,4 @@
1
- import ProviderInterface from 'node-socialite/dist/Core/ProviderInterface';
1
+ import { OpenWeWork } from 'node-socialite/dist/Providers/OpenWeWork';
2
2
  import ConfigInterface from '../Core/Contracts/ConfigInterface';
3
3
  import Encryptor from './Encryptor';
4
4
  import AccessTokenAwareClient from '../Core/HttpClient/AccessTokenAwareClient';
@@ -124,8 +124,8 @@ declare class Application implements ApplicationInterface {
124
124
  createClient(): AccessTokenAwareClient;
125
125
  getAuthorizerClient(corpId: string, permanentCode: string, suiteAccessToken?: SuiteAccessToken): Promise<AccessTokenAwareClient>;
126
126
  getJsApiTicket(corpId: string, permanentCode: string, suiteAccessToken?: SuiteAccessToken): Promise<JsApiTicket>;
127
- getOAuth(suiteId: string, suiteAccessToken?: SuiteAccessToken): Promise<ProviderInterface>;
128
- getCorpOAuth(corpId: string, suiteAccessToken?: SuiteAccessToken): Promise<ProviderInterface>;
127
+ getOAuth(suiteId: string, suiteAccessToken?: SuiteAccessToken): Promise<OpenWeWork>;
128
+ getCorpOAuth(corpId: string, suiteAccessToken?: SuiteAccessToken): Promise<OpenWeWork>;
129
129
  /**
130
130
  * 获取请求默认配置
131
131
  * @returns
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  const merge_1 = __importDefault(require("merge"));
6
- const OpenWeWork_1 = __importDefault(require("node-socialite/dist/Providers/OpenWeWork"));
6
+ const OpenWeWork_1 = require("node-socialite/dist/Providers/OpenWeWork");
7
7
  const Config_1 = __importDefault(require("./Config"));
8
8
  const ConfigInterface_1 = __importDefault(require("../Core/Contracts/ConfigInterface"));
9
9
  const Encryptor_1 = __importDefault(require("./Encryptor"));
@@ -280,7 +280,7 @@ class Application {
280
280
  async getOAuth(suiteId, suiteAccessToken = null) {
281
281
  if (!suiteAccessToken)
282
282
  suiteAccessToken = this.getSuiteAccessToken();
283
- return (new OpenWeWork_1.default({
283
+ return (new OpenWeWork_1.OpenWeWork({
284
284
  client_id: suiteId,
285
285
  client_secret: '',
286
286
  redirect: this.getConfig().get('oauth.redirect_url'),
@@ -292,7 +292,7 @@ class Application {
292
292
  async getCorpOAuth(corpId, suiteAccessToken = null) {
293
293
  if (!suiteAccessToken)
294
294
  suiteAccessToken = this.getSuiteAccessToken();
295
- return (new OpenWeWork_1.default({
295
+ return (new OpenWeWork_1.OpenWeWork({
296
296
  client_id: corpId,
297
297
  client_secret: '',
298
298
  redirect: this.getConfig().get('oauth.redirect_url'),
@@ -1,4 +1,3 @@
1
- import ProviderInterface from "node-socialite/dist/Core/ProviderInterface";
2
1
  import CacheInterface from "../../Core/Contracts/CacheInterface";
3
2
  import ConfigInterface from "../../Core/Contracts/ConfigInterface";
4
3
  import AccessTokenAwareClient from "../../Core/HttpClient/AccessTokenAwareClient";
@@ -12,6 +11,7 @@ import AccessTokenInterface from "../../Core/Contracts/AccessTokenInterface";
12
11
  import SuiteTicketInterface from "./SuiteTicketInterface";
13
12
  import SuiteAccessToken from "../SuiteAccessToken";
14
13
  import JsApiTicket from "../JsApiTicket";
14
+ import { OpenWeWork } from "node-socialite/dist/Providers/OpenWeWork";
15
15
  declare abstract class ApplicationInterface {
16
16
  /**
17
17
  * 获取当前账户实例
@@ -95,7 +95,7 @@ declare abstract class ApplicationInterface {
95
95
  * @https://developer.work.weixin.qq.com/document/path/91120#构造第三方应用oauth2链接
96
96
  * @returns
97
97
  */
98
- getOAuth(suiteId: string, suiteAccessToken?: SuiteAccessToken): Promise<ProviderInterface>;
98
+ getOAuth(suiteId: string, suiteAccessToken?: SuiteAccessToken): Promise<OpenWeWork>;
99
99
  /**
100
100
  * 获取企业的OAuth实例
101
101
  * @param corpId
@@ -103,6 +103,6 @@ declare abstract class ApplicationInterface {
103
103
  * @see https://developer.work.weixin.qq.com/document/path/91120#构造企业oauth2链接
104
104
  * @returns
105
105
  */
106
- getCorpOAuth(corpId: string, suiteAccessToken?: SuiteAccessToken): Promise<ProviderInterface>;
106
+ getCorpOAuth(corpId: string, suiteAccessToken?: SuiteAccessToken): Promise<OpenWeWork>;
107
107
  }
108
108
  export = ApplicationInterface;
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import ProviderInterface from 'node-socialite/dist/Core/ProviderInterface';
2
+ import { BaseProvider } from 'node-socialite';
3
3
  import OfficialAccountApplicationInterface from '../OfficialAccount/Contracts/ApplicationInterface';
4
4
  import WorkApplicationInterface from '../Work/Contracts/ApplicationInterface';
5
5
  import Message from '../Core/Message';
@@ -304,14 +304,14 @@ export interface OpenWorkConfig extends BaseConfig {
304
304
  * @param app 公众号应用实例
305
305
  * @returns OAuth服务供应商实例
306
306
  */
307
- export type OfficialAccountOAuthFactory = (app: OfficialAccountApplicationInterface) => ProviderInterface;
307
+ export type OfficialAccountOAuthFactory = (app: OfficialAccountApplicationInterface) => BaseProvider;
308
308
 
309
309
  /**
310
310
  * 企业微信OAuth工厂方法
311
311
  * @param app 企业微信应用实例
312
312
  * @returns OAuth服务供应商实例
313
313
  */
314
- export type WorkOAuthFactory = (app: WorkApplicationInterface) => ProviderInterface;
314
+ export type WorkOAuthFactory = (app: WorkApplicationInterface) => BaseProvider;
315
315
 
316
316
  /**
317
317
  * 服务端通知处理项
@@ -1,4 +1,4 @@
1
- import ProviderInterface from 'node-socialite/dist/Core/ProviderInterface';
1
+ import { WeWork } from 'node-socialite/dist/Providers/WeWork';
2
2
  import ConfigInterface from '../Core/Contracts/ConfigInterface';
3
3
  import Encryptor from './Encryptor';
4
4
  import AccessTokenAwareClient from '../Core/HttpClient/AccessTokenAwareClient';
@@ -55,7 +55,7 @@ declare class Application implements ApplicationInterface {
55
55
  */
56
56
  setAccessToken(accessToken: AccessTokenInterface): this;
57
57
  setOAuthFactory(oauthFactory: WorkOAuthFactory): this;
58
- getOAuth(): Promise<ProviderInterface>;
58
+ getOAuth(): Promise<WeWork>;
59
59
  getTicket(): JsApiTicket;
60
60
  /**
61
61
  * 设置JsApiTicket实例
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  const merge_1 = __importDefault(require("merge"));
6
- const WeWork_1 = __importDefault(require("node-socialite/dist/Providers/WeWork"));
6
+ const WeWork_1 = require("node-socialite/dist/Providers/WeWork");
7
7
  const Config_1 = __importDefault(require("./Config"));
8
8
  const ConfigInterface_1 = __importDefault(require("../Core/Contracts/ConfigInterface"));
9
9
  const Encryptor_1 = __importDefault(require("./Encryptor"));
@@ -113,7 +113,7 @@ class Application {
113
113
  async getOAuth() {
114
114
  if (!this.oauthFactory) {
115
115
  this.oauthFactory = ((app) => {
116
- return new WeWork_1.default({
116
+ return new WeWork_1.WeWork({
117
117
  client_id: app.getAccount().getCorpId(),
118
118
  client_secret: app.getAccount().getSecret(),
119
119
  redirect: app.getConfig().get('oauth.redirect_url'),
@@ -121,8 +121,8 @@ class Application {
121
121
  });
122
122
  }
123
123
  let provider = this.oauthFactory.call(null, this);
124
- if (!(provider instanceof WeWork_1.default)) {
125
- throw new Error(`The factory must return a \`ProviderInterface\` instance.`);
124
+ if (!(provider instanceof WeWork_1.WeWork)) {
125
+ throw new Error(`The factory must return a \`WeWork\` instance.`);
126
126
  }
127
127
  provider.withApiAccessToken(await this.getAccessToken().getToken());
128
128
  provider.scopes(this.getConfig().get('oauth.scopes', 'snsapi_userinfo'));
@@ -1,4 +1,3 @@
1
- import ProviderInterface from "node-socialite/dist/Core/ProviderInterface";
2
1
  import CacheInterface from "../../Core/Contracts/CacheInterface";
3
2
  import ConfigInterface from "../../Core/Contracts/ConfigInterface";
4
3
  import AccessTokenAwareClient from "../../Core/HttpClient/AccessTokenAwareClient";
@@ -11,6 +10,7 @@ import { WorkOAuthFactory } from "../../Types/global";
11
10
  import JsApiTicket from "../JsApiTicket";
12
11
  import Utils from "../Utils";
13
12
  import AccessTokenInterface from "../../Core/Contracts/AccessTokenInterface";
13
+ import { WeWork } from "node-socialite/dist/Providers/WeWork";
14
14
  declare abstract class ApplicationInterface {
15
15
  /**
16
16
  * 获取当前账户实例
@@ -66,7 +66,7 @@ declare abstract class ApplicationInterface {
66
66
  * 获取OAuth实例
67
67
  * @returns
68
68
  */
69
- getOAuth(): Promise<ProviderInterface>;
69
+ getOAuth(): Promise<WeWork>;
70
70
  /**
71
71
  * 获取JsApiTicket实例
72
72
  * @returns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "3.7.9",
3
+ "version": "3.7.11",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -22,21 +22,20 @@
22
22
  "node": ">=15.6.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "^20.19.9",
25
+ "@types/node": "^20.19.14",
26
26
  "axios-mock-adapter": "^1.22.0",
27
- "mocha": "^11.7.1",
27
+ "mocha": "^11.7.2",
28
28
  "package-release": "^1.0.4",
29
- "typescript": "^5.8.3"
29
+ "typescript": "^5.9.2"
30
30
  },
31
31
  "dependencies": {
32
- "axios": "^1.11.0",
32
+ "axios": "^1.12.2",
33
33
  "axios-retry": "^4.5.0",
34
34
  "form-data": "^4.0.4",
35
35
  "merge": "^2.1.1",
36
- "node-socialite": "^1.4.3",
36
+ "node-socialite": "^1.5.2",
37
37
  "qs": "^6.14.0",
38
38
  "raw-body": "^2.5.2",
39
39
  "xml2js": "^0.6.2"
40
- },
41
- "packageManager": "pnpm@10.12.4+sha512.5ea8b0deed94ed68691c9bad4c955492705c5eeb8a87ef86bc62c74a26b037b08ff9570f108b2e4dbd1dd1a9186fea925e527f141c648e85af45631074680184"
40
+ }
42
41
  }
@@ -1,21 +0,0 @@
1
- # 2.x 所有提交自动构建并测试
2
-
3
- name: Build 2.x
4
-
5
- on:
6
- push:
7
- branches:
8
- - '2.x'
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm install
19
- - run: npm run build
20
- - run: npm test
21
-
@@ -1,26 +0,0 @@
1
- # 构建、测试并发布2.x分支
2
-
3
- name: Publish 2.x to npm
4
-
5
- on:
6
- push:
7
- tags:
8
- - v2.*
9
-
10
- jobs:
11
- publish-npm:
12
- runs-on: ubuntu-latest
13
- permissions:
14
- id-token: write
15
- steps:
16
- - uses: actions/checkout@v3
17
- - uses: actions/setup-node@v3
18
- with:
19
- node-version: 22
20
- registry-url: https://registry.npmjs.org/
21
- - run: npm install
22
- - run: npm run build
23
- - run: npm test
24
- - run: npm publish --tag second --provenance --access public
25
- env:
26
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}