node-easywechat 3.0.0 → 3.1.0
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 +15 -0
- package/README.md +22 -1
- package/dist/Core/Config.d.ts +1 -1
- package/dist/Core/Config.js +3 -1
- package/dist/Core/HttpClient/Contracts/HttpClientInterface.d.ts +7 -1
- package/dist/Core/HttpClient/Contracts/HttpClientInterface.js +6 -0
- package/dist/Core/HttpClient/HttpClient.d.ts +1 -4
- package/dist/Core/HttpClient/HttpClient.js +4 -4
- package/dist/Core/HttpClient/Mixins/PresetMixin.d.ts +0 -12
- package/dist/Core/HttpClient/Mixins/PresetMixin.js +0 -18
- package/dist/Core/Support/Obj.js +4 -2
- package/dist/MiniApp/Application.d.ts +4 -4
- package/dist/MiniApp/Application.js +1 -1
- package/dist/MiniApp/Contracts/ApplicationInterface.d.ts +2 -2
- package/dist/OfficialAccount/Application.d.ts +4 -4
- package/dist/OfficialAccount/Application.js +1 -1
- package/dist/OfficialAccount/Contracts/ApplicationInterface.d.ts +2 -2
- package/dist/OpenPlatform/Account.d.ts +13 -0
- package/dist/OpenPlatform/Account.js +22 -0
- package/dist/OpenPlatform/Application.d.ts +152 -0
- package/dist/OpenPlatform/Application.js +355 -0
- package/dist/OpenPlatform/Authorization.d.ts +23 -0
- package/dist/OpenPlatform/Authorization.js +74 -0
- package/dist/OpenPlatform/AuthorizerAccessToken.d.ts +19 -0
- package/dist/OpenPlatform/AuthorizerAccessToken.js +43 -0
- package/dist/OpenPlatform/ComponentAccessToken.d.ts +28 -0
- package/dist/OpenPlatform/ComponentAccessToken.js +85 -0
- package/dist/OpenPlatform/Config.d.ts +5 -0
- package/dist/OpenPlatform/Config.js +16 -0
- package/dist/OpenPlatform/Contracts/AccountInterface.d.ts +23 -0
- package/dist/OpenPlatform/Contracts/AccountInterface.js +25 -0
- package/dist/OpenPlatform/Contracts/ApplicationInterface.d.ts +68 -0
- package/dist/OpenPlatform/Contracts/ApplicationInterface.js +60 -0
- package/dist/OpenPlatform/Contracts/VerifyTicketInterface.d.ts +23 -0
- package/dist/OpenPlatform/Contracts/VerifyTicketInterface.js +25 -0
- package/dist/OpenPlatform/Message.d.ts +43 -0
- package/dist/OpenPlatform/Message.js +9 -0
- package/dist/OpenPlatform/Server.d.ts +61 -0
- package/dist/OpenPlatform/Server.js +136 -0
- package/dist/OpenPlatform/VerifyTicket.d.ts +13 -0
- package/dist/OpenPlatform/VerifyTicket.js +49 -0
- package/dist/Pay/Application.d.ts +4 -4
- package/dist/Pay/Application.js +1 -1
- package/dist/Pay/Client.d.ts +12 -0
- package/dist/Pay/Client.js +27 -3
- package/dist/Pay/Signature.js +7 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v3.1.0 (2022-11-09)
|
|
5
|
+
|
|
6
|
+
- Feat: 新增开放平台模块
|
|
7
|
+
|
|
8
|
+
- Fix: 修复获取配置项异常的问题
|
|
9
|
+
- Fix: 修复配置项类型判断异常的问题
|
|
10
|
+
- Fix: 修复请求客户端无法设置请求是否错误判断逻辑的方法
|
|
11
|
+
|
|
12
|
+
- Perf: 优化url路径解析方法
|
|
13
|
+
|
|
14
|
+
## v3.0.1 (2022-08-26)
|
|
15
|
+
|
|
16
|
+
- Fix: 修复with方法无效的问题
|
|
17
|
+
|
|
4
18
|
## v3.0.0 (2022-07-28)
|
|
5
19
|
|
|
6
20
|
- Feat: 请求后自动解析响应结果,简化获取数据的方式
|
|
@@ -17,6 +31,7 @@
|
|
|
17
31
|
- Fix: 调整默认Message提示的作用域为公众号和小程序
|
|
18
32
|
- Fix: 修复AccessToken对象声明错误的问题
|
|
19
33
|
|
|
34
|
+
- Docs: 更新client调用方法说明
|
|
20
35
|
- Docs: 增加微信支付相关说明文档
|
|
21
36
|
|
|
22
37
|
## v3.0.0-beta.5 (2022-06-29)
|
package/README.md
CHANGED
|
@@ -44,6 +44,13 @@ let app = new Pay({
|
|
|
44
44
|
// 配置项
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
// 开放平台
|
|
48
|
+
const { OpenPlatform } = require('node-easywechat');
|
|
49
|
+
// 实例化应用
|
|
50
|
+
let app = new OpenPlatform({
|
|
51
|
+
// 配置项
|
|
52
|
+
});
|
|
53
|
+
|
|
47
54
|
// ----- 以下为通用的 api 调用方法 -----
|
|
48
55
|
|
|
49
56
|
// 获取 api 调用客户端
|
|
@@ -138,6 +145,20 @@ let data = response.toObject();
|
|
|
138
145
|
}
|
|
139
146
|
```
|
|
140
147
|
|
|
148
|
+
``` js
|
|
149
|
+
// 开放平台配置
|
|
150
|
+
{
|
|
151
|
+
// 开放平台的 app key
|
|
152
|
+
app_id: '',
|
|
153
|
+
// 开放平台的 app secret
|
|
154
|
+
secret: '',
|
|
155
|
+
// 开放平台的 token
|
|
156
|
+
token: '',
|
|
157
|
+
// EncodingAESKey
|
|
158
|
+
aes_key: '',
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
141
162
|
### 自定义模块(模块替换)使用方法
|
|
142
163
|
|
|
143
164
|
#### 日志模块
|
|
@@ -251,7 +272,7 @@ app.setRequest(request);
|
|
|
251
272
|
- [x] 公众号模块
|
|
252
273
|
- [x] 微信支付
|
|
253
274
|
- [x] 小程序
|
|
254
|
-
- [
|
|
275
|
+
- [x] 开放平台
|
|
255
276
|
- [ ] 企业微信
|
|
256
277
|
- [ ] 企业微信开放平台
|
|
257
278
|
- [ ] 自定义
|
package/dist/Core/Config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OfficialAccountConfig, MiniAppConfig, PayConfig, OpenPlatformConfig, WorkConfig, OpenWorkConfig } from "../Types/global";
|
|
2
2
|
import ConfigInterface from "./Contracts/ConfigInterface";
|
|
3
|
-
declare class Config
|
|
3
|
+
declare class Config extends ConfigInterface {
|
|
4
4
|
protected items: OfficialAccountConfig | MiniAppConfig | PayConfig | OpenPlatformConfig | WorkConfig | OpenWorkConfig;
|
|
5
5
|
protected requiredKeys: string[];
|
|
6
6
|
constructor(items?: OfficialAccountConfig | MiniAppConfig | PayConfig | OpenPlatformConfig | WorkConfig | OpenWorkConfig);
|
package/dist/Core/Config.js
CHANGED
|
@@ -3,9 +3,11 @@ 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 ConfigInterface_1 = __importDefault(require("./Contracts/ConfigInterface"));
|
|
6
7
|
const Obj_1 = __importDefault(require("./Support/Obj"));
|
|
7
|
-
class Config {
|
|
8
|
+
class Config extends ConfigInterface_1.default {
|
|
8
9
|
constructor(items = {}) {
|
|
10
|
+
super();
|
|
9
11
|
this.items = items;
|
|
10
12
|
this.requiredKeys = [];
|
|
11
13
|
this.items = merge_1.default.recursive(true, items);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Method, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
2
|
-
import { LogHandler } from '../../../Types/global';
|
|
2
|
+
import { HttpClientFailureJudgeClosure, LogHandler } from '../../../Types/global';
|
|
3
3
|
import HttpClientResponse from '../HttpClientResponse';
|
|
4
4
|
declare abstract class HttpClientInterface {
|
|
5
5
|
/**
|
|
@@ -15,6 +15,12 @@ declare abstract class HttpClientInterface {
|
|
|
15
15
|
* 设置日志方法
|
|
16
16
|
*/
|
|
17
17
|
setLogger(logger: LogHandler): this;
|
|
18
|
+
/**
|
|
19
|
+
* 设置错误判断方法
|
|
20
|
+
* @param closure
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
judgeFailureUsing(closure: HttpClientFailureJudgeClosure): this;
|
|
18
24
|
/**
|
|
19
25
|
* 发起http请求
|
|
20
26
|
*/
|
|
@@ -12,11 +12,8 @@ declare class HttpClient implements HttpClientInterface {
|
|
|
12
12
|
*/
|
|
13
13
|
protected logger: LogHandler;
|
|
14
14
|
constructor(axios: AxiosInstance, failureJudge?: HttpClientFailureJudgeClosure, throwError?: boolean);
|
|
15
|
-
/**
|
|
16
|
-
* 设置日志处理方法
|
|
17
|
-
* @param logger
|
|
18
|
-
*/
|
|
19
15
|
setLogger(logger: LogHandler): this;
|
|
16
|
+
judgeFailureUsing(closure: HttpClientFailureJudgeClosure): this;
|
|
20
17
|
request(method: Method, url: string, payload?: AxiosRequestConfig<any>): Promise<HttpClientResponse>;
|
|
21
18
|
getInstance(): AxiosInstance;
|
|
22
19
|
setInstance(instance: AxiosInstance): this;
|
|
@@ -25,14 +25,14 @@ class HttpClient {
|
|
|
25
25
|
*/
|
|
26
26
|
this.logger = null;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* 设置日志处理方法
|
|
30
|
-
* @param logger
|
|
31
|
-
*/
|
|
32
28
|
setLogger(logger) {
|
|
33
29
|
this.logger = logger;
|
|
34
30
|
return this;
|
|
35
31
|
}
|
|
32
|
+
judgeFailureUsing(closure) {
|
|
33
|
+
this.failureJudge = closure;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
36
|
request(method, url, payload = {}) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
let options = Object.assign({}, payload);
|
|
@@ -62,18 +62,6 @@ declare class PresetMixin {
|
|
|
62
62
|
* @returns
|
|
63
63
|
*/
|
|
64
64
|
withSecret(new_secret?: string): this;
|
|
65
|
-
/**
|
|
66
|
-
* 预设置mch_id(因nodejs不支持魔术方法,只好预先设置几个常用的方法)
|
|
67
|
-
* @param new_mch_id
|
|
68
|
-
* @returns
|
|
69
|
-
*/
|
|
70
|
-
withMchId(new_mch_id?: string): this;
|
|
71
|
-
/**
|
|
72
|
-
* 预设置mch_id别名(因nodejs不支持魔术方法,只好预先设置几个常用的方法)
|
|
73
|
-
* @param new_alias
|
|
74
|
-
* @returns
|
|
75
|
-
*/
|
|
76
|
-
withMchIdAs(new_alias?: string): this;
|
|
77
65
|
/**
|
|
78
66
|
* 预设置文件
|
|
79
67
|
* @param file 文件路径或可读文件流
|
|
@@ -109,24 +109,6 @@ class PresetMixin {
|
|
|
109
109
|
this.with('secret', new_secret);
|
|
110
110
|
return this;
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* 预设置mch_id(因nodejs不支持魔术方法,只好预先设置几个常用的方法)
|
|
114
|
-
* @param new_mch_id
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
withMchId(new_mch_id = null) {
|
|
118
|
-
this.with('mch_id', new_mch_id);
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* 预设置mch_id别名(因nodejs不支持魔术方法,只好预先设置几个常用的方法)
|
|
123
|
-
* @param new_alias
|
|
124
|
-
* @returns
|
|
125
|
-
*/
|
|
126
|
-
withMchIdAs(new_alias = null) {
|
|
127
|
-
this.with(new_alias, this.presets['mch_id']);
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
112
|
/**
|
|
131
113
|
* 预设置文件
|
|
132
114
|
* @param file 文件路径或可读文件流
|
package/dist/Core/Support/Obj.js
CHANGED
|
@@ -19,14 +19,16 @@ class Obj {
|
|
|
19
19
|
return obj[key];
|
|
20
20
|
}
|
|
21
21
|
let newObj = merge_1.default.recursive(true, obj);
|
|
22
|
-
key.split('.')
|
|
22
|
+
let keys = key.split('.');
|
|
23
|
+
for (let i = 0; i < keys.length; i++) {
|
|
24
|
+
let segment = keys[i];
|
|
23
25
|
if (Obj.exists(newObj, segment)) {
|
|
24
26
|
newObj = newObj[segment];
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
29
|
return defaultValue;
|
|
28
30
|
}
|
|
29
|
-
}
|
|
31
|
+
}
|
|
30
32
|
return newObj;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
@@ -11,7 +11,7 @@ import { MiniAppConfig } from '../Types/global';
|
|
|
11
11
|
import AccountInterface from './Contracts/AccountInterface';
|
|
12
12
|
import ApplicationInterface from './Contracts/ApplicationInterface';
|
|
13
13
|
import Utils from './Utils';
|
|
14
|
-
import
|
|
14
|
+
import AccessTokenInterface from '../Core/Contracts/AccessTokenInterface';
|
|
15
15
|
/**
|
|
16
16
|
* 小程序应用
|
|
17
17
|
*/
|
|
@@ -20,7 +20,7 @@ declare class Application implements ApplicationInterface {
|
|
|
20
20
|
protected account: AccountInterface;
|
|
21
21
|
protected encryptor: Encryptor;
|
|
22
22
|
protected server: ServerInterface;
|
|
23
|
-
protected accessToken:
|
|
23
|
+
protected accessToken: AccessTokenInterface;
|
|
24
24
|
getAccount(): AccountInterface;
|
|
25
25
|
/**
|
|
26
26
|
* 设置当前账户实例
|
|
@@ -42,13 +42,13 @@ declare class Application implements ApplicationInterface {
|
|
|
42
42
|
* @returns
|
|
43
43
|
*/
|
|
44
44
|
setServer(server: ServerInterface): this;
|
|
45
|
-
getAccessToken():
|
|
45
|
+
getAccessToken(): AccessTokenInterface;
|
|
46
46
|
/**
|
|
47
47
|
* 设置AccessToken实例
|
|
48
48
|
* @param accessToken
|
|
49
49
|
* @returns
|
|
50
50
|
*/
|
|
51
|
-
setAccessToken(accessToken:
|
|
51
|
+
setAccessToken(accessToken: AccessTokenInterface): this;
|
|
52
52
|
getUtils(): Utils;
|
|
53
53
|
createClient(): AccessTokenAwareClient;
|
|
54
54
|
/**
|
|
@@ -107,7 +107,7 @@ class Application {
|
|
|
107
107
|
return new Utils_2.default(this);
|
|
108
108
|
}
|
|
109
109
|
createClient() {
|
|
110
|
-
return (new AccessTokenAwareClient_1.default(this.getHttpClient(), this.getAccessToken()))
|
|
110
|
+
return (new AccessTokenAwareClient_1.default(this.getHttpClient(), this.getAccessToken(), (response) => { var _a; return ((_a = response.toObject()['errcode']) !== null && _a !== void 0 ? _a : 0) || (response.toObject()['error'] !== null && response.toObject()['error'] !== undefined); }, this.getConfig().get('http.throw', true)))
|
|
111
111
|
.setPresets(this.getConfig().all());
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
@@ -7,7 +7,7 @@ import ServerRequestInterface from "../../Core/Http/Contracts/ServerRequestInter
|
|
|
7
7
|
import Encryptor from "../../Core/Encryptor";
|
|
8
8
|
import AccountInterface from "./AccountInterface";
|
|
9
9
|
import Utils from "../Utils";
|
|
10
|
-
import
|
|
10
|
+
import AccessTokenInterface from "../../Core/Contracts/AccessTokenInterface";
|
|
11
11
|
declare abstract class ApplicationInterface {
|
|
12
12
|
/**
|
|
13
13
|
* 获取当前账户实例
|
|
@@ -53,7 +53,7 @@ declare abstract class ApplicationInterface {
|
|
|
53
53
|
* 获取AccessToken实例
|
|
54
54
|
* @returns
|
|
55
55
|
*/
|
|
56
|
-
getAccessToken():
|
|
56
|
+
getAccessToken(): AccessTokenInterface;
|
|
57
57
|
/**
|
|
58
58
|
* 获取缓存实例
|
|
59
59
|
* @returns
|
|
@@ -13,7 +13,7 @@ import AccountInterface from './Contracts/AccountInterface';
|
|
|
13
13
|
import ApplicationInterface from './Contracts/ApplicationInterface';
|
|
14
14
|
import JsApiTicket from './JsApiTicket';
|
|
15
15
|
import Utils from './Utils';
|
|
16
|
-
import
|
|
16
|
+
import AccessTokenInterface from '../Core/Contracts/AccessTokenInterface';
|
|
17
17
|
/**
|
|
18
18
|
* 公众号应用
|
|
19
19
|
*/
|
|
@@ -22,7 +22,7 @@ declare class Application implements ApplicationInterface {
|
|
|
22
22
|
protected account: AccountInterface;
|
|
23
23
|
protected encryptor: Encryptor;
|
|
24
24
|
protected server: ServerInterface;
|
|
25
|
-
protected accessToken:
|
|
25
|
+
protected accessToken: AccessTokenInterface;
|
|
26
26
|
protected oauthFactory: OfficialAccountOAuthFactory;
|
|
27
27
|
protected ticket: JsApiTicket;
|
|
28
28
|
getAccount(): AccountInterface;
|
|
@@ -46,13 +46,13 @@ declare class Application implements ApplicationInterface {
|
|
|
46
46
|
* @returns
|
|
47
47
|
*/
|
|
48
48
|
setServer(server: ServerInterface): this;
|
|
49
|
-
getAccessToken():
|
|
49
|
+
getAccessToken(): AccessTokenInterface;
|
|
50
50
|
/**
|
|
51
51
|
* 设置AccessToken实例
|
|
52
52
|
* @param accessToken
|
|
53
53
|
* @returns
|
|
54
54
|
*/
|
|
55
|
-
setAccessToken(accessToken:
|
|
55
|
+
setAccessToken(accessToken: AccessTokenInterface): this;
|
|
56
56
|
setOAuthFactory(oauthFactory: OfficialAccountOAuthFactory): this;
|
|
57
57
|
getOAuth(): ProviderInterface;
|
|
58
58
|
getTicket(): JsApiTicket;
|
|
@@ -142,7 +142,7 @@ class Application {
|
|
|
142
142
|
return new Utils_2.default(this);
|
|
143
143
|
}
|
|
144
144
|
createClient() {
|
|
145
|
-
return (new AccessTokenAwareClient_1.default(this.getHttpClient(), this.getAccessToken()))
|
|
145
|
+
return (new AccessTokenAwareClient_1.default(this.getHttpClient(), this.getAccessToken(), (response) => { var _a; return (_a = response.toObject()['errcode']) !== null && _a !== void 0 ? _a : 0; }, this.getConfig().get('http.throw', true)))
|
|
146
146
|
.setPresets(this.getConfig().all());
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
@@ -10,7 +10,7 @@ import AccountInterface from "./AccountInterface";
|
|
|
10
10
|
import { OfficialAccountOAuthFactory } from "../../Types/global";
|
|
11
11
|
import JsApiTicket from "../JsApiTicket";
|
|
12
12
|
import Utils from "../Utils";
|
|
13
|
-
import
|
|
13
|
+
import AccessTokenInterface from "../../Core/Contracts/AccessTokenInterface";
|
|
14
14
|
declare abstract class ApplicationInterface {
|
|
15
15
|
/**
|
|
16
16
|
* 获取当前账户实例
|
|
@@ -56,7 +56,7 @@ declare abstract class ApplicationInterface {
|
|
|
56
56
|
* 获取AccessToken实例
|
|
57
57
|
* @returns
|
|
58
58
|
*/
|
|
59
|
-
getAccessToken():
|
|
59
|
+
getAccessToken(): AccessTokenInterface;
|
|
60
60
|
/**
|
|
61
61
|
* 获取缓存实例
|
|
62
62
|
* @returns
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import AccountInterface from "./Contracts/AccountInterface";
|
|
2
|
+
declare class Account implements AccountInterface {
|
|
3
|
+
protected appId: string;
|
|
4
|
+
protected secret: string;
|
|
5
|
+
protected token: string;
|
|
6
|
+
protected aesKey: string;
|
|
7
|
+
constructor(appId: string, secret: string, token?: string, aesKey?: string);
|
|
8
|
+
getAppId(): string;
|
|
9
|
+
getSecret(): string;
|
|
10
|
+
getToken(): string;
|
|
11
|
+
getAesKey(): string;
|
|
12
|
+
}
|
|
13
|
+
export = Account;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
class Account {
|
|
3
|
+
constructor(appId, secret, token = null, aesKey = null) {
|
|
4
|
+
this.appId = appId;
|
|
5
|
+
this.secret = secret;
|
|
6
|
+
this.token = token;
|
|
7
|
+
this.aesKey = aesKey;
|
|
8
|
+
}
|
|
9
|
+
getAppId() {
|
|
10
|
+
return this.appId;
|
|
11
|
+
}
|
|
12
|
+
getSecret() {
|
|
13
|
+
return this.secret;
|
|
14
|
+
}
|
|
15
|
+
getToken() {
|
|
16
|
+
return this.token;
|
|
17
|
+
}
|
|
18
|
+
getAesKey() {
|
|
19
|
+
return this.aesKey;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
module.exports = Account;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import ProviderInterface from 'node-socialite/dist/Core/ProviderInterface';
|
|
2
|
+
import ConfigInterface from '../Core/Contracts/ConfigInterface';
|
|
3
|
+
import ServerInterface from '../Core/Contracts/ServerInterface';
|
|
4
|
+
import Encryptor from '../Core/Encryptor';
|
|
5
|
+
import AccessTokenAwareClient from '../Core/HttpClient/AccessTokenAwareClient';
|
|
6
|
+
import CacheMixin from '../Core/Mixins/CacheMixin';
|
|
7
|
+
import ClientMixin from '../Core/Mixins/ClientMixin';
|
|
8
|
+
import ConfigMixin from '../Core/Mixins/ConfigMixin';
|
|
9
|
+
import HttpClientMixin from '../Core/Mixins/HttpClientMixin';
|
|
10
|
+
import ServerRequestMixin from '../Core/Mixins/ServerRequestMixin';
|
|
11
|
+
import OfficialAccountApplication from '../OfficialAccount/Application';
|
|
12
|
+
import MiniAppApplication from '../MiniApp/Application';
|
|
13
|
+
import { OfficialAccountConfig, OfficialAccountOAuthFactory, MiniAppConfig } from '../Types/global';
|
|
14
|
+
import AccountInterface from './Contracts/AccountInterface';
|
|
15
|
+
import ApplicationInterface from './Contracts/ApplicationInterface';
|
|
16
|
+
import AccessTokenInterface from '../Core/Contracts/AccessTokenInterface';
|
|
17
|
+
import VerifyTicketInterface from './Contracts/VerifyTicketInterface';
|
|
18
|
+
import Authorization from './Authorization';
|
|
19
|
+
import AuthorizerAccessToken from './AuthorizerAccessToken';
|
|
20
|
+
/**
|
|
21
|
+
* 公众号应用
|
|
22
|
+
*/
|
|
23
|
+
declare class Application implements ApplicationInterface {
|
|
24
|
+
constructor(config: ConfigInterface | OfficialAccountConfig);
|
|
25
|
+
protected account: AccountInterface;
|
|
26
|
+
protected encryptor: Encryptor;
|
|
27
|
+
protected server: ServerInterface;
|
|
28
|
+
protected componentAccessToken: AccessTokenInterface;
|
|
29
|
+
protected verifyTicket: VerifyTicketInterface;
|
|
30
|
+
getAccount(): AccountInterface;
|
|
31
|
+
/**
|
|
32
|
+
* 设置当前账户实例
|
|
33
|
+
* @param account
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
setAccount(account: AccountInterface): this;
|
|
37
|
+
getVerifyTicket(): VerifyTicketInterface;
|
|
38
|
+
setVerifyTicket(verifyTicket: VerifyTicketInterface): this;
|
|
39
|
+
getEncryptor(): Encryptor;
|
|
40
|
+
/**
|
|
41
|
+
* 设置加密机实例
|
|
42
|
+
* @param encryptor
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
setEncryptor(encryptor: Encryptor): this;
|
|
46
|
+
getServer(): ServerInterface;
|
|
47
|
+
/**
|
|
48
|
+
* 设置服务端实例
|
|
49
|
+
* @param server
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
setServer(server: ServerInterface): this;
|
|
53
|
+
getAccessToken(): AccessTokenInterface;
|
|
54
|
+
getComponentAccessToken(): AccessTokenInterface;
|
|
55
|
+
/**
|
|
56
|
+
* 设置AccessToken实例
|
|
57
|
+
* @param accessToken
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
setComponentAccessToken(componentAccessToken: AccessTokenInterface): this;
|
|
61
|
+
/**
|
|
62
|
+
* 使用授权码获取授权信息
|
|
63
|
+
* @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/authorization_info.html
|
|
64
|
+
* @param authorizationCode
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
getAuthorization(authorizationCode: string): Promise<Authorization>;
|
|
68
|
+
/**
|
|
69
|
+
* 获取/刷新接口调用令牌
|
|
70
|
+
* @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html
|
|
71
|
+
* @param authorizerAppId
|
|
72
|
+
* @param authorizerRefreshToken
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
refreshAuthorizerToken(authorizerAppId: string, authorizerRefreshToken: string): Promise<import("../Types/global").WeixinResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* 获取预授权码
|
|
78
|
+
* @see https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/pre_auth_code.html
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
createPreAuthorizationCode(): Promise<import("../Types/global").WeixinResponse>;
|
|
82
|
+
getOAuth(): ProviderInterface;
|
|
83
|
+
/**
|
|
84
|
+
* 根据刷新令牌获取公众号实例
|
|
85
|
+
* @param appId
|
|
86
|
+
* @param refreshToken
|
|
87
|
+
* @param config
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
getOfficialAccountWithRefreshToken(appId: string, refreshToken: string, config?: ConfigInterface | OfficialAccountConfig): Promise<OfficialAccountApplication>;
|
|
91
|
+
/**
|
|
92
|
+
* 根据访问令牌获取公众号实例
|
|
93
|
+
* @param appId
|
|
94
|
+
* @param accessToken
|
|
95
|
+
* @param config
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
getOfficialAccountWithAccessToken(appId: string, accessToken: string, config?: ConfigInterface | OfficialAccountConfig): OfficialAccountApplication;
|
|
99
|
+
/**
|
|
100
|
+
* 获取公众号实例
|
|
101
|
+
* @param authorizerAccessToken
|
|
102
|
+
* @param config
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
getOfficialAccount(authorizerAccessToken: AuthorizerAccessToken, config?: ConfigInterface | OfficialAccountConfig): OfficialAccountApplication;
|
|
106
|
+
/**
|
|
107
|
+
* 创建第三方oauth工厂
|
|
108
|
+
* @param authorizerAppId
|
|
109
|
+
* @param config
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
protected createAuthorizerOAuthFactory(authorizerAppId: string, config: ConfigInterface): OfficialAccountOAuthFactory;
|
|
113
|
+
/**
|
|
114
|
+
* 根据刷新令牌获取小程序实例
|
|
115
|
+
* @param appId
|
|
116
|
+
* @param refreshToken
|
|
117
|
+
* @param config
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
getMiniAppWithRefreshToken(appId: string, refreshToken: string, config?: ConfigInterface | MiniAppConfig): Promise<MiniAppApplication>;
|
|
121
|
+
/**
|
|
122
|
+
* 根据访问令牌获取小程序实例
|
|
123
|
+
* @param appId
|
|
124
|
+
* @param accessToken
|
|
125
|
+
* @param config
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
getMiniAppWithAccessToken(appId: string, accessToken: string, config?: ConfigInterface | MiniAppConfig): MiniAppApplication;
|
|
129
|
+
/**
|
|
130
|
+
* 获取小程序实例
|
|
131
|
+
* @param authorizerAccessToken
|
|
132
|
+
* @param config
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
getMiniApp(authorizerAccessToken: AuthorizerAccessToken, config?: ConfigInterface | MiniAppConfig): MiniAppApplication;
|
|
136
|
+
/**
|
|
137
|
+
* 获取第三方授权令牌
|
|
138
|
+
* @param appId
|
|
139
|
+
* @param refreshToken
|
|
140
|
+
* @returns
|
|
141
|
+
*/
|
|
142
|
+
getAuthorizerAccessToken(appId: string, refreshToken: string): Promise<any>;
|
|
143
|
+
createClient(): AccessTokenAwareClient;
|
|
144
|
+
/**
|
|
145
|
+
* 获取请求默认配置
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
protected getHttpClientDefaultOptions(): Record<string, any>;
|
|
149
|
+
}
|
|
150
|
+
interface Application extends ConfigMixin, CacheMixin, ClientMixin, ServerRequestMixin, HttpClientMixin {
|
|
151
|
+
}
|
|
152
|
+
export = Application;
|