node-easywechat 3.7.15 → 3.7.17
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 +8 -0
- package/dist/OfficialAccount/Application.js +4 -2
- package/dist/OpenPlatform/Application.js +9 -4
- package/dist/OpenWork/Application.js +2 -0
- package/dist/Types/global.d.ts +61 -16
- package/dist/Work/Application.js +4 -3
- package/dist/Work/Config.js +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -113,17 +113,19 @@ class Application {
|
|
|
113
113
|
getOAuth() {
|
|
114
114
|
if (!this.oauthFactory) {
|
|
115
115
|
this.oauthFactory = ((app) => {
|
|
116
|
-
return
|
|
116
|
+
return new WeChat_1.WeChat({
|
|
117
117
|
client_id: app.getAccount().getAppId(),
|
|
118
118
|
client_secret: app.getAccount().getSecret(),
|
|
119
119
|
redirect: app.getConfig().get('oauth.redirect_url'),
|
|
120
|
-
})
|
|
120
|
+
});
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
let provider = this.oauthFactory.call(null, this);
|
|
124
124
|
if (!(provider instanceof WeChat_1.WeChat)) {
|
|
125
125
|
throw new Error(`The factory must return a \`BaseProvider\` instance.`);
|
|
126
126
|
}
|
|
127
|
+
provider.withRedirectUrl(this.getConfig().get('oauth.redirect_url'))
|
|
128
|
+
.scopes(this.getConfig().get('oauth.scopes', 'snsapi_userinfo'));
|
|
127
129
|
return provider;
|
|
128
130
|
}
|
|
129
131
|
getTicket() {
|
|
@@ -208,16 +208,18 @@ class Application {
|
|
|
208
208
|
}
|
|
209
209
|
getOAuth() {
|
|
210
210
|
let oauthFactory = ((app) => {
|
|
211
|
-
return
|
|
211
|
+
return new WeChat_1.WeChat({
|
|
212
212
|
client_id: app.getAccount().getAppId(),
|
|
213
213
|
client_secret: app.getAccount().getSecret(),
|
|
214
214
|
redirect: app.getConfig().get('oauth.redirect_url'),
|
|
215
|
-
})
|
|
215
|
+
});
|
|
216
216
|
});
|
|
217
217
|
let provider = oauthFactory.call(null, this);
|
|
218
218
|
if (!(provider instanceof WeChat_1.WeChat)) {
|
|
219
219
|
throw new Error(`The factory must return a \`WeChat\` instance.`);
|
|
220
220
|
}
|
|
221
|
+
provider.withRedirectUrl(this.getConfig().get('oauth.redirect_url'))
|
|
222
|
+
.scopes(this.getConfig().get('oauth.scopes', 'snsapi_userinfo'));
|
|
221
223
|
return provider;
|
|
222
224
|
}
|
|
223
225
|
/**
|
|
@@ -254,6 +256,7 @@ class Application {
|
|
|
254
256
|
config.token = this.config.get('token');
|
|
255
257
|
config.aes_key = this.config.get('aes_key');
|
|
256
258
|
config.http = this.config.get('http', {});
|
|
259
|
+
config.oauth = this.config.get('oauth', {});
|
|
257
260
|
config = new Config_1.default(config);
|
|
258
261
|
}
|
|
259
262
|
else {
|
|
@@ -261,6 +264,7 @@ class Application {
|
|
|
261
264
|
config.set('token', this.config.get('token'));
|
|
262
265
|
config.set('aes_key', this.config.get('aes_key'));
|
|
263
266
|
config.set('http', this.config.get('http', {}));
|
|
267
|
+
config.set('oauth', this.config.get('oauth', {}));
|
|
264
268
|
}
|
|
265
269
|
let app = new Application_1.default(config);
|
|
266
270
|
app.setAccessToken(authorizerAccessToken);
|
|
@@ -282,8 +286,9 @@ class Application {
|
|
|
282
286
|
component_app_id: this.getAccount().getSecret(),
|
|
283
287
|
component_access_token: this.getComponentAccessToken().getToken(),
|
|
284
288
|
},
|
|
285
|
-
redirect:
|
|
286
|
-
}))
|
|
289
|
+
redirect: config.get('oauth.redirect_url'),
|
|
290
|
+
}))
|
|
291
|
+
.scopes(config.get('oauth.scopes', 'snsapi_userinfo'));
|
|
287
292
|
});
|
|
288
293
|
}
|
|
289
294
|
/**
|
|
@@ -287,6 +287,7 @@ class Application {
|
|
|
287
287
|
}))
|
|
288
288
|
.withSuiteTicket(await this.getSuiteTicket().getTicket())
|
|
289
289
|
.withSuiteAccessToken(await suiteAccessToken.getToken())
|
|
290
|
+
.withRedirectUrl(this.getConfig().get('oauth.redirect_url'))
|
|
290
291
|
.scopes(this.getConfig().get('oauth.scopes', 'snsapi_base'));
|
|
291
292
|
}
|
|
292
293
|
async getCorpOAuth(corpId, suiteAccessToken = null) {
|
|
@@ -299,6 +300,7 @@ class Application {
|
|
|
299
300
|
}))
|
|
300
301
|
.withSuiteTicket(await this.getSuiteTicket().getTicket())
|
|
301
302
|
.withSuiteAccessToken(await suiteAccessToken.getToken())
|
|
303
|
+
.withRedirectUrl(this.getConfig().get('oauth.redirect_url'))
|
|
302
304
|
.scopes(this.getConfig().get('oauth.scopes', 'snsapi_base'));
|
|
303
305
|
}
|
|
304
306
|
/**
|
package/dist/Types/global.d.ts
CHANGED
|
@@ -27,21 +27,6 @@ export interface WeixinResponse extends Record<string, any> {
|
|
|
27
27
|
errmsg?: string,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* 公众号网页授权相关配置
|
|
32
|
-
*/
|
|
33
|
-
export interface OauthConfig {
|
|
34
|
-
/**
|
|
35
|
-
* 网页授权权限,可选值:snsapi_userinfo、snsapi_base
|
|
36
|
-
*/
|
|
37
|
-
scope: string;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 网页授权回调地址,完整URL
|
|
41
|
-
*/
|
|
42
|
-
redirect_url: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
30
|
/**
|
|
46
31
|
* 文件缓存相关配置
|
|
47
32
|
*/
|
|
@@ -135,7 +120,17 @@ export interface OfficialAccountConfig extends BaseConfig {
|
|
|
135
120
|
/**
|
|
136
121
|
* 网页授权相关配置
|
|
137
122
|
*/
|
|
138
|
-
oauth?:
|
|
123
|
+
oauth?: {
|
|
124
|
+
/**
|
|
125
|
+
* 网页授权权限,可选值:snsapi_userinfo、snsapi_base,默认:snsapi_userinfo
|
|
126
|
+
*/
|
|
127
|
+
scopes: string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 网页授权回调地址,完整URL
|
|
131
|
+
*/
|
|
132
|
+
redirect_url?: string;
|
|
133
|
+
};
|
|
139
134
|
|
|
140
135
|
/**
|
|
141
136
|
* 是否使用稳定版接口调用凭据,默认:false
|
|
@@ -237,6 +232,21 @@ export interface OpenPlatformConfig extends BaseConfig {
|
|
|
237
232
|
* 开发平台服务端消息加解密密钥 aes_key
|
|
238
233
|
*/
|
|
239
234
|
aes_key?: string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 网页授权相关配置
|
|
238
|
+
*/
|
|
239
|
+
oauth?: {
|
|
240
|
+
/**
|
|
241
|
+
* 网页授权权限,可选值:snsapi_userinfo、snsapi_base,默认:snsapi_userinfo
|
|
242
|
+
*/
|
|
243
|
+
scopes: string;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 网页授权回调地址,完整URL
|
|
247
|
+
*/
|
|
248
|
+
redirect_url?: string;
|
|
249
|
+
};
|
|
240
250
|
}
|
|
241
251
|
|
|
242
252
|
/**
|
|
@@ -248,6 +258,11 @@ export interface WorkConfig extends BaseConfig {
|
|
|
248
258
|
*/
|
|
249
259
|
corp_id?: string;
|
|
250
260
|
|
|
261
|
+
/**
|
|
262
|
+
* 应用ID(AgentId)
|
|
263
|
+
*/
|
|
264
|
+
agent_id?: string;
|
|
265
|
+
|
|
251
266
|
/**
|
|
252
267
|
* 企业微信 secret
|
|
253
268
|
*/
|
|
@@ -262,6 +277,21 @@ export interface WorkConfig extends BaseConfig {
|
|
|
262
277
|
* 企业微信服务端消息加解密密钥 aes_key
|
|
263
278
|
*/
|
|
264
279
|
aes_key?: string;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* 网页授权相关配置
|
|
283
|
+
*/
|
|
284
|
+
oauth?: {
|
|
285
|
+
/**
|
|
286
|
+
* 网页授权权限,可选值:snsapi_privateinfo、snsapi_base,默认:snsapi_base
|
|
287
|
+
*/
|
|
288
|
+
scopes: string;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 网页授权回调地址,完整URL
|
|
292
|
+
*/
|
|
293
|
+
redirect_url?: string;
|
|
294
|
+
};
|
|
265
295
|
}
|
|
266
296
|
|
|
267
297
|
/**
|
|
@@ -297,6 +327,21 @@ export interface OpenWorkConfig extends BaseConfig {
|
|
|
297
327
|
* 企业微信服务端消息加解密密钥 aes_key
|
|
298
328
|
*/
|
|
299
329
|
aes_key?: string;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* 网页授权相关配置
|
|
333
|
+
*/
|
|
334
|
+
oauth?: {
|
|
335
|
+
/**
|
|
336
|
+
* 网页授权权限,可选值:snsapi_privateinfo、snsapi_base,默认:snsapi_base
|
|
337
|
+
*/
|
|
338
|
+
scopes: string;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 网页授权回调地址,完整URL
|
|
342
|
+
*/
|
|
343
|
+
redirect_url?: string;
|
|
344
|
+
};
|
|
300
345
|
}
|
|
301
346
|
|
|
302
347
|
/**
|
package/dist/Work/Application.js
CHANGED
|
@@ -124,9 +124,10 @@ class Application {
|
|
|
124
124
|
if (!(provider instanceof WeWork_1.WeWork)) {
|
|
125
125
|
throw new Error(`The factory must return a \`WeWork\` instance.`);
|
|
126
126
|
}
|
|
127
|
-
provider.withApiAccessToken(await this.getAccessToken().getToken())
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
provider.withApiAccessToken(await this.getAccessToken().getToken())
|
|
128
|
+
.withRedirectUrl(this.getConfig().get('oauth.redirect_url'))
|
|
129
|
+
.scopes(this.getConfig().get('oauth.scopes', 'snsapi_base'));
|
|
130
|
+
let agent_id = parseInt(this.getConfig().get('agent_id')) || null;
|
|
130
131
|
if (agent_id) {
|
|
131
132
|
provider.setAgentId(agent_id);
|
|
132
133
|
}
|
package/dist/Work/Config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-easywechat",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.17",
|
|
4
4
|
"description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"node": ">=15.6.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^20.19.
|
|
25
|
+
"@types/node": "^20.19.43",
|
|
26
26
|
"axios-mock-adapter": "^1.22.0",
|
|
27
27
|
"mocha": "^11.7.6",
|
|
28
28
|
"package-release": "^1.0.4",
|
|
29
29
|
"typescript": "^5.9.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"axios": "^1.
|
|
32
|
+
"axios": "^1.18.0",
|
|
33
33
|
"axios-retry": "^4.5.0",
|
|
34
|
-
"form-data": "^4.0.
|
|
34
|
+
"form-data": "^4.0.6",
|
|
35
35
|
"merge": "^2.1.1",
|
|
36
36
|
"node-socialite": "^1.5.6",
|
|
37
37
|
"qs": "^6.15.2",
|