@pacoyang/wechaty-puppet-wechat 0.28.6 → 0.28.8
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/dist/examples/demo.js.map +1 -1
- package/dist/scripts/retry-unit-tests.js +2 -2
- package/dist/scripts/retry-unit-tests.js.map +1 -1
- package/dist/src/bridge.d.ts +82 -4
- package/dist/src/bridge.d.ts.map +1 -1
- package/dist/src/bridge.js +282 -8
- package/dist/src/bridge.js.map +1 -1
- package/dist/src/bridge.spec.js +8 -8
- package/dist/src/bridge.spec.js.map +1 -1
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +5 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/event.d.ts.map +1 -1
- package/dist/src/event.js +10 -2
- package/dist/src/event.js.map +1 -1
- package/dist/src/event.spec.js +1 -1
- package/dist/src/event.spec.js.map +1 -1
- package/dist/src/firer.d.ts.map +1 -1
- package/dist/src/firer.js +12 -3
- package/dist/src/firer.js.map +1 -1
- package/dist/src/firer.spec.js +4 -4
- package/dist/src/firer.spec.js.map +1 -1
- package/dist/src/mod.js +1 -1
- package/dist/src/puppet-wechat.d.ts +108 -3
- package/dist/src/puppet-wechat.d.ts.map +1 -1
- package/dist/src/puppet-wechat.js +524 -54
- package/dist/src/puppet-wechat.js.map +1 -1
- package/dist/src/puppet-wechat.spec.js +2 -2
- package/dist/src/puppet-wechat.spec.js.map +1 -1
- package/dist/src/pure-function-helpers/is-type.js +2 -3
- package/dist/src/pure-function-helpers/is-type.js.map +1 -1
- package/dist/src/pure-function-helpers/message-extname.js +1 -2
- package/dist/src/pure-function-helpers/message-extname.js.map +1 -1
- package/dist/src/pure-function-helpers/message-filename.js +2 -3
- package/dist/src/pure-function-helpers/message-filename.js.map +1 -1
- package/dist/src/pure-function-helpers/message-raw-payload-parser.js +6 -7
- package/dist/src/pure-function-helpers/message-raw-payload-parser.js.map +1 -1
- package/dist/src/pure-function-helpers/mod.js +6 -2
- package/dist/src/pure-function-helpers/mod.js.map +1 -1
- package/dist/src/pure-function-helpers/normalize-scan-status.js +1 -2
- package/dist/src/pure-function-helpers/normalize-scan-status.js.map +1 -1
- package/dist/src/pure-function-helpers/normalize-scan-status.spec.js +2 -2
- package/dist/src/pure-function-helpers/normalize-scan-status.spec.js.map +1 -1
- package/dist/src/pure-function-helpers/web-message-type.js +1 -2
- package/dist/src/pure-function-helpers/web-message-type.js.map +1 -1
- package/dist/src/pure-function-helpers/xml.js +6 -7
- package/dist/src/pure-function-helpers/xml.js.map +1 -1
- package/dist/src/session-monitor.d.ts +90 -0
- package/dist/src/session-monitor.d.ts.map +1 -0
- package/dist/src/session-monitor.js +173 -0
- package/dist/src/session-monitor.js.map +1 -0
- package/dist/src/session-monitor.spec.d.ts +3 -0
- package/dist/src/session-monitor.spec.d.ts.map +1 -0
- package/dist/src/session-monitor.spec.js +65 -0
- package/dist/src/session-monitor.spec.js.map +1 -0
- package/dist/src/version.spec.js +1 -1
- package/dist/src/version.spec.js.map +1 -1
- package/dist/src/web-schemas.js +2 -2
- package/dist/src/web-schemas.js.map +1 -1
- package/dist/src/wechaty-bro.js +58 -3
- package/dist/tests/puppeteer-contact.spec.js +1 -1
- package/dist/tests/puppeteer-contact.spec.js.map +1 -1
- package/dist/tests/puppeteer-friendship.spec.js +4 -4
- package/dist/tests/puppeteer-friendship.spec.js.map +1 -1
- package/dist/tests/puppeteer-message.spec.js +2 -2
- package/dist/tests/puppeteer-message.spec.js.map +1 -1
- package/dist/tests/puppeteer-room.spec.js +1 -1
- package/dist/tests/puppeteer-room.spec.js.map +1 -1
- package/dist/tests/puppeteer.spec.js +12 -12
- package/dist/tests/puppeteer.spec.js.map +1 -1
- package/package.json +1 -1
- package/src/bridge.ts +327 -4
- package/src/event.ts +9 -1
- package/src/firer.ts +12 -3
- package/src/puppet-wechat.ts +540 -13
- package/src/session-monitor.spec.ts +80 -0
- package/src/session-monitor.ts +219 -0
- package/src/wechaty-bro.js +58 -3
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the web session's own requests say about its health, read from
|
|
3
|
+
* outside the page.
|
|
4
|
+
*
|
|
5
|
+
* The web app long-polls `synccheck` (answered within ~25s) and fetches new
|
|
6
|
+
* messages with `webwxsync` when synccheck reports a change. It carries on
|
|
7
|
+
* after a failing webwxsync and only marks a failed send in its own chat
|
|
8
|
+
* window, so nothing tells Node. Bridge feeds the answers of those requests
|
|
9
|
+
* in here as the browser reports them; nothing is added to or changed in the
|
|
10
|
+
* page for this.
|
|
11
|
+
*/
|
|
12
|
+
export interface SyncCheckAnswer {
|
|
13
|
+
retcode: string;
|
|
14
|
+
selector: string;
|
|
15
|
+
time: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ApiAnswer {
|
|
18
|
+
api: string;
|
|
19
|
+
failures: number;
|
|
20
|
+
failingSince: null | number;
|
|
21
|
+
ret: string;
|
|
22
|
+
time: number;
|
|
23
|
+
}
|
|
24
|
+
export interface SessionHealth {
|
|
25
|
+
now: number;
|
|
26
|
+
since: number;
|
|
27
|
+
syncCheck: null | SyncCheckAnswer;
|
|
28
|
+
lastSync: null | ApiAnswer;
|
|
29
|
+
lastSend: null | ApiAnswer;
|
|
30
|
+
lastReceived: null | number;
|
|
31
|
+
sentWithoutSync: null | number;
|
|
32
|
+
}
|
|
33
|
+
export type WatchedCall = 'synccheck' | string;
|
|
34
|
+
/**
|
|
35
|
+
* The call a request URL makes, when it is one we watch.
|
|
36
|
+
*/
|
|
37
|
+
export declare function watchedCall(url: string): undefined | WatchedCall;
|
|
38
|
+
export declare function parseSyncCheck(body: string): undefined | {
|
|
39
|
+
retcode: string;
|
|
40
|
+
selector: string;
|
|
41
|
+
};
|
|
42
|
+
export declare const REFUSED_AFTER: number;
|
|
43
|
+
export declare const REFUSED_SYNC_FAILURES = 10;
|
|
44
|
+
export declare const REFUSED_SEND_FAILURES = 5;
|
|
45
|
+
/**
|
|
46
|
+
* Whether an API failure looks like the server refusing the session (numeric
|
|
47
|
+
* BaseResponse.Ret other than 1205 rate limiting), rather than a transient
|
|
48
|
+
* network error.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isRefusalCandidate(answer: null | ApiAnswer): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Why the session counts as refused by the server, or undefined while it
|
|
53
|
+
* does not. Only answers from the server count: a request that failed on the
|
|
54
|
+
* way (`request failed: ...`) says nothing about the session.
|
|
55
|
+
*/
|
|
56
|
+
export declare function refusedSession(health: SessionHealth): undefined | string;
|
|
57
|
+
export declare class SessionMonitor {
|
|
58
|
+
private since;
|
|
59
|
+
private selfId?;
|
|
60
|
+
private syncCheck;
|
|
61
|
+
private lastSync;
|
|
62
|
+
private lastSend;
|
|
63
|
+
private lastReceived;
|
|
64
|
+
private sentWithoutSync;
|
|
65
|
+
/**
|
|
66
|
+
* A new login: what the session before it left behind says nothing about
|
|
67
|
+
* this one.
|
|
68
|
+
*/
|
|
69
|
+
reset(selfId?: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* The page went to another document: requests in flight are gone, so a
|
|
72
|
+
* send still waiting for its sync would wait for ever.
|
|
73
|
+
*/
|
|
74
|
+
navigated(): void;
|
|
75
|
+
onSyncCheck(answer: {
|
|
76
|
+
retcode: string;
|
|
77
|
+
selector: string;
|
|
78
|
+
}): SyncCheckAnswer;
|
|
79
|
+
/**
|
|
80
|
+
* An answer of webwxsync or of a send. `started` is when its request left.
|
|
81
|
+
* `messages` are webwxsync's new messages.
|
|
82
|
+
*/
|
|
83
|
+
onApiAnswer(api: string, ret: string, started: number, messages?: Array<{
|
|
84
|
+
FromUserName?: string;
|
|
85
|
+
MsgType?: number;
|
|
86
|
+
}>): ApiAnswer;
|
|
87
|
+
health(): SessionHealth;
|
|
88
|
+
}
|
|
89
|
+
export default SessionMonitor;
|
|
90
|
+
//# sourceMappingURL=session-monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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,CAAE,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,MAAM,CAgBzE;AAED,qBAAa,cAAc;IAEzB,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAkB;IACjC,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,eAAe,CAAwB;IAE/C;;;OAGG;IACI,KAAK,CAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAUpC;;;OAGG;IACI,SAAS,IAAK,IAAI;IAIlB,WAAW,CAAE,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe;IAKnF;;;OAGG;IACI,WAAW,CAChB,GAAG,EAAQ,MAAM,EACjB,GAAG,EAAQ,MAAM,EACjB,OAAO,EAAI,MAAM,EACjB,QAAQ,GAAG,KAAK,CAAC;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAM,GACjE,SAAS;IA0CL,MAAM,IAAK,aAAa;CAYhC;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What the web session's own requests say about its health, read from
|
|
4
|
+
* outside the page.
|
|
5
|
+
*
|
|
6
|
+
* The web app long-polls `synccheck` (answered within ~25s) and fetches new
|
|
7
|
+
* messages with `webwxsync` when synccheck reports a change. It carries on
|
|
8
|
+
* after a failing webwxsync and only marks a failed send in its own chat
|
|
9
|
+
* window, so nothing tells Node. Bridge feeds the answers of those requests
|
|
10
|
+
* in here as the browser reports them; nothing is added to or changed in the
|
|
11
|
+
* page for this.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.SessionMonitor = exports.REFUSED_SEND_FAILURES = exports.REFUSED_SYNC_FAILURES = exports.REFUSED_AFTER = void 0;
|
|
15
|
+
exports.watchedCall = watchedCall;
|
|
16
|
+
exports.parseSyncCheck = parseSyncCheck;
|
|
17
|
+
exports.isRefusalCandidate = isRefusalCandidate;
|
|
18
|
+
exports.refusedSession = refusedSession;
|
|
19
|
+
// webwxsync and the calls that send a message, by the last part of their path
|
|
20
|
+
const API_REGEX = /\/(webwxsync|webwxsendmsg|webwxsendappmsg|webwxsendmsgimg|webwxsendvideomsg|webwxsendemoticon)(\?|$)/;
|
|
21
|
+
const SYNCCHECK_REGEX = /\/synccheck(\?|$)/;
|
|
22
|
+
// window.synccheck={retcode:"0",selector:"2"}
|
|
23
|
+
const SYNCCHECK_BODY_REGEX = /retcode\s*:\s*"?(\d+)"?\s*,\s*selector\s*:\s*"?(\d+)"?/;
|
|
24
|
+
// a notice that a chat was opened on the phone, not a message
|
|
25
|
+
const MSGTYPE_STATUSNOTIFY = 51;
|
|
26
|
+
/**
|
|
27
|
+
* The call a request URL makes, when it is one we watch.
|
|
28
|
+
*/
|
|
29
|
+
function watchedCall(url) {
|
|
30
|
+
if (SYNCCHECK_REGEX.test(url)) {
|
|
31
|
+
return 'synccheck';
|
|
32
|
+
}
|
|
33
|
+
const match = API_REGEX.exec(url);
|
|
34
|
+
return match ? match[1] : undefined;
|
|
35
|
+
}
|
|
36
|
+
function parseSyncCheck(body) {
|
|
37
|
+
const match = SYNCCHECK_BODY_REGEX.exec(body);
|
|
38
|
+
return match ? { retcode: match[1], selector: match[2] } : undefined;
|
|
39
|
+
}
|
|
40
|
+
// A session the server stopped serving keeps answering synccheck as usual,
|
|
41
|
+
// while webwxsync and every send answer an error (seen: BaseResponse.Ret 3,
|
|
42
|
+
// with the session's Sid still recognised: a wrong Sid answers 1101). The
|
|
43
|
+
// web app retries webwxsync a few times a second and never leaves, and a
|
|
44
|
+
// reload brings back the same refused session. Errors that last this long,
|
|
45
|
+
// with nothing succeeding in between, mean the session is gone.
|
|
46
|
+
exports.REFUSED_AFTER = 3 * 60 * 1000;
|
|
47
|
+
exports.REFUSED_SYNC_FAILURES = 10;
|
|
48
|
+
exports.REFUSED_SEND_FAILURES = 5;
|
|
49
|
+
// 1205 is the server asking us to send less; the web app logs out on it by
|
|
50
|
+
// itself.
|
|
51
|
+
const NOT_REFUSAL = ['1205'];
|
|
52
|
+
/**
|
|
53
|
+
* Whether an API failure looks like the server refusing the session (numeric
|
|
54
|
+
* BaseResponse.Ret other than 1205 rate limiting), rather than a transient
|
|
55
|
+
* network error.
|
|
56
|
+
*/
|
|
57
|
+
function isRefusalCandidate(answer) {
|
|
58
|
+
if (!answer || !answer.failingSince || answer.failures <= 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return /^-?\d+$/.test(answer.ret) && !NOT_REFUSAL.includes(answer.ret);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Why the session counts as refused by the server, or undefined while it
|
|
65
|
+
* does not. Only answers from the server count: a request that failed on the
|
|
66
|
+
* way (`request failed: ...`) says nothing about the session.
|
|
67
|
+
*/
|
|
68
|
+
function refusedSession(health) {
|
|
69
|
+
const checks = [
|
|
70
|
+
[health.lastSync, exports.REFUSED_SYNC_FAILURES],
|
|
71
|
+
[health.lastSend, exports.REFUSED_SEND_FAILURES],
|
|
72
|
+
];
|
|
73
|
+
for (const [answer, minFailures] of checks) {
|
|
74
|
+
if (!answer || !isRefusalCandidate(answer) || answer.failures < minFailures) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const failingSince = answer.failingSince;
|
|
78
|
+
const minutes = (health.now - failingSince) / 60000;
|
|
79
|
+
if (health.now - failingSince >= exports.REFUSED_AFTER) {
|
|
80
|
+
return `${answer.api} answered Ret ${answer.ret} ${answer.failures} times in a row for ${Math.round(minutes)} minutes`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
class SessionMonitor {
|
|
86
|
+
constructor() {
|
|
87
|
+
this.since = Date.now();
|
|
88
|
+
this.syncCheck = null;
|
|
89
|
+
this.lastSync = null;
|
|
90
|
+
this.lastSend = null;
|
|
91
|
+
this.lastReceived = null;
|
|
92
|
+
this.sentWithoutSync = null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A new login: what the session before it left behind says nothing about
|
|
96
|
+
* this one.
|
|
97
|
+
*/
|
|
98
|
+
reset(selfId) {
|
|
99
|
+
this.since = Date.now();
|
|
100
|
+
this.selfId = selfId;
|
|
101
|
+
this.syncCheck = null;
|
|
102
|
+
this.lastSync = null;
|
|
103
|
+
this.lastSend = null;
|
|
104
|
+
this.lastReceived = null;
|
|
105
|
+
this.sentWithoutSync = null;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The page went to another document: requests in flight are gone, so a
|
|
109
|
+
* send still waiting for its sync would wait for ever.
|
|
110
|
+
*/
|
|
111
|
+
navigated() {
|
|
112
|
+
this.sentWithoutSync = null;
|
|
113
|
+
}
|
|
114
|
+
onSyncCheck(answer) {
|
|
115
|
+
this.syncCheck = { ...answer, time: Date.now() };
|
|
116
|
+
return this.syncCheck;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* An answer of webwxsync or of a send. `started` is when its request left.
|
|
120
|
+
* `messages` are webwxsync's new messages.
|
|
121
|
+
*/
|
|
122
|
+
onApiAnswer(api, ret, started, messages = []) {
|
|
123
|
+
const isSync = api === 'webwxsync';
|
|
124
|
+
const previous = isSync ? this.lastSync : this.lastSend;
|
|
125
|
+
const now = Date.now();
|
|
126
|
+
const failures = ret === '0' ? 0 : ((previous && previous.failures) || 0) + 1;
|
|
127
|
+
const failingSince = ret === '0'
|
|
128
|
+
? null
|
|
129
|
+
: (previous && previous.failures && previous.failingSince) || now;
|
|
130
|
+
const answer = { api, failingSince, failures, ret, time: now };
|
|
131
|
+
if (isSync) {
|
|
132
|
+
this.lastSync = answer;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.lastSend = answer;
|
|
136
|
+
}
|
|
137
|
+
if (ret !== '0') {
|
|
138
|
+
return answer;
|
|
139
|
+
}
|
|
140
|
+
if (!isSync) {
|
|
141
|
+
// Each send makes the server report a change, which the page fetches
|
|
142
|
+
// with webwxsync within a second. That sync can be answered before the
|
|
143
|
+
// send's own answer arrives: one answered since the request left
|
|
144
|
+
// already covers it. Otherwise wait for one, from the first send on.
|
|
145
|
+
const sync = this.lastSync;
|
|
146
|
+
const covered = !!sync && sync.ret === '0' && sync.time > started;
|
|
147
|
+
if (!covered && !this.sentWithoutSync) {
|
|
148
|
+
this.sentWithoutSync = answer.time;
|
|
149
|
+
}
|
|
150
|
+
return answer;
|
|
151
|
+
}
|
|
152
|
+
this.sentWithoutSync = null;
|
|
153
|
+
const fromOthers = messages.some(m => m.MsgType !== MSGTYPE_STATUSNOTIFY && !!m.FromUserName && m.FromUserName !== this.selfId);
|
|
154
|
+
if (fromOthers) {
|
|
155
|
+
this.lastReceived = answer.time;
|
|
156
|
+
}
|
|
157
|
+
return answer;
|
|
158
|
+
}
|
|
159
|
+
health() {
|
|
160
|
+
return {
|
|
161
|
+
lastReceived: this.lastReceived,
|
|
162
|
+
lastSend: this.lastSend,
|
|
163
|
+
lastSync: this.lastSync,
|
|
164
|
+
now: Date.now(),
|
|
165
|
+
sentWithoutSync: this.sentWithoutSync,
|
|
166
|
+
since: this.since,
|
|
167
|
+
syncCheck: this.syncCheck,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.SessionMonitor = SessionMonitor;
|
|
172
|
+
exports.default = SessionMonitor;
|
|
173
|
+
//# sourceMappingURL=session-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-monitor.js","sourceRoot":"","sources":["../../src/session-monitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA6CH,k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AC;IAEM,MAAM;QACX,OAAO;YACL,YAAY,EAAM,IAAI,CAAC,YAAY;YACnC,QAAQ,EAAU,IAAI,CAAC,QAAQ;YAC/B,QAAQ,EAAU,IAAI,CAAC,QAAQ;YAC/B,GAAG,EAAe,IAAI,CAAC,GAAG,EAAE;YAC5B,eAAe,EAAG,IAAI,CAAC,eAAe;YACtC,KAAK,EAAa,IAAI,CAAC,KAAK;YAC5B,SAAS,EAAS,IAAI,CAAC,SAAS;SACjC,CAAA;IACH,CAAC;CAEF;AApGD,wCAoGC;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-monitor.spec.d.ts","sourceRoot":"","sources":["../../src/session-monitor.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const blue_tape_1 = __importDefault(require("blue-tape"));
|
|
8
|
+
const session_monitor_1 = require("./session-monitor");
|
|
9
|
+
function health(lastSync, lastSend = null, now = Date.now()) {
|
|
10
|
+
return {
|
|
11
|
+
lastReceived: null,
|
|
12
|
+
lastSend,
|
|
13
|
+
lastSync,
|
|
14
|
+
now,
|
|
15
|
+
sentWithoutSync: null,
|
|
16
|
+
since: now - 3600 * 1000,
|
|
17
|
+
syncCheck: null,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function answer(api, ret, failures, failingFor, now = Date.now()) {
|
|
21
|
+
return { api, failingSince: failures ? now - failingFor : null, failures, ret, time: now };
|
|
22
|
+
}
|
|
23
|
+
(0, blue_tape_1.default)('SessionMonitor remembers when a failing streak started', async (t) => {
|
|
24
|
+
const monitor = new session_monitor_1.SessionMonitor();
|
|
25
|
+
const first = monitor.onApiAnswer('webwxsync', '3', Date.now());
|
|
26
|
+
t.equal(first.failures, 1, 'first failure counted');
|
|
27
|
+
t.ok(first.failingSince, 'streak start set');
|
|
28
|
+
const second = monitor.onApiAnswer('webwxsync', '3', Date.now());
|
|
29
|
+
t.equal(second.failures, 2, 'second failure counted');
|
|
30
|
+
t.equal(second.failingSince, first.failingSince, 'streak start kept');
|
|
31
|
+
const ok = monitor.onApiAnswer('webwxsync', '0', Date.now());
|
|
32
|
+
t.equal(ok.failingSince, null, 'a success ends the streak');
|
|
33
|
+
const again = monitor.onApiAnswer('webwxsync', '3', Date.now());
|
|
34
|
+
t.ok(again.failingSince && again.failingSince >= ok.time, 'a new streak starts after the success');
|
|
35
|
+
});
|
|
36
|
+
(0, blue_tape_1.default)('refusedSession() on the 2026-12-06 pattern: webwxsync Ret 3 for minutes', async (t) => {
|
|
37
|
+
const reason = (0, session_monitor_1.refusedSession)(health(answer('webwxsync', '3', 40000, 4 * 3600 * 1000)));
|
|
38
|
+
t.ok(reason, 'refused');
|
|
39
|
+
t.ok(reason && /webwxsync answered Ret 3/.test(reason), 'reason names the call and Ret: ' + reason);
|
|
40
|
+
});
|
|
41
|
+
(0, blue_tape_1.default)('refusedSession() waits for both enough failures and enough time', async (t) => {
|
|
42
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(answer('webwxsync', '3', session_monitor_1.REFUSED_SYNC_FAILURES - 1, session_monitor_1.REFUSED_AFTER * 2))), 'too few failures');
|
|
43
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(answer('webwxsync', '3', 500, session_monitor_1.REFUSED_AFTER - 1000))), 'not long enough');
|
|
44
|
+
t.ok((0, session_monitor_1.refusedSession)(health(answer('webwxsync', '3', session_monitor_1.REFUSED_SYNC_FAILURES, session_monitor_1.REFUSED_AFTER))), 'both reached');
|
|
45
|
+
});
|
|
46
|
+
(0, blue_tape_1.default)('refusedSession() ignores what does not come from the server, and rate limiting', async (t) => {
|
|
47
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(answer('webwxsync', 'request failed: net::ERR_ABORTED', 500, session_monitor_1.REFUSED_AFTER * 2))), 'network failure');
|
|
48
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(answer('webwxsync', '1205', 500, session_monitor_1.REFUSED_AFTER * 2))), '1205 is rate limiting');
|
|
49
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(answer('webwxsync', '0', 0, 0))), 'working session');
|
|
50
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(null)), 'nothing seen yet');
|
|
51
|
+
});
|
|
52
|
+
(0, blue_tape_1.default)('refusedSession() on sends alone', async (t) => {
|
|
53
|
+
const sync = answer('webwxsync', '0', 0, 0);
|
|
54
|
+
t.notOk((0, session_monitor_1.refusedSession)(health(sync, answer('webwxsendmsg', '3', session_monitor_1.REFUSED_SEND_FAILURES - 1, session_monitor_1.REFUSED_AFTER * 2))), 'too few sends');
|
|
55
|
+
t.ok((0, session_monitor_1.refusedSession)(health(sync, answer('webwxsendmsg', '3', session_monitor_1.REFUSED_SEND_FAILURES, session_monitor_1.REFUSED_AFTER))), 'sends refused for long enough');
|
|
56
|
+
});
|
|
57
|
+
(0, blue_tape_1.default)('isRefusalCandidate() distinguishes server refusals from rate limiting and network errors', async (t) => {
|
|
58
|
+
t.ok((0, session_monitor_1.isRefusalCandidate)(answer('webwxsync', '3', 3, 60 * 1000)), 'Ret 3 is a refusal candidate');
|
|
59
|
+
t.ok((0, session_monitor_1.isRefusalCandidate)(answer('webwxsendappmsg', '-1', 3, 60 * 1000)), 'Ret -1 is a refusal candidate');
|
|
60
|
+
t.notOk((0, session_monitor_1.isRefusalCandidate)(answer('webwxsendmsg', '1205', 3, 60 * 1000)), '1205 is rate limiting');
|
|
61
|
+
t.notOk((0, session_monitor_1.isRefusalCandidate)(answer('webwxsync', 'request failed: net::ERR_ABORTED', 3, 60 * 1000)), 'network error is not a refusal');
|
|
62
|
+
t.notOk((0, session_monitor_1.isRefusalCandidate)(answer('webwxsync', '0', 0, 0)), 'success is not a refusal');
|
|
63
|
+
t.notOk((0, session_monitor_1.isRefusalCandidate)(null), 'null is not a refusal');
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=session-monitor.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-monitor.spec.js","sourceRoot":"","sources":["../../src/session-monitor.spec.ts"],"names":[],"mappings":";;;;;;AAEA,0DAA6B;AAE7B,uDAS4C;AAE5C,SAAS,MAAM,CAAE,QAA0B,EAAE,WAA6B,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAC9F,OAAO;QACL,YAAY,EAAM,IAAI;QACtB,QAAQ;QACR,QAAQ;QACR,GAAG;QACH,eAAe,EAAG,IAAI;QACtB,KAAK,EAAa,GAAG,GAAG,IAAI,GAAG,IAAI;QACnC,SAAS,EAAS,IAAI;KACvB,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAE,GAAW,EAAE,GAAW,EAAE,QAAgB,EAAE,UAAkB,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAC/F,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAC5F,CAAC;AAED,IAAA,mBAAI,EAAC,wDAAwD,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IACvE,MAAM,OAAO,GAAG,IAAI,gCAAc,EAAE,CAAA;IACpC,MAAM,KAAK,GAAK,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACjE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,uBAAuB,CAAC,CAAA;IACnD,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,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CAAC,WAAW,EAAE,kCAAkC,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,gCAAgC,CAAC,CAAA;IACpI,CAAC,CAAC,KAAK,CAAC,IAAA,oCAAkB,EAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAA;IACvF,CAAC,CAAC,KAAK,CAAC,IAAA,oCAAkB,EAAC,IAAI,CAAC,EAAE,uBAAuB,CAAC,CAAA;AAC5D,CAAC,CAAC,CAAA"}
|
package/dist/src/version.spec.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
// tslint:disable:no-shadowed-variable
|
|
8
8
|
const blue_tape_1 = __importDefault(require("blue-tape"));
|
|
9
9
|
const version_1 = require("./version");
|
|
10
|
-
blue_tape_1.default('Make sure the VERSION is fresh in source code', async (t) => {
|
|
10
|
+
(0, blue_tape_1.default)('Make sure the VERSION is fresh in source code', async (t) => {
|
|
11
11
|
t.equal(version_1.VERSION, '0.0.0', 'version should be 0.0.0 in source code, only updated before publish to NPM');
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=version.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.spec.js","sourceRoot":"","sources":["../../src/version.spec.ts"],"names":[],"mappings":";;;;;;AAEA,sCAAsC;AACtC,0DAA6B;AAE7B,uCAAmC;AAEnC,mBAAI,
|
|
1
|
+
{"version":3,"file":"version.spec.js","sourceRoot":"","sources":["../../src/version.spec.ts"],"names":[],"mappings":";;;;;;AAEA,sCAAsC;AACtC,0DAA6B;AAE7B,uCAAmC;AAEnC,IAAA,mBAAI,EAAC,+CAA+C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAChE,CAAC,CAAC,KAAK,CAAC,iBAAO,EAAE,OAAO,EAAE,4EAA4E,CAAC,CAAA;AACzG,CAAC,CAAC,CAAA"}
|
package/dist/src/web-schemas.js
CHANGED
|
@@ -70,7 +70,7 @@ var WebAppMsgType;
|
|
|
70
70
|
WebAppMsgType[WebAppMsgType["TRANSFERS"] = 2000] = "TRANSFERS";
|
|
71
71
|
WebAppMsgType[WebAppMsgType["RED_ENVELOPES"] = 2001] = "RED_ENVELOPES";
|
|
72
72
|
WebAppMsgType[WebAppMsgType["READER_TYPE"] = 100001] = "READER_TYPE";
|
|
73
|
-
})(WebAppMsgType
|
|
73
|
+
})(WebAppMsgType || (exports.WebAppMsgType = WebAppMsgType = {}));
|
|
74
74
|
/**
|
|
75
75
|
*
|
|
76
76
|
* Enum for MsgType values.
|
|
@@ -114,5 +114,5 @@ var WebMessageType;
|
|
|
114
114
|
WebMessageType[WebMessageType["SYSNOTICE"] = 9999] = "SYSNOTICE";
|
|
115
115
|
WebMessageType[WebMessageType["SYS"] = 10000] = "SYS";
|
|
116
116
|
WebMessageType[WebMessageType["RECALLED"] = 10002] = "RECALLED";
|
|
117
|
-
})(WebMessageType
|
|
117
|
+
})(WebMessageType || (exports.WebMessageType = WebMessageType = {}));
|
|
118
118
|
//# sourceMappingURL=web-schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-schemas.js","sourceRoot":"","sources":["../../src/web-schemas.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAmJH,gGAAgG;AAChG,yFAAyF;AACzF,kFAAkF;AAElF,+HAA+H;AAE/H,oCAAoC;AACpC,oCAAoC;AACpC,4CAA4C;AAC5C,2CAA2C;AAC3C,IAAI;AAEJ;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,IAAY,aAkBX;AAlBD,WAAY,aAAa;IACvB,iDAA4B,CAAA;IAC5B,+CAA4B,CAAA;IAC5B,mDAA4B,CAAA;IAC5B,mDAA4B,CAAA;IAC5B,+CAA4B,CAAA;IAC5B,qDAA4B,CAAA;IAC5B,iDAA4B,CAAA;IAC5B,mDAA4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kDAAwB,CAAA;IACxB,0DAAwB,CAAA;IACxB,oEAAwB,CAAA;IACxB,gEAAwB,CAAA;IACxB,gEAAwB,CAAA;IACxB,gEAAwB,CAAA;IACxB,gEAA0B,CAAA;IAC1B,qDAA2B,CAAA;IAC3B,+DAA2B,CAAA;AAC7B,CAAC,EAnBW,cAAc,8BAAd,cAAc,QAmBzB"}
|
package/dist/src/wechaty-bro.js
CHANGED
|
@@ -268,6 +268,57 @@
|
|
|
268
268
|
setTimeout(() => checkScan(), 1000)
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
/**
|
|
272
|
+
* chatFactory.sendMessage() posts in the background and later sets the
|
|
273
|
+
* message's MMStatus to success or failure. Wait for that, so a message
|
|
274
|
+
* WeChat refused is reported as failed instead of sent.
|
|
275
|
+
*/
|
|
276
|
+
// the web app retries a send 3 times, 15s each, before it marks it failed
|
|
277
|
+
const SEND_CONFIRM_TIMEOUT = 75 * 1000
|
|
278
|
+
|
|
279
|
+
function sentResult (m) {
|
|
280
|
+
const confFactory = WechatyBro.glue.confFactory
|
|
281
|
+
const started = Date.now()
|
|
282
|
+
return new Promise(function (resolve) {
|
|
283
|
+
(function check () {
|
|
284
|
+
if (m.MMStatus === confFactory.MSG_SEND_STATUS_SUCC) {
|
|
285
|
+
return resolve(true)
|
|
286
|
+
}
|
|
287
|
+
if (m.MMStatus === confFactory.MSG_SEND_STATUS_FAIL) {
|
|
288
|
+
return resolve('WeChat refused the message')
|
|
289
|
+
}
|
|
290
|
+
if (Date.now() - started > SEND_CONFIRM_TIMEOUT) {
|
|
291
|
+
return resolve('no answer from WeChat in ' + (SEND_CONFIRM_TIMEOUT / 1000) + 's')
|
|
292
|
+
}
|
|
293
|
+
setTimeout(check, 200)
|
|
294
|
+
})()
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function health () {
|
|
299
|
+
const loginScope = WechatyBro.glue.loginScope
|
|
300
|
+
let roomCount = null
|
|
301
|
+
try {
|
|
302
|
+
roomCount = WechatyBro.glue.contactFactory.getAllChatroomContact().length
|
|
303
|
+
} catch (e) {}
|
|
304
|
+
return {
|
|
305
|
+
loginState : loginState(),
|
|
306
|
+
loginCode : loginScope ? loginScope.code : null,
|
|
307
|
+
now : Date.now(),
|
|
308
|
+
roomCount,
|
|
309
|
+
userName : getUserName(),
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function roomTopicList () {
|
|
314
|
+
return WechatyBro.glue.contactFactory.getAllChatroomContact()
|
|
315
|
+
.map(r => ({
|
|
316
|
+
id : r.UserName,
|
|
317
|
+
memberCount : (r.MemberList || []).length,
|
|
318
|
+
topic : r.NickName || '',
|
|
319
|
+
}))
|
|
320
|
+
}
|
|
321
|
+
|
|
271
322
|
function ding (data) {
|
|
272
323
|
log('recv ding')
|
|
273
324
|
return data || 'dong'
|
|
@@ -431,11 +482,11 @@
|
|
|
431
482
|
|
|
432
483
|
chatFactory.appendMessage(m)
|
|
433
484
|
chatFactory.sendMessage(m)
|
|
485
|
+
return sentResult(m)
|
|
434
486
|
} catch (e) {
|
|
435
487
|
log('sendMedia() exception: ' + e.message)
|
|
436
488
|
return false
|
|
437
489
|
}
|
|
438
|
-
return true
|
|
439
490
|
}
|
|
440
491
|
|
|
441
492
|
function forward (baseData, patchData) {
|
|
@@ -455,11 +506,11 @@
|
|
|
455
506
|
|
|
456
507
|
chatFactory.appendMessage(m)
|
|
457
508
|
chatFactory.sendMessage(m)
|
|
509
|
+
return sentResult(m)
|
|
458
510
|
} catch (e) {
|
|
459
511
|
log('forward() exception: ' + e.message)
|
|
460
512
|
return false
|
|
461
513
|
}
|
|
462
|
-
return true
|
|
463
514
|
}
|
|
464
515
|
|
|
465
516
|
function send (ToUserName, Content) {
|
|
@@ -478,11 +529,11 @@
|
|
|
478
529
|
})
|
|
479
530
|
chatFactory.appendMessage(m)
|
|
480
531
|
chatFactory.sendMessage(m)
|
|
532
|
+
return sentResult(m)
|
|
481
533
|
} catch (e) {
|
|
482
534
|
log('send() exception: ' + e.message)
|
|
483
535
|
return false
|
|
484
536
|
}
|
|
485
|
-
return true
|
|
486
537
|
}
|
|
487
538
|
|
|
488
539
|
function getMessage (id) {
|
|
@@ -811,6 +862,7 @@
|
|
|
811
862
|
|
|
812
863
|
scanCode : null,
|
|
813
864
|
heartBeatTimmer : null,
|
|
865
|
+
|
|
814
866
|
},
|
|
815
867
|
|
|
816
868
|
// funcs
|
|
@@ -846,6 +898,9 @@
|
|
|
846
898
|
roomList,
|
|
847
899
|
roomDelMember,
|
|
848
900
|
roomModTopic,
|
|
901
|
+
roomTopicList,
|
|
902
|
+
|
|
903
|
+
health,
|
|
849
904
|
|
|
850
905
|
// for Friend Request
|
|
851
906
|
verifyUserRequest,
|
|
@@ -30,7 +30,7 @@ const tstest_1 = require("tstest");
|
|
|
30
30
|
// } from 'clone-class'
|
|
31
31
|
const config_1 = require("../src/config");
|
|
32
32
|
const puppet_wechat_1 = __importDefault(require("../src/puppet-wechat"));
|
|
33
|
-
tstest_1.test('Contact smoke testing', async (t) => {
|
|
33
|
+
(0, tstest_1.test)('Contact smoke testing', async (t) => {
|
|
34
34
|
/* tslint:disable:variable-name */
|
|
35
35
|
const UserName = '@0bb3e4dd746fdbd4a80546aef66f4085';
|
|
36
36
|
const NickName = 'NickNameTest';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-contact.spec.js","sourceRoot":"","sources":["../../tests/puppeteer-contact.spec.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,8BAA8B;AAC9B,sCAAsC;;;;;AAEtC,mCAAoC;AACpC,WAAW;AACX,gBAAgB;AAChB,qCAAqC;AAErC,0CAEmC;AAEnC,yEAAgD;AAEhD,aAAI,
|
|
1
|
+
{"version":3,"file":"puppeteer-contact.spec.js","sourceRoot":"","sources":["../../tests/puppeteer-contact.spec.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH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c,CAAC,KAAK,EAAG,UAAU,EAAE,yCAAyC,CAAC,CAAA;IAElF,OAAO,CAAC,OAAO,EAAE,CAAA;IAEjB,8DAA8D;IAC9D,6DAA6D;IAE7D,4DAA4D;IAC5D,8DAA8D;AAChE,CAAC,CAAC,CAAA"}
|
|
@@ -38,7 +38,7 @@ class PuppetTest extends puppet_wechat_1.PuppetWeChat {
|
|
|
38
38
|
return super.messageRawPayload(id);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
tstest_1.test('PuppetWeChatFriendship.receive smoke testing', async (t) => {
|
|
41
|
+
(0, tstest_1.test)('PuppetWeChatFriendship.receive smoke testing', async (t) => {
|
|
42
42
|
const puppet = new PuppetTest();
|
|
43
43
|
// const wechaty = new WechatyTest({ puppet })
|
|
44
44
|
// wechaty.initPuppetAccessory(puppet)
|
|
@@ -56,7 +56,7 @@ tstest_1.test('PuppetWeChatFriendship.receive smoke testing', async (t) => {
|
|
|
56
56
|
hello,
|
|
57
57
|
id,
|
|
58
58
|
ticket,
|
|
59
|
-
timestamp: Math.floor(Date.now() / 1000),
|
|
59
|
+
timestamp: Math.floor(Date.now() / 1000), // in seconds
|
|
60
60
|
type,
|
|
61
61
|
};
|
|
62
62
|
const sandbox = tstest_1.sinon.createSandbox();
|
|
@@ -75,7 +75,7 @@ tstest_1.test('PuppetWeChatFriendship.receive smoke testing', async (t) => {
|
|
|
75
75
|
t.equal(friendshipPayload.type, wechaty_puppet_1.FriendshipType.Receive, 'should be receive type');
|
|
76
76
|
sandbox.restore();
|
|
77
77
|
});
|
|
78
|
-
tstest_1.test('PuppetWeChatFriendship.confirm smoke testing', async (t) => {
|
|
78
|
+
(0, tstest_1.test)('PuppetWeChatFriendship.confirm smoke testing', async (t) => {
|
|
79
79
|
const CONTACT_ID = 'contact-id';
|
|
80
80
|
const puppet = new PuppetTest();
|
|
81
81
|
// const wechaty = new WechatyTest({ puppet })
|
|
@@ -87,7 +87,7 @@ tstest_1.test('PuppetWeChatFriendship.confirm smoke testing', async (t) => {
|
|
|
87
87
|
const friendshipPayload = {
|
|
88
88
|
contactId: CONTACT_ID,
|
|
89
89
|
id: 'id',
|
|
90
|
-
timestamp: Math.floor(Date.now() / 1000),
|
|
90
|
+
timestamp: Math.floor(Date.now() / 1000), // in seconds
|
|
91
91
|
type: wechaty_puppet_1.FriendshipType.Confirm,
|
|
92
92
|
};
|
|
93
93
|
const sandbox = tstest_1.sinon.createSandbox();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-friendship.spec.js","sourceRoot":"","sources":["../../tests/puppeteer-friendship.spec.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,mCAGyB;AAEzB,mDAG+C;AAE/C,wDAEqD;AAKrD,sCAAsC;AACtC,wDAAwD;AACxD,wCAAwC;AACxC,MAAM;AACN,IAAI;AAEJ,MAAM,UAAW,SAAQ,4BAAY;IAE5B,iBAAiB,CAAE,EAAU;QAClC,OAAO,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC;IAEM,cAAc,CAAE,EAAU;QAC/B,OAAO,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;IACjC,CAAC;IAEM,iBAAiB,CAAE,EAAU;QAClC,OAAO,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC;CAEF;AAED,aAAI,
|
|
1
|
+
{"version":3,"file":"puppeteer-friendship.spec.js","sourceRoot":"","sources":["../../tests/puppeteer-friendship.spec.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,mCAGyB;AAEzB,mDAG+C;AAE/C,wDAEqD;AAKrD,sCAAsC;AACtC,wDAAwD;AACxD,wCAAwC;AACxC,MAAM;AACN,IAAI;AAEJ,MAAM,UAAW,SAAQ,4BAAY;IAE5B,iBAAiB,CAAE,EAAU;QAClC,OAAO,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,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AC5E,6EAA6E;IAE7E,8DAA8D;IAC9D,oBAAoB;IACpB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;IAEvE,CAAC,CAAC,IAAI,CAAC,+DAA+D,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,8BAA8B,CAAC,CAAA;IAEnI,2CAA2C;IAC3C,mBAAmB;IACnB,MAAM,kBAAkB,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAE/D,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,EAAE,0BAA0B,CAAC,CAAA;IAC1E,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,+BAAc,CAAC,OAAO,EAAE,wBAAwB,CAAC,CAAA;IAE/E,OAAO,CAAC,OAAO,EAAE,CAAA;AACnB,CAAC,CAAC,CAAA"}
|
|
@@ -46,7 +46,7 @@ class PuppetTest extends puppet_wechat_1.PuppetWeChat {
|
|
|
46
46
|
// class PuppetWeChatTest extends PuppetWeChat {
|
|
47
47
|
// public id?: string = undefined
|
|
48
48
|
// }
|
|
49
|
-
tstest_1.test('constructor()', async (t) => {
|
|
49
|
+
(0, tstest_1.test)('constructor()', async (t) => {
|
|
50
50
|
const puppet = new PuppetTest();
|
|
51
51
|
// const wechaty = new WechatyTest({ puppet })
|
|
52
52
|
// wechaty.initPuppetAccessory(puppet)
|
|
@@ -83,7 +83,7 @@ tstest_1.test('constructor()', async (t) => {
|
|
|
83
83
|
});
|
|
84
84
|
// Issue #445
|
|
85
85
|
// XXX have to use test.serial() because mockGetContact can not be parallel
|
|
86
|
-
tstest_1.test('ready()', async (t) => {
|
|
86
|
+
(0, tstest_1.test)('ready()', async (t) => {
|
|
87
87
|
// must different with other rawData, because Contact class with load() will cache the result. or use Contact.resetPool()
|
|
88
88
|
/* tslint:disable:max-line-length */
|
|
89
89
|
const rawPayload = JSON.parse('{"MsgId":"3009511950433684462","FromUserName":"@0748ee480711bf20af91c298a0d7dcc77c30a680c1004157386b81cf13474823","ToUserName":"@b58f91e0c5c9e841e290d862ddb63c14","MsgType":1,"Content":"哈哈","Status":3,"ImgStatus":1,"CreateTime":1462887888,"VoiceLength":0,"PlayLength":0,"FileName":"","FileSize":"","MediaId":"","Url":"","AppMsgType":0,"StatusNotifyCode":0,"StatusNotifyUserName":"","RecommendInfo":{"UserName":"","NickName":"","QQNum":0,"Province":"","City":"","Content":"","Signature":"","Alias":"","Scene":0,"VerifyFlag":0,"AttrStatus":0,"Sex":0,"Ticket":"","OpCode":0},"ForwardFlag":0,"AppInfo":{"AppID":"","Type":0},"HasProductId":0,"Ticket":"","ImgHeight":0,"ImgWidth":0,"SubMsgType":0,"NewMsgId":3009511950433684500,"MMPeerUserName":"@0748ee480711bf20af91c298a0d7dcc77c30a680c1004157386b81cf13474823","MMDigest":"哈哈","MMIsSend":false,"MMIsChatRoom":false,"MMUnread":false,"LocalID":"3009511950433684462","ClientMsgId":"3009511950433684462","MMActualContent":"哈哈","MMActualSender":"@0748ee480711bf20af91c298a0d7dcc77c30a680c1004157386b81cf13474823","MMDigestTime":"21:44","MMDisplayTime":1462887888,"MMTime":"21:44","_h":104,"_index":0,"_offsetTop":0,"$$hashKey":"098"}');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-message.spec.js","sourceRoot":"","sources":["../../tests/puppeteer-message.spec.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,sCAAsC;AACtC,sCAAsC;AACtC,8BAA8B;AAC9B,6CAA6C;AAE7C,mCAGyB;AAEzB,0CAGsC;AAEtC,mDAGuC;AAEvC,wDAEqD;AAMrD,sCAAsC;AACtC,wDAAwD;AACxD,wCAAwC;AACxC,MAAM;AACN,IAAI;AAEJ,MAAM,UAAW,SAAQ,4BAAY;IAE5B,iBAAiB,CAAE,E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