lansenger-sdk-ts 1.0.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/LICENSE +21 -0
- package/README.fr.md +501 -0
- package/README.md +504 -0
- package/README.zhHans.md +501 -0
- package/README.zhHant.md +501 -0
- package/README.zhHantHK.md +501 -0
- package/dist/accountMessages.d.ts +12 -0
- package/dist/accountMessages.js +41 -0
- package/dist/auth.d.ts +13 -0
- package/dist/auth.js +70 -0
- package/dist/calendars.d.ts +84 -0
- package/dist/calendars.js +278 -0
- package/dist/callbacks.d.ts +384 -0
- package/dist/callbacks.js +712 -0
- package/dist/chats.d.ts +22 -0
- package/dist/chats.js +88 -0
- package/dist/client.d.ts +439 -0
- package/dist/client.js +712 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +42 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.js +187 -0
- package/dist/contacts.d.ts +38 -0
- package/dist/contacts.js +161 -0
- package/dist/departments.d.ts +18 -0
- package/dist/departments.js +69 -0
- package/dist/exceptions.d.ts +20 -0
- package/dist/exceptions.js +42 -0
- package/dist/groupMessages.d.ts +11 -0
- package/dist/groupMessages.js +39 -0
- package/dist/groups.d.ts +66 -0
- package/dist/groups.js +218 -0
- package/dist/http.d.ts +7 -0
- package/dist/http.js +67 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +189 -0
- package/dist/media.d.ts +16 -0
- package/dist/media.js +178 -0
- package/dist/models.d.ts +925 -0
- package/dist/models.js +991 -0
- package/dist/oauth.d.ts +17 -0
- package/dist/oauth.js +107 -0
- package/dist/persistence.d.ts +26 -0
- package/dist/persistence.js +210 -0
- package/dist/reminders.d.ts +10 -0
- package/dist/reminders.js +31 -0
- package/dist/streaming.d.ts +9 -0
- package/dist/streaming.js +40 -0
- package/dist/todos.d.ts +75 -0
- package/dist/todos.js +282 -0
- package/dist/urlHelpers.d.ts +7 -0
- package/dist/urlHelpers.js +22 -0
- package/dist/userMessages.d.ts +8 -0
- package/dist/userMessages.js +34 -0
- package/dist/users.d.ts +6 -0
- package/dist/users.js +32 -0
- package/package.json +33 -0
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FIELD_MAPS = exports.EVENT_DATA_PARSERS = exports.TagMemberData = exports.ScheduleDeleteData = exports.ScheduleModifyData = exports.GroupCreateApproveData = exports.WbVisibleConfigData = exports.BotGroupMessageData = exports.BotPrivateMessageData = exports.DataScopeData = exports.UserLogoutData = exports.ReportLocationData = exports.UaCertDeleteData = exports.UaCertCreateData = exports.AppUninstallData = exports.AppInstallData = exports.DeptDeleteData = exports.DeptModifyData = exports.DeptCreateData = exports.TelephoneTrackData = exports.TelephoneTrackCallerData = exports.StaffDeleteData = exports.StaffCreateData = exports.StaffModifyData = exports.StaffInfoData = exports.AccountUnsubscribeData = exports.AccountSubscribeData = exports.CallbackEvent = exports.CALLBACK_EVENT_TYPES = void 0;
|
|
37
|
+
exports.parseCallbackPayload = parseCallbackPayload;
|
|
38
|
+
exports.verifyCallbackSignature = verifyCallbackSignature;
|
|
39
|
+
exports.decryptCallbackPayload = decryptCallbackPayload;
|
|
40
|
+
exports.getCallbackEventTypes = getCallbackEventTypes;
|
|
41
|
+
const crypto = __importStar(require("crypto"));
|
|
42
|
+
exports.CALLBACK_EVENT_TYPES = {
|
|
43
|
+
account_message: "public_account",
|
|
44
|
+
account_subscribe: "public_account",
|
|
45
|
+
account_unsubscribe: "public_account",
|
|
46
|
+
staff_info: "staff",
|
|
47
|
+
staff_modify: "staff",
|
|
48
|
+
staff_create: "staff",
|
|
49
|
+
staff_delete: "staff",
|
|
50
|
+
dept_modify: "department",
|
|
51
|
+
dept_create: "department",
|
|
52
|
+
dept_delete: "department",
|
|
53
|
+
tag_member: "tag",
|
|
54
|
+
app_install_org: "app",
|
|
55
|
+
app_uninstall_org: "app",
|
|
56
|
+
bot_private_message: "bot",
|
|
57
|
+
bot_group_message: "bot",
|
|
58
|
+
group_create_approve: "group",
|
|
59
|
+
telephone_track: "notification",
|
|
60
|
+
ua_cert_create: "certificate",
|
|
61
|
+
ua_cert_delete: "certificate",
|
|
62
|
+
report_location: "location",
|
|
63
|
+
user_logout: "auth",
|
|
64
|
+
data_scope: "data_scope",
|
|
65
|
+
wb_visible_config: "workbench",
|
|
66
|
+
schedule_modify: "calendar",
|
|
67
|
+
schedule_delete: "calendar",
|
|
68
|
+
};
|
|
69
|
+
class CallbackEvent {
|
|
70
|
+
constructor(init) {
|
|
71
|
+
this.event_id = init.event_id ?? 0;
|
|
72
|
+
this.event_type = init.event_type ?? "";
|
|
73
|
+
this.category = init.category ?? "";
|
|
74
|
+
this.data = init.data ?? {};
|
|
75
|
+
this.app_id = init.app_id ?? "";
|
|
76
|
+
this.org_id = init.org_id ?? "";
|
|
77
|
+
}
|
|
78
|
+
toDict() {
|
|
79
|
+
const d = {
|
|
80
|
+
event_id: this.event_id,
|
|
81
|
+
event_type: this.event_type,
|
|
82
|
+
category: this.category,
|
|
83
|
+
app_id: this.app_id,
|
|
84
|
+
org_id: this.org_id,
|
|
85
|
+
};
|
|
86
|
+
if (this.data != null) {
|
|
87
|
+
d.data = typeof this.data === "object" && "toDict" in this.data
|
|
88
|
+
? this.data.toDict()
|
|
89
|
+
: this.data;
|
|
90
|
+
}
|
|
91
|
+
return d;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.CallbackEvent = CallbackEvent;
|
|
95
|
+
class AccountSubscribeData {
|
|
96
|
+
constructor(init) {
|
|
97
|
+
this.staff_id = init.staff_id ?? "";
|
|
98
|
+
this.create_time = init.create_time ?? "";
|
|
99
|
+
}
|
|
100
|
+
toDict() {
|
|
101
|
+
return { staff_id: this.staff_id, create_time: this.create_time };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.AccountSubscribeData = AccountSubscribeData;
|
|
105
|
+
class AccountUnsubscribeData {
|
|
106
|
+
constructor(init) {
|
|
107
|
+
this.staff_id = init.staff_id ?? "";
|
|
108
|
+
this.create_time = init.create_time ?? "";
|
|
109
|
+
}
|
|
110
|
+
toDict() {
|
|
111
|
+
return { staff_id: this.staff_id, create_time: this.create_time };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.AccountUnsubscribeData = AccountUnsubscribeData;
|
|
115
|
+
class StaffInfoData {
|
|
116
|
+
constructor(init) {
|
|
117
|
+
this.staff_id = init.staff_id ?? "";
|
|
118
|
+
this.name = init.name ?? "";
|
|
119
|
+
this.mobile = init.mobile ?? "";
|
|
120
|
+
this.state = init.state ?? "";
|
|
121
|
+
this.sex = init.sex ?? "";
|
|
122
|
+
this.email = init.email ?? "";
|
|
123
|
+
this.employee_id = init.employee_id ?? "";
|
|
124
|
+
this.avatar_id = init.avatar_id ?? "";
|
|
125
|
+
this.timestamp = init.timestamp ?? "";
|
|
126
|
+
}
|
|
127
|
+
toDict() {
|
|
128
|
+
const d = {};
|
|
129
|
+
for (const key of ["staff_id", "name", "mobile", "state", "sex", "email", "employee_id", "avatar_id", "timestamp"]) {
|
|
130
|
+
const v = this[key];
|
|
131
|
+
if (v)
|
|
132
|
+
d[key] = v;
|
|
133
|
+
}
|
|
134
|
+
return d;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.StaffInfoData = StaffInfoData;
|
|
138
|
+
class StaffModifyData {
|
|
139
|
+
constructor(init) {
|
|
140
|
+
this.staff_id = init.staff_id ?? "";
|
|
141
|
+
this.timestamp = init.timestamp ?? "";
|
|
142
|
+
}
|
|
143
|
+
toDict() {
|
|
144
|
+
return { staff_id: this.staff_id, timestamp: this.timestamp };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.StaffModifyData = StaffModifyData;
|
|
148
|
+
class StaffCreateData {
|
|
149
|
+
constructor(init) {
|
|
150
|
+
this.staff_id = init.staff_id ?? "";
|
|
151
|
+
this.timestamp = init.timestamp ?? "";
|
|
152
|
+
}
|
|
153
|
+
toDict() {
|
|
154
|
+
return { staff_id: this.staff_id, timestamp: this.timestamp };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.StaffCreateData = StaffCreateData;
|
|
158
|
+
class StaffDeleteData {
|
|
159
|
+
constructor(init) {
|
|
160
|
+
this.staff_id = init.staff_id ?? "";
|
|
161
|
+
this.timestamp = init.timestamp ?? "";
|
|
162
|
+
}
|
|
163
|
+
toDict() {
|
|
164
|
+
return { staff_id: this.staff_id, timestamp: this.timestamp };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.StaffDeleteData = StaffDeleteData;
|
|
168
|
+
class TelephoneTrackCallerData {
|
|
169
|
+
constructor(init) {
|
|
170
|
+
this.staff_id = init.staff_id ?? "";
|
|
171
|
+
this.country_code = init.country_code ?? "";
|
|
172
|
+
this.number = init.number ?? "";
|
|
173
|
+
}
|
|
174
|
+
toDict() {
|
|
175
|
+
const d = { staff_id: this.staff_id };
|
|
176
|
+
if (this.country_code)
|
|
177
|
+
d.country_code = this.country_code;
|
|
178
|
+
if (this.number)
|
|
179
|
+
d.number = this.number;
|
|
180
|
+
return d;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.TelephoneTrackCallerData = TelephoneTrackCallerData;
|
|
184
|
+
class TelephoneTrackData {
|
|
185
|
+
constructor(init) {
|
|
186
|
+
this.transaction_id = init.transaction_id ?? "";
|
|
187
|
+
this.attach = init.attach ?? "";
|
|
188
|
+
this.caller = init.caller ?? new TelephoneTrackCallerData({});
|
|
189
|
+
this.callee = init.callee ?? new TelephoneTrackCallerData({});
|
|
190
|
+
this.confirm_type = init.confirm_type ?? 0;
|
|
191
|
+
this.timestamp = init.timestamp ?? "";
|
|
192
|
+
}
|
|
193
|
+
toDict() {
|
|
194
|
+
const d = {
|
|
195
|
+
transaction_id: this.transaction_id,
|
|
196
|
+
caller: this.caller.toDict(),
|
|
197
|
+
callee: this.callee.toDict(),
|
|
198
|
+
confirm_type: this.confirm_type,
|
|
199
|
+
};
|
|
200
|
+
if (this.attach)
|
|
201
|
+
d.attach = this.attach;
|
|
202
|
+
if (this.timestamp)
|
|
203
|
+
d.timestamp = this.timestamp;
|
|
204
|
+
return d;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.TelephoneTrackData = TelephoneTrackData;
|
|
208
|
+
class DeptCreateData {
|
|
209
|
+
constructor(init) {
|
|
210
|
+
this.dept_id = init.dept_id ?? "";
|
|
211
|
+
this.timestamp = init.timestamp ?? "";
|
|
212
|
+
}
|
|
213
|
+
toDict() {
|
|
214
|
+
return { dept_id: this.dept_id, timestamp: this.timestamp };
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.DeptCreateData = DeptCreateData;
|
|
218
|
+
class DeptModifyData {
|
|
219
|
+
constructor(init) {
|
|
220
|
+
this.dept_id = init.dept_id ?? "";
|
|
221
|
+
this.timestamp = init.timestamp ?? "";
|
|
222
|
+
}
|
|
223
|
+
toDict() {
|
|
224
|
+
return { dept_id: this.dept_id, timestamp: this.timestamp };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
exports.DeptModifyData = DeptModifyData;
|
|
228
|
+
class DeptDeleteData {
|
|
229
|
+
constructor(init) {
|
|
230
|
+
this.dept_id = init.dept_id ?? "";
|
|
231
|
+
this.timestamp = init.timestamp ?? "";
|
|
232
|
+
}
|
|
233
|
+
toDict() {
|
|
234
|
+
return { dept_id: this.dept_id, timestamp: this.timestamp };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.DeptDeleteData = DeptDeleteData;
|
|
238
|
+
class AppInstallData {
|
|
239
|
+
constructor(init) {
|
|
240
|
+
this.org_id = init.org_id ?? "";
|
|
241
|
+
this.org_name = init.org_name ?? "";
|
|
242
|
+
this.timestamp = init.timestamp ?? "";
|
|
243
|
+
}
|
|
244
|
+
toDict() {
|
|
245
|
+
return { org_id: this.org_id, org_name: this.org_name, timestamp: this.timestamp };
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
exports.AppInstallData = AppInstallData;
|
|
249
|
+
class AppUninstallData {
|
|
250
|
+
constructor(init) {
|
|
251
|
+
this.org_id = init.org_id ?? "";
|
|
252
|
+
this.org_name = init.org_name ?? "";
|
|
253
|
+
this.timestamp = init.timestamp ?? "";
|
|
254
|
+
}
|
|
255
|
+
toDict() {
|
|
256
|
+
return { org_id: this.org_id, org_name: this.org_name, timestamp: this.timestamp };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
exports.AppUninstallData = AppUninstallData;
|
|
260
|
+
class UaCertCreateData {
|
|
261
|
+
constructor(init) {
|
|
262
|
+
this.staff_id = init.staff_id ?? "";
|
|
263
|
+
this.device_id = init.device_id ?? "";
|
|
264
|
+
this.ua_cert = init.ua_cert ?? "";
|
|
265
|
+
this.timestamp = init.timestamp ?? "";
|
|
266
|
+
}
|
|
267
|
+
toDict() {
|
|
268
|
+
return { staff_id: this.staff_id, device_id: this.device_id, ua_cert: this.ua_cert, timestamp: this.timestamp };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
exports.UaCertCreateData = UaCertCreateData;
|
|
272
|
+
class UaCertDeleteData {
|
|
273
|
+
constructor(init) {
|
|
274
|
+
this.staff_id = init.staff_id ?? "";
|
|
275
|
+
this.device_id = init.device_id ?? "";
|
|
276
|
+
this.timestamp = init.timestamp ?? "";
|
|
277
|
+
}
|
|
278
|
+
toDict() {
|
|
279
|
+
return { staff_id: this.staff_id, device_id: this.device_id, timestamp: this.timestamp };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
exports.UaCertDeleteData = UaCertDeleteData;
|
|
283
|
+
class ReportLocationData {
|
|
284
|
+
constructor(init) {
|
|
285
|
+
this.location_info = init.location_info ?? {};
|
|
286
|
+
}
|
|
287
|
+
toDict() {
|
|
288
|
+
return { location_info: this.location_info };
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
exports.ReportLocationData = ReportLocationData;
|
|
292
|
+
class UserLogoutData {
|
|
293
|
+
constructor(init) {
|
|
294
|
+
this.staff_id = init.staff_id ?? "";
|
|
295
|
+
this.device_id = init.device_id ?? "";
|
|
296
|
+
this.timestamp = init.timestamp ?? "";
|
|
297
|
+
}
|
|
298
|
+
toDict() {
|
|
299
|
+
return { staff_id: this.staff_id, device_id: this.device_id, timestamp: this.timestamp };
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
exports.UserLogoutData = UserLogoutData;
|
|
303
|
+
class DataScopeData {
|
|
304
|
+
constructor(init) {
|
|
305
|
+
this.dept_ids = init.dept_ids ?? [];
|
|
306
|
+
this.timestamp = init.timestamp ?? "";
|
|
307
|
+
}
|
|
308
|
+
toDict() {
|
|
309
|
+
return { dept_ids: this.dept_ids, timestamp: this.timestamp };
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
exports.DataScopeData = DataScopeData;
|
|
313
|
+
class BotPrivateMessageData {
|
|
314
|
+
constructor(init) {
|
|
315
|
+
this.from_id = init.from_id ?? "";
|
|
316
|
+
this.entry_id = init.entry_id ?? "";
|
|
317
|
+
this.msg_type = init.msg_type ?? "";
|
|
318
|
+
this.msg_data = init.msg_data ?? {};
|
|
319
|
+
}
|
|
320
|
+
toDict() {
|
|
321
|
+
return { from_id: this.from_id, entry_id: this.entry_id, msg_type: this.msg_type, msg_data: this.msg_data };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
exports.BotPrivateMessageData = BotPrivateMessageData;
|
|
325
|
+
class BotGroupMessageData {
|
|
326
|
+
constructor(init) {
|
|
327
|
+
this.from_id = init.from_id ?? "";
|
|
328
|
+
this.entry_id = init.entry_id ?? "";
|
|
329
|
+
this.msg_type = init.msg_type ?? "";
|
|
330
|
+
this.msg_data = init.msg_data ?? {};
|
|
331
|
+
this.group_id = init.group_id ?? "";
|
|
332
|
+
this.from_type = init.from_type ?? 0;
|
|
333
|
+
this.group_name = init.group_name ?? "";
|
|
334
|
+
this.bot_creator = init.bot_creator ?? "";
|
|
335
|
+
this.msg_id = init.msg_id ?? "";
|
|
336
|
+
this.bot_id = init.bot_id ?? "";
|
|
337
|
+
this.is_at_me = init.is_at_me ?? false;
|
|
338
|
+
this.is_at_all = init.is_at_all ?? false;
|
|
339
|
+
}
|
|
340
|
+
toDict() {
|
|
341
|
+
return {
|
|
342
|
+
from_id: this.from_id,
|
|
343
|
+
entry_id: this.entry_id,
|
|
344
|
+
msg_type: this.msg_type,
|
|
345
|
+
msg_data: this.msg_data,
|
|
346
|
+
group_id: this.group_id,
|
|
347
|
+
from_type: this.from_type,
|
|
348
|
+
group_name: this.group_name,
|
|
349
|
+
bot_creator: this.bot_creator,
|
|
350
|
+
msg_id: this.msg_id,
|
|
351
|
+
bot_id: this.bot_id,
|
|
352
|
+
is_at_me: this.is_at_me,
|
|
353
|
+
is_at_all: this.is_at_all,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
exports.BotGroupMessageData = BotGroupMessageData;
|
|
358
|
+
class WbVisibleConfigData {
|
|
359
|
+
constructor(init) {
|
|
360
|
+
this.entry_id = init.entry_id ?? "";
|
|
361
|
+
this.department_ids = init.department_ids ?? [];
|
|
362
|
+
this.staff_ids = init.staff_ids ?? [];
|
|
363
|
+
this.timestamp = init.timestamp ?? "";
|
|
364
|
+
this.is_test_mode_on = init.is_test_mode_on ?? false;
|
|
365
|
+
}
|
|
366
|
+
toDict() {
|
|
367
|
+
return {
|
|
368
|
+
entry_id: this.entry_id,
|
|
369
|
+
department_ids: this.department_ids,
|
|
370
|
+
staff_ids: this.staff_ids,
|
|
371
|
+
timestamp: this.timestamp,
|
|
372
|
+
is_test_mode_on: this.is_test_mode_on,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
exports.WbVisibleConfigData = WbVisibleConfigData;
|
|
377
|
+
class GroupCreateApproveData {
|
|
378
|
+
constructor(init) {
|
|
379
|
+
this.apply_request_id = init.apply_request_id ?? "";
|
|
380
|
+
this.group_id = init.group_id ?? "";
|
|
381
|
+
this.timestamp = init.timestamp ?? "";
|
|
382
|
+
}
|
|
383
|
+
toDict() {
|
|
384
|
+
return { apply_request_id: this.apply_request_id, group_id: this.group_id, timestamp: this.timestamp };
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
exports.GroupCreateApproveData = GroupCreateApproveData;
|
|
388
|
+
class ScheduleModifyData {
|
|
389
|
+
constructor(init) {
|
|
390
|
+
this.primary_schedule_id = init.primary_schedule_id ?? "";
|
|
391
|
+
this.schedule_id = init.schedule_id ?? "";
|
|
392
|
+
this.summary = init.summary ?? "";
|
|
393
|
+
this.description = init.description ?? "";
|
|
394
|
+
this.operation_type = init.operation_type ?? "";
|
|
395
|
+
this.current_time = init.current_time ?? 0;
|
|
396
|
+
this.repeat_type = init.repeat_type ?? "";
|
|
397
|
+
this.expire_date_type = init.expire_date_type ?? "";
|
|
398
|
+
this.all_day = init.all_day ?? "";
|
|
399
|
+
this.rule = init.rule ?? "";
|
|
400
|
+
this.rule_start_time = init.rule_start_time ?? 0;
|
|
401
|
+
this.rule_end_time = init.rule_end_time ?? 0;
|
|
402
|
+
this.start_time = init.start_time ?? {};
|
|
403
|
+
this.end_time = init.end_time ?? {};
|
|
404
|
+
this.operator = init.operator ?? "";
|
|
405
|
+
this.attendees = init.attendees ?? [];
|
|
406
|
+
this.timestamp = init.timestamp ?? "";
|
|
407
|
+
}
|
|
408
|
+
toDict() {
|
|
409
|
+
const d = {};
|
|
410
|
+
for (const key of [
|
|
411
|
+
"primary_schedule_id", "schedule_id", "summary", "description",
|
|
412
|
+
"operation_type", "current_time", "repeat_type", "expire_date_type",
|
|
413
|
+
"all_day", "rule", "rule_start_time", "rule_end_time",
|
|
414
|
+
"start_time", "end_time", "operator", "attendees", "timestamp",
|
|
415
|
+
]) {
|
|
416
|
+
const v = this[key];
|
|
417
|
+
if (v !== null && v !== undefined && (typeof v !== "string" || v)) {
|
|
418
|
+
d[key] = v;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return d;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
exports.ScheduleModifyData = ScheduleModifyData;
|
|
425
|
+
class ScheduleDeleteData {
|
|
426
|
+
constructor(init) {
|
|
427
|
+
this.primary_schedule_id = init.primary_schedule_id ?? "";
|
|
428
|
+
this.schedule_id = init.schedule_id ?? "";
|
|
429
|
+
this.summary = init.summary ?? "";
|
|
430
|
+
this.description = init.description ?? "";
|
|
431
|
+
this.operation_type = init.operation_type ?? "";
|
|
432
|
+
this.current_time = init.current_time ?? 0;
|
|
433
|
+
this.repeat_type = init.repeat_type ?? "";
|
|
434
|
+
this.expire_date_type = init.expire_date_type ?? "";
|
|
435
|
+
this.all_day = init.all_day ?? "";
|
|
436
|
+
this.rule = init.rule ?? "";
|
|
437
|
+
this.rule_start_time = init.rule_start_time ?? 0;
|
|
438
|
+
this.rule_end_time = init.rule_end_time ?? 0;
|
|
439
|
+
this.start_time = init.start_time ?? {};
|
|
440
|
+
this.end_time = init.end_time ?? {};
|
|
441
|
+
this.operator = init.operator ?? "";
|
|
442
|
+
this.timestamp = init.timestamp ?? "";
|
|
443
|
+
}
|
|
444
|
+
toDict() {
|
|
445
|
+
const d = {};
|
|
446
|
+
for (const key of [
|
|
447
|
+
"primary_schedule_id", "schedule_id", "summary", "description",
|
|
448
|
+
"operation_type", "current_time", "repeat_type", "expire_date_type",
|
|
449
|
+
"all_day", "rule", "rule_start_time", "rule_end_time",
|
|
450
|
+
"start_time", "end_time", "operator", "timestamp",
|
|
451
|
+
]) {
|
|
452
|
+
const v = this[key];
|
|
453
|
+
if (v !== null && v !== undefined && (typeof v !== "string" || v)) {
|
|
454
|
+
d[key] = v;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return d;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
exports.ScheduleDeleteData = ScheduleDeleteData;
|
|
461
|
+
class TagMemberData {
|
|
462
|
+
constructor(init) {
|
|
463
|
+
this.tag_id = init.tag_id ?? "";
|
|
464
|
+
this.timestamp = init.timestamp ?? "";
|
|
465
|
+
}
|
|
466
|
+
toDict() {
|
|
467
|
+
return { tag_id: this.tag_id, timestamp: this.timestamp };
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
exports.TagMemberData = TagMemberData;
|
|
471
|
+
exports.EVENT_DATA_PARSERS = {
|
|
472
|
+
account_subscribe: AccountSubscribeData,
|
|
473
|
+
account_unsubscribe: AccountUnsubscribeData,
|
|
474
|
+
staff_info: StaffInfoData,
|
|
475
|
+
staff_modify: StaffModifyData,
|
|
476
|
+
staff_create: StaffCreateData,
|
|
477
|
+
staff_delete: StaffDeleteData,
|
|
478
|
+
telephone_track: TelephoneTrackData,
|
|
479
|
+
dept_create: DeptCreateData,
|
|
480
|
+
dept_modify: DeptModifyData,
|
|
481
|
+
dept_delete: DeptDeleteData,
|
|
482
|
+
app_install_org: AppInstallData,
|
|
483
|
+
app_uninstall_org: AppUninstallData,
|
|
484
|
+
ua_cert_create: UaCertCreateData,
|
|
485
|
+
ua_cert_delete: UaCertDeleteData,
|
|
486
|
+
report_location: ReportLocationData,
|
|
487
|
+
user_logout: UserLogoutData,
|
|
488
|
+
data_scope: DataScopeData,
|
|
489
|
+
bot_private_message: BotPrivateMessageData,
|
|
490
|
+
bot_group_message: BotGroupMessageData,
|
|
491
|
+
wb_visible_config: WbVisibleConfigData,
|
|
492
|
+
group_create_approve: GroupCreateApproveData,
|
|
493
|
+
schedule_modify: ScheduleModifyData,
|
|
494
|
+
schedule_delete: ScheduleDeleteData,
|
|
495
|
+
tag_member: TagMemberData,
|
|
496
|
+
};
|
|
497
|
+
exports.FIELD_MAPS = {
|
|
498
|
+
account_subscribe: { staffId: "staff_id", createTime: "create_time" },
|
|
499
|
+
account_unsubscribe: { staffId: "staff_id", createTime: "create_time" },
|
|
500
|
+
staff_info: { staffId: "staff_id", name: "name", mobile: "mobile", state: "state", sex: "sex", email: "email", employId: "employee_id", employeeId: "employee_id", avatarId: "avatar_id", timestamp: "timestamp" },
|
|
501
|
+
staff_modify: { staffId: "staff_id", timestamp: "timestamp" },
|
|
502
|
+
staff_create: { staffId: "staff_id", timestamp: "timestamp" },
|
|
503
|
+
staff_delete: { staffId: "staff_id", timestamp: "timestamp" },
|
|
504
|
+
telephone_track: { transactionId: "transaction_id", attach: "attach", confirmType: "confirm_type", timestamp: "timestamp" },
|
|
505
|
+
dept_create: { deptId: "dept_id", timestamp: "timestamp" },
|
|
506
|
+
dept_modify: { deptId: "dept_id", timestamp: "timestamp" },
|
|
507
|
+
dept_delete: { deptId: "dept_id", timestamp: "timestamp" },
|
|
508
|
+
app_install_org: { orgId: "org_id", orgName: "org_name", timestamp: "timestamp" },
|
|
509
|
+
app_uninstall_org: { orgId: "org_id", orgName: "org_name", timestamp: "timestamp" },
|
|
510
|
+
ua_cert_create: { staffId: "staff_id", deviceId: "device_id", uaCert: "ua_cert", timestamp: "timestamp" },
|
|
511
|
+
ua_cert_delete: { staffId: "staff_id", deviceId: "device_id", timestamp: "timestamp" },
|
|
512
|
+
report_location: {},
|
|
513
|
+
user_logout: { staffId: "staff_id", deviceId: "device_id", timestamp: "timestamp" },
|
|
514
|
+
data_scope: { deptIds: "dept_ids", timestamp: "timestamp" },
|
|
515
|
+
bot_private_message: { from: "from_id", entryId: "entry_id", msgType: "msg_type", msgData: "msg_data" },
|
|
516
|
+
bot_group_message: { from: "from_id", entryId: "entry_id", msgType: "msg_type", msgData: "msg_data", groupId: "group_id", fromType: "from_type", groupName: "group_name", botCreator: "bot_creator", msgId: "msg_id", botId: "bot_id", isAtMe: "is_at_me", isAtAll: "is_at_all" },
|
|
517
|
+
wb_visible_config: { entryId: "entry_id", departmentIds: "department_ids", staffIds: "staff_ids", timestamp: "timestamp", isTestModeOn: "is_test_mode_on" },
|
|
518
|
+
group_create_approve: { applyRequestId: "apply_request_id", groupId: "group_id", timestamp: "timestamp" },
|
|
519
|
+
schedule_modify: { primaryScheduleId: "primary_schedule_id", scheduleId: "schedule_id", summary: "summary", description: "description", operationType: "operation_type", currentTime: "current_time", repeatType: "repeat_type", expireDateType: "expire_date_type", allDay: "all_day", rule: "rule", ruleStartTime: "rule_start_time", ruleEndTime: "rule_end_time", startTime: "start_time", endTime: "end_time", operator: "operator", attendees: "attendees", timestamp: "timestamp" },
|
|
520
|
+
schedule_delete: { primaryScheduleId: "primary_schedule_id", scheduleId: "schedule_id", summary: "summary", description: "description", operationType: "operation_type", currentTime: "current_time", repeatType: "repeat_type", expireDateType: "expire_date_type", allDay: "all_day", rule: "rule", ruleStartTime: "rule_start_time", ruleEndTime: "rule_end_time", startTime: "start_time", endTime: "end_time", operator: "operator", timestamp: "timestamp" },
|
|
521
|
+
tag_member: { tagId: "tag_id", timestamp: "timestamp" },
|
|
522
|
+
};
|
|
523
|
+
function _parseEventData(eventType, rawData) {
|
|
524
|
+
const parserCls = exports.EVENT_DATA_PARSERS[eventType];
|
|
525
|
+
if (!parserCls)
|
|
526
|
+
return rawData;
|
|
527
|
+
const fieldMap = exports.FIELD_MAPS[eventType] || {};
|
|
528
|
+
const kwargs = {};
|
|
529
|
+
for (const [apiKey, tsKey] of Object.entries(fieldMap)) {
|
|
530
|
+
const value = rawData[apiKey];
|
|
531
|
+
if (value !== undefined && value !== null)
|
|
532
|
+
kwargs[tsKey] = value;
|
|
533
|
+
}
|
|
534
|
+
if (eventType === "telephone_track") {
|
|
535
|
+
const callerRaw = rawData.caller || {};
|
|
536
|
+
const calleeRaw = rawData.callee || {};
|
|
537
|
+
const callerInfo = (typeof callerRaw === "object" && callerRaw.mobilePhone) || {};
|
|
538
|
+
const calleeInfo = (typeof calleeRaw === "object" && calleeRaw.mobilePhone) || {};
|
|
539
|
+
kwargs.caller = new TelephoneTrackCallerData({
|
|
540
|
+
staff_id: callerRaw.staffId || "",
|
|
541
|
+
country_code: callerInfo.countryCode || "",
|
|
542
|
+
number: callerInfo.number || "",
|
|
543
|
+
});
|
|
544
|
+
kwargs.callee = new TelephoneTrackCallerData({
|
|
545
|
+
staff_id: calleeRaw.staffId || "",
|
|
546
|
+
country_code: calleeInfo.countryCode || "",
|
|
547
|
+
number: calleeInfo.number || "",
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
if (eventType === "report_location") {
|
|
551
|
+
kwargs.location_info = rawData.locationInfo || {};
|
|
552
|
+
}
|
|
553
|
+
return new parserCls(kwargs);
|
|
554
|
+
}
|
|
555
|
+
function _parseDecryptedPayload(payload) {
|
|
556
|
+
const events = [];
|
|
557
|
+
let eventList = payload.events || [];
|
|
558
|
+
if (!Array.isArray(eventList))
|
|
559
|
+
eventList = [eventList];
|
|
560
|
+
const topAppId = payload.appId || "";
|
|
561
|
+
const topOrgId = payload.orgId || "";
|
|
562
|
+
for (const entry of eventList) {
|
|
563
|
+
const eventType = entry.eventType || entry.type || "";
|
|
564
|
+
const category = exports.CALLBACK_EVENT_TYPES[eventType] || "unknown";
|
|
565
|
+
let rawData = entry.data || {};
|
|
566
|
+
if (!rawData || (typeof rawData === "object" && Object.keys(rawData).length === 0) && eventType) {
|
|
567
|
+
rawData = entry;
|
|
568
|
+
}
|
|
569
|
+
const parsedData = _parseEventData(eventType, rawData);
|
|
570
|
+
events.push(new CallbackEvent({
|
|
571
|
+
event_id: entry.eventId || entry.id || 0,
|
|
572
|
+
event_type: eventType,
|
|
573
|
+
category,
|
|
574
|
+
data: parsedData,
|
|
575
|
+
app_id: entry.appId || topAppId,
|
|
576
|
+
org_id: entry.orgId || topOrgId,
|
|
577
|
+
}));
|
|
578
|
+
}
|
|
579
|
+
return events;
|
|
580
|
+
}
|
|
581
|
+
function parseCallbackPayload(input, options) {
|
|
582
|
+
const opts = options || {};
|
|
583
|
+
const encodingKey = opts.encodingKey || "";
|
|
584
|
+
if (encodingKey && input.trim().startsWith("{")) {
|
|
585
|
+
let payloadInner;
|
|
586
|
+
try {
|
|
587
|
+
payloadInner = JSON.parse(input);
|
|
588
|
+
}
|
|
589
|
+
catch {
|
|
590
|
+
payloadInner = {};
|
|
591
|
+
}
|
|
592
|
+
const dataEncrypt = payloadInner.dataEncrypt || "";
|
|
593
|
+
if (typeof dataEncrypt === "string" && dataEncrypt) {
|
|
594
|
+
input = dataEncrypt;
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
if (opts.verifySignature) {
|
|
598
|
+
if (!verifyCallbackSignature(opts.timestamp || "", opts.nonce || "", opts.signature || "", encodingKey, input, opts.callbackToken || "")) {
|
|
599
|
+
throw new Error("Callback signature verification failed");
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return _parseDecryptedPayload(payloadInner);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (encodingKey) {
|
|
606
|
+
if (opts.verifySignature) {
|
|
607
|
+
let dataEncrypt = input;
|
|
608
|
+
if (input.trim().startsWith("{")) {
|
|
609
|
+
const payloadInner = JSON.parse(input);
|
|
610
|
+
dataEncrypt = payloadInner.dataEncrypt || "";
|
|
611
|
+
}
|
|
612
|
+
if (!verifyCallbackSignature(opts.timestamp || "", opts.nonce || "", opts.signature || "", encodingKey, dataEncrypt, opts.callbackToken || "")) {
|
|
613
|
+
throw new Error("Callback signature verification failed");
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const decrypted = decryptCallbackPayload(input, encodingKey, opts.knownAppId || "");
|
|
617
|
+
const payload = {
|
|
618
|
+
orgId: decrypted.orgId || "",
|
|
619
|
+
appId: decrypted.appId || "",
|
|
620
|
+
events: decrypted.events || [],
|
|
621
|
+
};
|
|
622
|
+
return _parseDecryptedPayload(payload);
|
|
623
|
+
}
|
|
624
|
+
const payload = JSON.parse(input);
|
|
625
|
+
if ("dataEncrypt" in payload && !encodingKey) {
|
|
626
|
+
throw new Error("Encrypted callback payload requires encodingKey for decryption");
|
|
627
|
+
}
|
|
628
|
+
if (opts.verifySignature && !verifyCallbackSignature(opts.timestamp || "", opts.nonce || "", opts.signature || "", encodingKey, input, opts.callbackToken || "")) {
|
|
629
|
+
throw new Error("Callback signature verification failed");
|
|
630
|
+
}
|
|
631
|
+
return _parseDecryptedPayload(payload);
|
|
632
|
+
}
|
|
633
|
+
function verifyCallbackSignature(timestamp, nonce, signature, encodingKey, dataEncrypt = "", callbackToken) {
|
|
634
|
+
const token = callbackToken || encodingKey;
|
|
635
|
+
const params = [token, timestamp, nonce, dataEncrypt];
|
|
636
|
+
params.sort();
|
|
637
|
+
const joined = params.join("");
|
|
638
|
+
const computed = crypto.createHash("sha1").update(joined, "utf8").digest("hex");
|
|
639
|
+
return computed === signature;
|
|
640
|
+
}
|
|
641
|
+
function decryptCallbackPayload(encryptedData, encodingKey, knownAppId = "") {
|
|
642
|
+
const keyBytes = _decodeAesKey(encodingKey);
|
|
643
|
+
const aesKey = keyBytes.slice(0, 32);
|
|
644
|
+
const iv = keyBytes.length >= 48 ? keyBytes.slice(32, 48) : keyBytes.slice(0, 16);
|
|
645
|
+
const encBytes = Buffer.from(encryptedData, "base64");
|
|
646
|
+
const randomPrefixLen = encBytes.readUInt32BE(0);
|
|
647
|
+
const offset = 4 + randomPrefixLen + 32;
|
|
648
|
+
const aesPayload = encBytes.slice(offset);
|
|
649
|
+
const decipher = crypto.createDecipheriv("aes-256-cbc", aesKey, iv);
|
|
650
|
+
const decrypted = Buffer.concat([decipher.update(aesPayload), decipher.final()]);
|
|
651
|
+
const raw = _pkcs7Unpad(decrypted);
|
|
652
|
+
if (raw.length < 20) {
|
|
653
|
+
throw new Error(`Decrypted data too short: ${raw.length} bytes (need >= 20)`);
|
|
654
|
+
}
|
|
655
|
+
const randomStr = raw.slice(0, 16).toString("utf8");
|
|
656
|
+
const eventsLen = raw.readUInt32BE(16);
|
|
657
|
+
const totalAfterHeader = raw.length - 20;
|
|
658
|
+
if (totalAfterHeader < eventsLen) {
|
|
659
|
+
throw new Error(`Remaining data (${totalAfterHeader}B) shorter than declared events length (${eventsLen}B)`);
|
|
660
|
+
}
|
|
661
|
+
const eventsBytes = raw.slice(20 + totalAfterHeader - eventsLen);
|
|
662
|
+
const middleBytes = raw.slice(20, 20 + totalAfterHeader - eventsLen);
|
|
663
|
+
let eventsData = JSON.parse(eventsBytes.toString("utf8"));
|
|
664
|
+
if (!Array.isArray(eventsData))
|
|
665
|
+
eventsData = [eventsData];
|
|
666
|
+
const middleStr = middleBytes.toString("utf8");
|
|
667
|
+
const [orgId, appId] = _splitOrgAppId(middleStr, knownAppId);
|
|
668
|
+
return {
|
|
669
|
+
random: randomStr,
|
|
670
|
+
orgId,
|
|
671
|
+
appId,
|
|
672
|
+
events: eventsData,
|
|
673
|
+
length: eventsLen,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function _decodeAesKey(encodingKey) {
|
|
677
|
+
const padded = encodingKey + "=".repeat((-encodingKey.length) % 4);
|
|
678
|
+
const keyBytes = Buffer.from(padded, "base64");
|
|
679
|
+
if (keyBytes.length < 32) {
|
|
680
|
+
throw new Error(`Invalid AES key length: ${keyBytes.length} bytes (need >= 32)`);
|
|
681
|
+
}
|
|
682
|
+
return keyBytes;
|
|
683
|
+
}
|
|
684
|
+
function _pkcs7Unpad(data) {
|
|
685
|
+
const padLen = data[data.length - 1];
|
|
686
|
+
if (padLen < 1 || padLen > 32) {
|
|
687
|
+
throw new Error(`Invalid PKCS7 padding: ${padLen}`);
|
|
688
|
+
}
|
|
689
|
+
for (let i = 0; i < padLen; i++) {
|
|
690
|
+
if (data[data.length - 1 - i] !== padLen) {
|
|
691
|
+
throw new Error("Invalid PKCS7 padding bytes");
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return data.slice(0, data.length - padLen);
|
|
695
|
+
}
|
|
696
|
+
function _splitOrgAppId(middleStr, knownAppId = "") {
|
|
697
|
+
if (!middleStr)
|
|
698
|
+
return ["", ""];
|
|
699
|
+
if (knownAppId && middleStr.endsWith(knownAppId)) {
|
|
700
|
+
return [middleStr.slice(0, -knownAppId.length), knownAppId];
|
|
701
|
+
}
|
|
702
|
+
if (knownAppId) {
|
|
703
|
+
const idx = middleStr.indexOf(knownAppId);
|
|
704
|
+
if (idx >= 0)
|
|
705
|
+
return [middleStr.slice(0, idx), knownAppId];
|
|
706
|
+
}
|
|
707
|
+
return [middleStr, ""];
|
|
708
|
+
}
|
|
709
|
+
function getCallbackEventTypes() {
|
|
710
|
+
return exports.CALLBACK_EVENT_TYPES;
|
|
711
|
+
}
|
|
712
|
+
//# sourceMappingURL=callbacks.js.map
|