@satorijs/adapter-dingtalk 2.0.1 → 2.0.2
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 +2 -3
- package/lib/index.js +5 -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,6 @@
|
|
|
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
4
|
logger: Logger;
|
|
5
|
-
|
|
6
|
-
connect(bot: DingtalkBot): Promise<void>;
|
|
5
|
+
connect(bot: DingtalkBot<C>): Promise<void>;
|
|
7
6
|
}
|
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,9 +121,9 @@ 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
|
});
|
|
@@ -281,7 +278,7 @@ var _WsClient = class _WsClient extends import_satori4.Adapter.WsClient {
|
|
|
281
278
|
this.bot.online();
|
|
282
279
|
this.socket.addEventListener("message", async ({ data }) => {
|
|
283
280
|
const parsed = JSON.parse(data.toString());
|
|
284
|
-
this.ctx.logger("dingtalk").debug(
|
|
281
|
+
this.ctx.logger("dingtalk").debug(parsed);
|
|
285
282
|
if (parsed.type === "SYSTEM") {
|
|
286
283
|
if (parsed.headers.topic === "ping") {
|
|
287
284
|
this.socket.send(JSON.stringify({
|
|
@@ -292,11 +289,11 @@ var _WsClient = class _WsClient extends import_satori4.Adapter.WsClient {
|
|
|
292
289
|
}));
|
|
293
290
|
}
|
|
294
291
|
} else if (parsed.type === "CALLBACK") {
|
|
295
|
-
this.ctx.logger("dingtalk").debug(
|
|
292
|
+
this.ctx.logger("dingtalk").debug(JSON.parse(parsed.data));
|
|
296
293
|
const session = await decodeMessage(this.bot, JSON.parse(parsed.data));
|
|
297
294
|
if (session)
|
|
298
295
|
this.bot.dispatch(session);
|
|
299
|
-
this.ctx.logger("dingtalk").debug(
|
|
296
|
+
this.ctx.logger("dingtalk").debug(session);
|
|
300
297
|
}
|
|
301
298
|
});
|
|
302
299
|
}
|