@satorijs/adapter-dingtalk 2.0.1 → 2.0.3
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/lib/bot.d.ts +2 -2
- package/lib/http.d.ts +3 -3
- package/lib/index.js +6 -8
- package/lib/index.js.map +2 -2
- package/lib/message.d.ts +2 -2
- package/lib/utils.d.ts +2 -2
- package/lib/ws.d.ts +2 -2
- package/package.json +7 -4
package/lib/bot.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { Bot, Context, Quester, Schema } from '@satorijs/satori';
|
|
|
2
2
|
import { DingtalkMessageEncoder } from './message';
|
|
3
3
|
import { WsClient } from './ws';
|
|
4
4
|
import { Internal } from './internal';
|
|
5
|
-
export declare class DingtalkBot extends Bot<DingtalkBot.Config> {
|
|
5
|
+
export declare class DingtalkBot<C extends Context = Context> extends Bot<C, DingtalkBot.Config> {
|
|
6
6
|
static MessageEncoder: typeof DingtalkMessageEncoder;
|
|
7
7
|
oldHttp: Quester;
|
|
8
8
|
http: Quester;
|
|
9
9
|
internal: Internal;
|
|
10
10
|
private refreshTokenTimer;
|
|
11
|
-
constructor(ctx:
|
|
11
|
+
constructor(ctx: C, config: DingtalkBot.Config);
|
|
12
12
|
getLogin(): Promise<import("@satorijs/protocol").Login>;
|
|
13
13
|
stop(): Promise<void>;
|
|
14
14
|
token: string;
|
package/lib/http.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Adapter, Context, Logger } from '@satorijs/satori';
|
|
2
2
|
import { DingtalkBot } from './bot';
|
|
3
|
-
export declare class HttpServer extends Adapter<DingtalkBot
|
|
3
|
+
export declare class HttpServer<C extends Context = Context> extends Adapter<C, DingtalkBot<C>> {
|
|
4
|
+
static inject: string[];
|
|
4
5
|
logger: Logger;
|
|
5
|
-
|
|
6
|
-
connect(bot: DingtalkBot): Promise<void>;
|
|
6
|
+
connect(bot: DingtalkBot<C>): Promise<void>;
|
|
7
7
|
}
|
package/lib/index.js
CHANGED
|
@@ -105,9 +105,6 @@ __name(decodeMessage, "decodeMessage");
|
|
|
105
105
|
// satori/adapters/dingtalk/src/http.ts
|
|
106
106
|
var _HttpServer = class _HttpServer extends import_satori2.Adapter {
|
|
107
107
|
logger = new import_satori2.Logger("dingtalk");
|
|
108
|
-
constructor(ctx, bot) {
|
|
109
|
-
super();
|
|
110
|
-
}
|
|
111
108
|
async connect(bot) {
|
|
112
109
|
await bot.refreshToken();
|
|
113
110
|
await bot.getLogin();
|
|
@@ -124,15 +121,16 @@ var _HttpServer = class _HttpServer extends import_satori2.Adapter {
|
|
|
124
121
|
if (computedSign !== sign)
|
|
125
122
|
return ctx.status = 403;
|
|
126
123
|
const body = ctx.request.body;
|
|
127
|
-
this.logger.debug(
|
|
124
|
+
this.logger.debug(body);
|
|
128
125
|
const session = await decodeMessage(bot, body);
|
|
129
|
-
this.logger.debug(
|
|
126
|
+
this.logger.debug(session);
|
|
130
127
|
if (session)
|
|
131
128
|
bot.dispatch(session);
|
|
132
129
|
});
|
|
133
130
|
}
|
|
134
131
|
};
|
|
135
132
|
__name(_HttpServer, "HttpServer");
|
|
133
|
+
__publicField(_HttpServer, "inject", ["router"]);
|
|
136
134
|
var HttpServer = _HttpServer;
|
|
137
135
|
|
|
138
136
|
// satori/adapters/dingtalk/src/message.ts
|
|
@@ -281,7 +279,7 @@ var _WsClient = class _WsClient extends import_satori4.Adapter.WsClient {
|
|
|
281
279
|
this.bot.online();
|
|
282
280
|
this.socket.addEventListener("message", async ({ data }) => {
|
|
283
281
|
const parsed = JSON.parse(data.toString());
|
|
284
|
-
this.ctx.logger("dingtalk").debug(
|
|
282
|
+
this.ctx.logger("dingtalk").debug(parsed);
|
|
285
283
|
if (parsed.type === "SYSTEM") {
|
|
286
284
|
if (parsed.headers.topic === "ping") {
|
|
287
285
|
this.socket.send(JSON.stringify({
|
|
@@ -292,11 +290,11 @@ var _WsClient = class _WsClient extends import_satori4.Adapter.WsClient {
|
|
|
292
290
|
}));
|
|
293
291
|
}
|
|
294
292
|
} else if (parsed.type === "CALLBACK") {
|
|
295
|
-
this.ctx.logger("dingtalk").debug(
|
|
293
|
+
this.ctx.logger("dingtalk").debug(JSON.parse(parsed.data));
|
|
296
294
|
const session = await decodeMessage(this.bot, JSON.parse(parsed.data));
|
|
297
295
|
if (session)
|
|
298
296
|
this.bot.dispatch(session);
|
|
299
|
-
this.ctx.logger("dingtalk").debug(
|
|
297
|
+
this.ctx.logger("dingtalk").debug(session);
|
|
300
298
|
}
|
|
301
299
|
});
|
|
302
300
|
}
|