node-easywechat 2.9.3 → 2.9.4
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 +178 -0
- package/README.md +1 -1
- package/dist/Core/BaseAccessToken.d.ts +9 -2
- package/dist/Core/BaseAccessToken.js +22 -9
- package/dist/OpenPlatform/Auth/AccessToken.d.ts +3 -2
- package/dist/OpenPlatform/Auth/AccessToken.js +27 -6
- package/dist/OpenPlatform/Authorizer/Auth/AccessToken.d.ts +3 -2
- package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +28 -6
- package/dist/OpenWork/Auth/ProviderAccessToken.d.ts +2 -1
- package/dist/OpenWork/Auth/ProviderAccessToken.js +25 -4
- package/dist/OpenWork/Auth/SuiteAccessToken.d.ts +2 -1
- package/dist/OpenWork/Auth/SuiteAccessToken.js +25 -4
- package/node-easywechat.file_cache.easywechat.kernel.access_token.0b91a4a397e7de4df604574db3ecfbf9.cache +1 -0
- package/node-easywechat.file_cache.easywechat.kernel.provider_access_token.ee7599901778506be40c39a76a077a37.cache +1 -0
- package/node-easywechat.file_cache.easywechat.kernel.suite_access_token.9cf5f200d41129506edd6b7cff9c6543.cache +1 -0
- package/node-easywechat.file_cache.easywechat.open_platform.verify_ticket.mock-app_id.cache +1 -0
- package/node-easywechat.file_cache.easywechat.open_work.suite_ticket.mock-suite_id.cache +1 -0
- package/package.json +3 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## v2.9.4 (2022-04-22)
|
|
5
|
+
|
|
6
|
+
- Fix: 修复开放平台、企业微信开放平台获取授权AccessToken异常的问题 (#18)
|
|
7
|
+
|
|
8
|
+
## v2.9.3 (2022-03-25)
|
|
9
|
+
|
|
10
|
+
- Fix: 修复发送图文客服消息失败的问题 (#17)
|
|
11
|
+
|
|
12
|
+
## v2.9.2 (2022-03-23)
|
|
13
|
+
|
|
14
|
+
- Feat: 新增企业微信客户群「加入群聊」管理相关接口
|
|
15
|
+
- Feat: 新增物流服务退货相关接口
|
|
16
|
+
- Feat: 新增获取订单列表接口
|
|
17
|
+
- Feat: 新增小程序绑定、解绑物流账号接口
|
|
18
|
+
- Feat: 增加查询openAPI调用次数
|
|
19
|
+
|
|
20
|
+
- Docs: 移除api文档
|
|
21
|
+
|
|
22
|
+
## v2.9.1 (2022-02-09)
|
|
23
|
+
|
|
24
|
+
## v2.9.0 (2022-01-28)
|
|
25
|
+
|
|
26
|
+
- Feat: 新增企业微信开放平台
|
|
27
|
+
|
|
28
|
+
- Fix: 修复开放平台构建移动端授权链接的方法
|
|
29
|
+
- Fix: 调整消息通知处理类的方法作用域
|
|
30
|
+
|
|
31
|
+
## v2.8.3 (2022-01-20)
|
|
32
|
+
|
|
33
|
+
- Feat: 小程序新增自定义版交易组件及开放接口
|
|
34
|
+
|
|
35
|
+
## v2.8.2 (2022-01-12)
|
|
36
|
+
|
|
37
|
+
- Feat: 企业微信朋友圈优化相关接口
|
|
38
|
+
- Feat: 企业微信增加上传附件资源接口
|
|
39
|
+
- Feat: 新增企业微信客服相关接口
|
|
40
|
+
- Feat: 优化企业微信群聊数据统计相关接口
|
|
41
|
+
- Feat: 优化客户联系「联系我」相关接口
|
|
42
|
+
- Feat: 完善企业互联相关接口
|
|
43
|
+
- Feat: 新增应用工作台相关接口
|
|
44
|
+
|
|
45
|
+
## v2.8.1 (2022-01-07)
|
|
46
|
+
|
|
47
|
+
- Feat: 增加获取小程序短链接功能
|
|
48
|
+
- Feat: 新增企业微信客户id转换相关接口
|
|
49
|
+
|
|
50
|
+
## v2.8.0 (2022-01-06)
|
|
51
|
+
|
|
52
|
+
- Feat: 新增小程序获取用户手机号功能
|
|
53
|
+
- Feat: 微信支付jssdk增加生成联系人配置和小程序红包配置
|
|
54
|
+
- Feat: 增加小程序联盟定向计划推广接口
|
|
55
|
+
- Feat: 企业微信新增群发相关接口
|
|
56
|
+
- Feat: 新增小程序链接模块
|
|
57
|
+
- Feat: 企业微信获取客户群详情增加need_name参数
|
|
58
|
+
|
|
59
|
+
- Fix: 修复批量获取客户详情参数错误
|
|
60
|
+
|
|
61
|
+
## v2.7.2 (2021-10-01)
|
|
62
|
+
|
|
63
|
+
- Fix: 修复自动回复消息格式异常的问题 (#13)
|
|
64
|
+
|
|
65
|
+
## v2.7.1 (2021-09-08)
|
|
66
|
+
|
|
67
|
+
## v2.7.0 (2021-08-31)
|
|
68
|
+
|
|
69
|
+
- Feat: 新增小微商户相关接口
|
|
70
|
+
|
|
71
|
+
- Fix: 重命名RSA加密解密文件
|
|
72
|
+
- Fix: 移除无效文件
|
|
73
|
+
- Fix: 封装构建xml的方法
|
|
74
|
+
|
|
75
|
+
## v2.6.10 (2021-08-03)
|
|
76
|
+
|
|
77
|
+
- Fix: 配置项中增加debug参数,以控制是否显示日志 (#12)
|
|
78
|
+
|
|
79
|
+
## v2.6.9 (2021-07-29)
|
|
80
|
+
|
|
81
|
+
- Feat: 新增获取所有绑定的物流账号
|
|
82
|
+
|
|
83
|
+
- Fix: 修复提现到零钱时签名错误的问题 (#10)
|
|
84
|
+
|
|
85
|
+
## v2.6.8 (2021-07-13)
|
|
86
|
+
|
|
87
|
+
- Feat: 新增发送小程序红包接口
|
|
88
|
+
- Feat: 补全客户联系相关接口
|
|
89
|
+
|
|
90
|
+
## v2.6.7 (2021-07-02)
|
|
91
|
+
|
|
92
|
+
- Feat: 新增获取小程序启动性能,运行性能等数据的接口
|
|
93
|
+
- Feat: 增加小程序联盟查询联盟精选商品接口
|
|
94
|
+
- Feat: 增加开放平台小程序代码模板template_type参数
|
|
95
|
+
|
|
96
|
+
- Fix: 修复小程序风控接口请求异常的问题
|
|
97
|
+
- Fix: 修复获取资源时错误信息的反馈异常的问题
|
|
98
|
+
- Fix: 企业微信新增上传永久图片、获取高清语音素材接口
|
|
99
|
+
|
|
100
|
+
## v2.6.6 (2021-06-01)
|
|
101
|
+
|
|
102
|
+
- Feat: 新增消息类型interactive_taskcard和update_taskcard
|
|
103
|
+
|
|
104
|
+
## v2.6.5 (2021-05-21)
|
|
105
|
+
|
|
106
|
+
- Fix: 添加markdown和miniprogram_notice两种消息类型 (#9)
|
|
107
|
+
|
|
108
|
+
## v2.6.4 (2021-05-20)
|
|
109
|
+
|
|
110
|
+
- Fix: 修复获取企业微信accesstoken异常的问题
|
|
111
|
+
|
|
112
|
+
## v2.6.3 (2021-05-19)
|
|
113
|
+
|
|
114
|
+
- Feat: 新增公众号订阅消息功能
|
|
115
|
+
|
|
116
|
+
- Fix: 增加小程序订阅消息的小程序类型参数,默认正式版
|
|
117
|
+
|
|
118
|
+
## v2.6.2 (2021-04-28)
|
|
119
|
+
|
|
120
|
+
- Feat: 新增小程序联盟相关接口
|
|
121
|
+
- Feat: 新增入群欢迎语素材管理
|
|
122
|
+
- Feat: 完善OCR识别相关接口
|
|
123
|
+
|
|
124
|
+
## v2.6.1 (2021-04-13)
|
|
125
|
+
|
|
126
|
+
- Feat: 增加声明配置项的方法
|
|
127
|
+
|
|
128
|
+
- Fix: 取消企业微信中消息回复时media_id的必填设置
|
|
129
|
+
|
|
130
|
+
## v2.6.0 (2021-03-22)
|
|
131
|
+
|
|
132
|
+
- Feat: 新增小程序直播相关接口
|
|
133
|
+
- Feat: 新增小程序风险控制相关接口
|
|
134
|
+
- Feat: 新增小程序scheme码相关接口
|
|
135
|
+
- Feat: 移除EasyWechat.Message
|
|
136
|
+
- Feat: 网页授权模块改用node-socialite
|
|
137
|
+
- Feat: 将request模块替换为axios
|
|
138
|
+
- Feat: 添加企业微信模块
|
|
139
|
+
- Feat: 完善企业微信接口
|
|
140
|
+
- Feat: 新增企业微信的网页授权功能
|
|
141
|
+
- Feat: 添加小程序相关接口
|
|
142
|
+
- Feat: 注册已添加的企业微信接口
|
|
143
|
+
- Feat: 新增企业微信群机器人接口
|
|
144
|
+
- Feat: 新增企业微信日程管理接口
|
|
145
|
+
- Feat: 增加企业微信的服务端消息处理功能
|
|
146
|
+
- Feat: 增加企业微信回话内容模块
|
|
147
|
+
- Feat: 增加企业微信的消息处理功能
|
|
148
|
+
- Feat: 增加企业微信的用户管理、用户标签管理
|
|
149
|
+
|
|
150
|
+
- Fix: 取消发送企业微信新客户欢迎语时的media_id必填限制
|
|
151
|
+
- Fix: 修复变量错误的问题
|
|
152
|
+
- Fix: 修复企业微信消息继承类错误的问题
|
|
153
|
+
- Fix: 修复网页授权的功能,提升各模块的兼容性
|
|
154
|
+
- Fix: OAuth支持设置code和AccessToken
|
|
155
|
+
- Fix: 修复类名错误
|
|
156
|
+
- Fix: 调整变量类型
|
|
157
|
+
- Fix: 调整公众号服务端判断是否为接口验证请求的逻辑
|
|
158
|
+
- Fix: 优化微信支付的一些小问题
|
|
159
|
+
- Fix: 补充微信支付的沙盒模式参数
|
|
160
|
+
- Fix: 修复支付时签约的接口地址异常问题
|
|
161
|
+
- Fix: 修复非签约时统一下单接口地址有误的问题 #6
|
|
162
|
+
- Fix: 修复微信支付通知中,业务逻辑有异常时无法返回正确结果的问题
|
|
163
|
+
- Fix: 优化AES加密解密方法
|
|
164
|
+
- Fix: 增加支持设置xml格式的request内容
|
|
165
|
+
- Fix: 修复存在默认值导致读取请求内容异常的情况 #5
|
|
166
|
+
- Fix: 当请求url包含域名时,则忽略base_url
|
|
167
|
+
- Fix: 避免变量冲突导致异常
|
|
168
|
+
- Fix: 修复无法合并类实例对象的问题
|
|
169
|
+
- Fix: 移除merge依赖包
|
|
170
|
+
|
|
171
|
+
- Docs: 修改注释
|
|
172
|
+
|
|
173
|
+
- Perf: 优化服务端通知的回调函数提醒
|
|
174
|
+
- Perf: 优化文件缓存操作类
|
|
175
|
+
- Perf: 优化返回this的类型推导
|
|
176
|
+
- Perf: 调整测试用例框架结构,完善测试用例中的类型推导
|
|
177
|
+
- Perf: 调整总对象实现方式,优化服务类型推导
|
|
178
|
+
- Perf: 增加配置类型声明、精简代码(如去除“* as”、配置项改为".xx"方式)
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
## EasyWechat for Node.js
|
|
3
3
|
|
|
4
|
-
[](https://app.travis-ci.com/hpyer/node-easywechat) [](https://www.npmjs.com/package/node-easywechat) [](LICENSE)
|
|
5
5
|
|
|
6
6
|
**注:2.x分支针对 EasyWechat 的 5.x版本(由于4.x与5.x的结构基本一致,就不升级大版本了)。**
|
|
7
7
|
|
|
@@ -25,11 +25,11 @@ export declare class AccessToken {
|
|
|
25
25
|
* 授权的作用域
|
|
26
26
|
*/
|
|
27
27
|
scope: string;
|
|
28
|
-
constructor(info?: object);
|
|
28
|
+
constructor(info?: object, keysMap?: Record<string, string>);
|
|
29
29
|
/**
|
|
30
30
|
* 获取access_token
|
|
31
31
|
*/
|
|
32
|
-
getToken(): string
|
|
32
|
+
getToken(): string;
|
|
33
33
|
/**
|
|
34
34
|
* 获取access_token
|
|
35
35
|
*/
|
|
@@ -57,6 +57,7 @@ declare abstract class BaseAccessToken implements HttpMixin {
|
|
|
57
57
|
protected queryName: string;
|
|
58
58
|
protected tokenKey: string;
|
|
59
59
|
protected endpointToGetToken: string;
|
|
60
|
+
protected cachePrefix: string;
|
|
60
61
|
protected app: BaseApplication;
|
|
61
62
|
constructor(app: BaseApplication);
|
|
62
63
|
protected getCredentials(): Promise<object>;
|
|
@@ -68,6 +69,12 @@ declare abstract class BaseAccessToken implements HttpMixin {
|
|
|
68
69
|
* @param refresh 为true时表示强制刷新
|
|
69
70
|
*/
|
|
70
71
|
getToken(refresh?: boolean): Promise<AccessToken>;
|
|
72
|
+
/**
|
|
73
|
+
* 包装为授权后的 AccessToken 对象
|
|
74
|
+
* @param token 接口返回的数据
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
protected warpAccessToken(token: Record<string, any>): AccessToken;
|
|
71
78
|
/**
|
|
72
79
|
* 设置Token
|
|
73
80
|
* @param access_token AccessToken
|
|
@@ -19,7 +19,7 @@ const Utils_1 = require("./Utils");
|
|
|
19
19
|
* 授权后的AccessToken对象
|
|
20
20
|
*/
|
|
21
21
|
class AccessToken {
|
|
22
|
-
constructor(info = null) {
|
|
22
|
+
constructor(info = null, keysMap = {}) {
|
|
23
23
|
/**
|
|
24
24
|
* 网页授权接口调用凭证
|
|
25
25
|
*/
|
|
@@ -41,11 +41,15 @@ class AccessToken {
|
|
|
41
41
|
*/
|
|
42
42
|
this.scope = null;
|
|
43
43
|
if (info) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
Object.keys(info).map(key => {
|
|
45
|
+
this[key] = info[key] || info[(0, Utils_1.strCamel)(key)] || '';
|
|
46
|
+
});
|
|
47
|
+
if (keysMap) {
|
|
48
|
+
Object.keys(keysMap).map(key => {
|
|
49
|
+
let mapKey = keysMap[key];
|
|
50
|
+
this[key] = info[mapKey] || info[(0, Utils_1.strCamel)(mapKey)] || '';
|
|
51
|
+
});
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
@@ -94,6 +98,7 @@ class BaseAccessToken {
|
|
|
94
98
|
this.queryName = '';
|
|
95
99
|
this.tokenKey = 'access_token';
|
|
96
100
|
this.endpointToGetToken = '';
|
|
101
|
+
this.cachePrefix = 'easywechat.kernel.access_token.';
|
|
97
102
|
this.app = null;
|
|
98
103
|
this.app = app;
|
|
99
104
|
}
|
|
@@ -112,7 +117,7 @@ class BaseAccessToken {
|
|
|
112
117
|
}
|
|
113
118
|
getCacheKey() {
|
|
114
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
return
|
|
120
|
+
return this.cachePrefix + (0, Utils_1.createHash)(JSON.stringify(yield this.getCredentials()), 'md5');
|
|
116
121
|
});
|
|
117
122
|
}
|
|
118
123
|
requestToken(credentials) {
|
|
@@ -143,13 +148,21 @@ class BaseAccessToken {
|
|
|
143
148
|
if (!refresh && (yield cache.has(cacheKey))) {
|
|
144
149
|
let token = yield cache.get(cacheKey);
|
|
145
150
|
if (token)
|
|
146
|
-
return
|
|
151
|
+
return this.warpAccessToken(token);
|
|
147
152
|
}
|
|
148
153
|
let res = yield this.requestToken(yield this.getCredentials());
|
|
149
154
|
yield this.setToken(res, res.expires_in || 7200);
|
|
150
|
-
return res;
|
|
155
|
+
return this.warpAccessToken(res);
|
|
151
156
|
});
|
|
152
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* 包装为授权后的 AccessToken 对象
|
|
160
|
+
* @param token 接口返回的数据
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
warpAccessToken(token) {
|
|
164
|
+
return new AccessToken(token);
|
|
165
|
+
}
|
|
153
166
|
/**
|
|
154
167
|
* 设置Token
|
|
155
168
|
* @param access_token AccessToken
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import BaseAccessToken from '../../Core/BaseAccessToken';
|
|
2
|
-
export default class
|
|
1
|
+
import BaseAccessToken, { AccessToken } from '../../Core/BaseAccessToken';
|
|
2
|
+
export default class AuthAccessToken extends BaseAccessToken {
|
|
3
3
|
protected requestMethod: string;
|
|
4
4
|
protected tokenKey: string;
|
|
5
5
|
protected endpointToGetToken: string;
|
|
6
|
+
protected warpAccessToken(token: Record<string, any>): AccessToken;
|
|
6
7
|
protected getCredentials(): Promise<object>;
|
|
7
8
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,18 +27,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const BaseAccessToken_1 =
|
|
16
|
-
class
|
|
31
|
+
const BaseAccessToken_1 = __importStar(require("../../Core/BaseAccessToken"));
|
|
32
|
+
class AuthAccessToken extends BaseAccessToken_1.default {
|
|
17
33
|
constructor() {
|
|
18
34
|
super(...arguments);
|
|
19
35
|
this.requestMethod = 'POST';
|
|
20
36
|
this.tokenKey = 'component_access_token';
|
|
21
37
|
this.endpointToGetToken = 'cgi-bin/component/api_component_token';
|
|
22
38
|
}
|
|
39
|
+
warpAccessToken(token) {
|
|
40
|
+
return new BaseAccessToken_1.AccessToken(token, {
|
|
41
|
+
access_token: 'component_access_token',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
23
44
|
getCredentials() {
|
|
24
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
46
|
return {
|
|
@@ -30,4 +51,4 @@ class AccessToken extends BaseAccessToken_1.default {
|
|
|
30
51
|
});
|
|
31
52
|
}
|
|
32
53
|
}
|
|
33
|
-
exports.default =
|
|
54
|
+
exports.default = AuthAccessToken;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import BaseAccessToken from '../../../Core/BaseAccessToken';
|
|
1
|
+
import BaseAccessToken, { AccessToken } from '../../../Core/BaseAccessToken';
|
|
2
2
|
import OpenPlatformApplication from '../../Application';
|
|
3
3
|
import BaseApplicatioin from '../../../Core/BaseApplication';
|
|
4
|
-
export default class
|
|
4
|
+
export default class AuthAccessToken extends BaseAccessToken {
|
|
5
5
|
protected requestMethod: string;
|
|
6
6
|
protected queryName: string;
|
|
7
7
|
protected tokenKey: string;
|
|
8
8
|
protected component: OpenPlatformApplication;
|
|
9
9
|
constructor(app: BaseApplicatioin, component: OpenPlatformApplication);
|
|
10
|
+
protected warpAccessToken(token: Record<string, any>): AccessToken;
|
|
10
11
|
protected getCredentials(): Promise<object>;
|
|
11
12
|
getEndpoint(): Promise<string>;
|
|
12
13
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,13 +27,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const BaseAccessToken_1 =
|
|
31
|
+
const BaseAccessToken_1 = __importStar(require("../../../Core/BaseAccessToken"));
|
|
16
32
|
const Utils_1 = require("../../../Core/Utils");
|
|
17
|
-
class
|
|
33
|
+
class AuthAccessToken extends BaseAccessToken_1.default {
|
|
18
34
|
constructor(app, component) {
|
|
19
35
|
super(app);
|
|
20
36
|
this.requestMethod = 'POST';
|
|
@@ -23,6 +39,12 @@ class AccessToken extends BaseAccessToken_1.default {
|
|
|
23
39
|
this.component = null;
|
|
24
40
|
this.component = component;
|
|
25
41
|
}
|
|
42
|
+
warpAccessToken(token) {
|
|
43
|
+
return new BaseAccessToken_1.AccessToken(token, {
|
|
44
|
+
access_token: 'authorizer_access_token',
|
|
45
|
+
refresh_token: 'authorizer_refresh_token',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
26
48
|
getCredentials() {
|
|
27
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
50
|
return {
|
|
@@ -40,4 +62,4 @@ class AccessToken extends BaseAccessToken_1.default {
|
|
|
40
62
|
});
|
|
41
63
|
}
|
|
42
64
|
}
|
|
43
|
-
exports.default =
|
|
65
|
+
exports.default = AuthAccessToken;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import BaseAccessToken from '../../Core/BaseAccessToken';
|
|
1
|
+
import BaseAccessToken, { AccessToken } from '../../Core/BaseAccessToken';
|
|
2
2
|
export default class ProviderAccessToken extends BaseAccessToken {
|
|
3
3
|
protected requestMethod: string;
|
|
4
4
|
protected tokenKey: string;
|
|
5
5
|
protected endpointToGetToken: string;
|
|
6
6
|
protected cachePrefix: string;
|
|
7
|
+
protected warpAccessToken(token: Record<string, any>): AccessToken;
|
|
7
8
|
protected getCredentials(): Promise<object>;
|
|
8
9
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,11 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const BaseAccessToken_1 =
|
|
31
|
+
const BaseAccessToken_1 = __importStar(require("../../Core/BaseAccessToken"));
|
|
16
32
|
class ProviderAccessToken extends BaseAccessToken_1.default {
|
|
17
33
|
constructor() {
|
|
18
34
|
super(...arguments);
|
|
@@ -21,6 +37,11 @@ class ProviderAccessToken extends BaseAccessToken_1.default {
|
|
|
21
37
|
this.endpointToGetToken = 'cgi-bin/service/get_provider_token';
|
|
22
38
|
this.cachePrefix = 'easywechat.kernel.provider_access_token.';
|
|
23
39
|
}
|
|
40
|
+
warpAccessToken(token) {
|
|
41
|
+
return new BaseAccessToken_1.AccessToken(token, {
|
|
42
|
+
access_token: 'provider_access_token',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
24
45
|
getCredentials() {
|
|
25
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
47
|
return {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import BaseAccessToken from '../../Core/BaseAccessToken';
|
|
1
|
+
import BaseAccessToken, { AccessToken } from '../../Core/BaseAccessToken';
|
|
2
2
|
export default class SuiteAccessToken extends BaseAccessToken {
|
|
3
3
|
protected requestMethod: string;
|
|
4
4
|
protected tokenKey: string;
|
|
5
5
|
protected endpointToGetToken: string;
|
|
6
6
|
protected cachePrefix: string;
|
|
7
|
+
protected warpAccessToken(token: Record<string, any>): AccessToken;
|
|
7
8
|
protected getCredentials(): Promise<object>;
|
|
8
9
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,11 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const BaseAccessToken_1 =
|
|
31
|
+
const BaseAccessToken_1 = __importStar(require("../../Core/BaseAccessToken"));
|
|
16
32
|
class SuiteAccessToken extends BaseAccessToken_1.default {
|
|
17
33
|
constructor() {
|
|
18
34
|
super(...arguments);
|
|
@@ -21,6 +37,11 @@ class SuiteAccessToken extends BaseAccessToken_1.default {
|
|
|
21
37
|
this.endpointToGetToken = 'cgi-bin/service/get_suite_token';
|
|
22
38
|
this.cachePrefix = 'easywechat.kernel.suite_access_token.';
|
|
23
39
|
}
|
|
40
|
+
warpAccessToken(token) {
|
|
41
|
+
return new BaseAccessToken_1.AccessToken(token, {
|
|
42
|
+
access_token: 'suite_access_token',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
24
45
|
getCredentials() {
|
|
25
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
47
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"data":{"component_access_token":"fake-component-access-token","expires_in":7200},"lifeTime":1650631173}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"data":{"errcode":0,"errmsg":"ok","provider_access_token":"fake-provider-access-token","expires_in":7200},"lifeTime":1650631173}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"data":{"errcode":0,"errmsg":"ok","suite_access_token":"fake-suite-access-token","expires_in":7200},"lifeTime":1650631173}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"data":"mock-component-verify_ticket","lifeTime":1650627573}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"data":"mock-suite-ticket","lifeTime":1650627573}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-easywechat",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
4
4
|
"description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"release": "npx package-release",
|
|
7
8
|
"build": "rm -rf dist && npx tsc",
|
|
8
9
|
"test": "npx mocha ./test/**/*.js"
|
|
9
10
|
},
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@types/node": "^17.0.8",
|
|
22
23
|
"mocha": "^9.2.0",
|
|
24
|
+
"package-release": "^1.0.2",
|
|
23
25
|
"sinon": "^12.0.1",
|
|
24
26
|
"typescript": "^4.5.4"
|
|
25
27
|
},
|