node-easywechat 3.7.4 → 3.7.5
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 +6 -0
- package/README.md +1 -1
- package/dist/OpenWork/Application.d.ts +17 -0
- package/dist/OpenWork/Application.js +43 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
### 使用说明
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
请参考 [文档](https://hpyer.github.io/node-easywechat/) 来使用。如有需要可以查看 [示例代码](https://github.com/hpyer/node-easywechat-demo/)。如果仍有疑问,请提issue,谢谢~
|
|
24
24
|
|
|
25
25
|
从 `3.x` 起 SDK 中不再内置具体业务的接口,仅封装底层基础部分,如认证、授权和 API 客户端。至于为什么不再封装业务接口,可以查看 [EasyWeChat 给出说明](https://easywechat.com/6.x/introduction.html#不再封装业务接口)。
|
|
26
26
|
|
|
@@ -96,6 +96,23 @@ declare class Application implements ApplicationInterface {
|
|
|
96
96
|
* @returns
|
|
97
97
|
*/
|
|
98
98
|
createPreAuthorizationCode(suiteAccessToken?: SuiteAccessToken): Promise<import("../Types/global").WeixinResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* 生成授权页地址
|
|
101
|
+
* @see https://developer.work.weixin.qq.com/document/path/90597#从服务商网站发起
|
|
102
|
+
* @param callbackUrl 授权后的回调地址
|
|
103
|
+
* @param pre_auth_code 预授权码,不传则系统自动调用 createPreAuthorizationCode 获取
|
|
104
|
+
* @param state
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
createPreAuthorizationUrl(callbackUrl: string, pre_auth_code?: string, state?: string): Promise<string>;
|
|
108
|
+
/**
|
|
109
|
+
* 获取企业永久授权码
|
|
110
|
+
* @see https://developer.work.weixin.qq.com/document/path/90603
|
|
111
|
+
* @param authCode 临时授权码
|
|
112
|
+
* @param suiteAccessToken
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
getPermanentCode(authCode: string, suiteAccessToken?: SuiteAccessToken): Promise<import("../Types/global").WeixinResponse>;
|
|
99
116
|
/**
|
|
100
117
|
* 获取企业授权令牌
|
|
101
118
|
* @param corpId
|
|
@@ -211,6 +211,49 @@ class Application {
|
|
|
211
211
|
}
|
|
212
212
|
return response;
|
|
213
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* 生成授权页地址
|
|
216
|
+
* @see https://developer.work.weixin.qq.com/document/path/90597#从服务商网站发起
|
|
217
|
+
* @param callbackUrl 授权后的回调地址
|
|
218
|
+
* @param pre_auth_code 预授权码,不传则系统自动调用 createPreAuthorizationCode 获取
|
|
219
|
+
* @param state
|
|
220
|
+
* @returns
|
|
221
|
+
*/
|
|
222
|
+
async createPreAuthorizationUrl(callbackUrl, pre_auth_code, state) {
|
|
223
|
+
let optional = {
|
|
224
|
+
pre_auth_code,
|
|
225
|
+
state,
|
|
226
|
+
};
|
|
227
|
+
if (!optional['pre_auth_code']) {
|
|
228
|
+
optional.pre_auth_code = (await this.createPreAuthorizationCode()).pre_auth_code;
|
|
229
|
+
}
|
|
230
|
+
let queries = (0, merge_1.default)({
|
|
231
|
+
suite_id: this.getAccount().getSuiteId(),
|
|
232
|
+
redirect_uri: callbackUrl,
|
|
233
|
+
}, optional);
|
|
234
|
+
return `https://open.work.weixin.qq.com/3rdapp/install?${(0, Utils_1.buildQueryString)(queries)}`;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 获取企业永久授权码
|
|
238
|
+
* @see https://developer.work.weixin.qq.com/document/path/90603
|
|
239
|
+
* @param authCode 临时授权码
|
|
240
|
+
* @param suiteAccessToken
|
|
241
|
+
* @returns
|
|
242
|
+
*/
|
|
243
|
+
async getPermanentCode(authCode, suiteAccessToken = null) {
|
|
244
|
+
if (!suiteAccessToken)
|
|
245
|
+
suiteAccessToken = this.getSuiteAccessToken();
|
|
246
|
+
let response = (await this.getClient().request('post', '/cgi-bin/service/get_permanent_code', {
|
|
247
|
+
params: {
|
|
248
|
+
auth_code: authCode,
|
|
249
|
+
suite_access_token: await suiteAccessToken.getToken(),
|
|
250
|
+
}
|
|
251
|
+
})).toObject();
|
|
252
|
+
if (!response['permanent_code']) {
|
|
253
|
+
throw new Error('Failed to get permanent_code: ' + JSON.stringify(response));
|
|
254
|
+
}
|
|
255
|
+
return response;
|
|
256
|
+
}
|
|
214
257
|
/**
|
|
215
258
|
* 获取企业授权令牌
|
|
216
259
|
* @param corpId
|