zalo-toolkit 1.0.9 → 1.1.1
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/apis/getAliasList.js +0 -1
- package/dist/apis/listen.js +4 -2
- package/dist/cjs/apis/getAliasList.cjs +0 -1
- package/dist/cjs/apis/listen.cjs +3 -1
- package/dist/cjs/utils.cjs +9 -0
- package/dist/cjs/zalo.cjs +0 -2
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +8 -0
- package/dist/zalo.js +0 -2
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
|
2
2
|
import { apiFactory } from "../utils.js";
|
|
3
3
|
export const getAliasListFactory = apiFactory()((api, ctx, utils) => {
|
|
4
4
|
return async function getListAlias(page = 1, limit = 200) {
|
|
5
|
-
console.log('getListAlias', page, ctx.uid);
|
|
6
5
|
try {
|
|
7
6
|
const params = {
|
|
8
7
|
page,
|
package/dist/apis/listen.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Reaction } from '../models/Reaction.js';
|
|
|
8
8
|
import { GroupSeenMessage, UserSeenMessage } from '../models/SeenMessage.js';
|
|
9
9
|
import { GroupTyping, UserTyping } from '../models/Typing.js';
|
|
10
10
|
import { Undo } from '../models/Undo.js';
|
|
11
|
-
import { decodeEventData, FibonacciRetry, getFriendEventType, getGroupEventType, hasOwn, logger, looksLikeJson, makeURL } from '../utils.js';
|
|
11
|
+
import { decodeEventData, FibonacciRetry, getFriendEventType, getGroupEventType, hasOwn, logger, looksLikeJson, makeURL, safeJsonParse } from '../utils.js';
|
|
12
12
|
import { ConfigSocket } from '../socket/config-socket.js';
|
|
13
13
|
import { ZaloApiError } from '../Errors/ZaloApiError.js';
|
|
14
14
|
import WebSocket from 'ws';
|
|
@@ -157,7 +157,9 @@ export class Listener extends EventEmitter {
|
|
|
157
157
|
const decodedData = new TextDecoder('utf-8').decode(dataToDecode);
|
|
158
158
|
if (decodedData.length == 0)
|
|
159
159
|
return;
|
|
160
|
-
const parsed =
|
|
160
|
+
const parsed = safeJsonParse(decodedData);
|
|
161
|
+
if (!parsed)
|
|
162
|
+
return;
|
|
161
163
|
if (cmd === MessageCommand.Ping) {
|
|
162
164
|
if (subCmd === KeepAliveCommand.KeepConnection || this.onlineConfigs.send_active_to_keep_live) {
|
|
163
165
|
if ((_a = this.settingSocket.debug) === null || _a === void 0 ? void 0 : _a.skip_ping) {
|
package/dist/cjs/apis/listen.cjs
CHANGED
|
@@ -160,7 +160,9 @@ class Listener extends stream.EventEmitter {
|
|
|
160
160
|
const decodedData = new TextDecoder('utf-8').decode(dataToDecode);
|
|
161
161
|
if (decodedData.length == 0)
|
|
162
162
|
return;
|
|
163
|
-
const parsed =
|
|
163
|
+
const parsed = utils.safeJsonParse(decodedData);
|
|
164
|
+
if (!parsed)
|
|
165
|
+
return;
|
|
164
166
|
if (cmd === Listen.MessageCommand.Ping) {
|
|
165
167
|
if (subCmd === Listen.KeepAliveCommand.KeepConnection || this.onlineConfigs.send_active_to_keep_live) {
|
|
166
168
|
if ((_a = this.settingSocket.debug) === null || _a === void 0 ? void 0 : _a.skip_ping) {
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -692,6 +692,14 @@ function handleQueueStatus(queueStatus) {
|
|
|
692
692
|
function looksLikeJson(str) {
|
|
693
693
|
return /^[\[{].*[\]}]$/.test(str.trim());
|
|
694
694
|
}
|
|
695
|
+
function safeJsonParse(input) {
|
|
696
|
+
try {
|
|
697
|
+
return JSON.parse(input);
|
|
698
|
+
}
|
|
699
|
+
catch (_a) {
|
|
700
|
+
return undefined;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
695
703
|
|
|
696
704
|
exports.FibonacciRetry = FibonacciRetry;
|
|
697
705
|
exports.ParamsEncryptor = ParamsEncryptor;
|
|
@@ -725,4 +733,5 @@ exports.makeURL = makeURL;
|
|
|
725
733
|
exports.removeUndefinedKeys = removeUndefinedKeys;
|
|
726
734
|
exports.request = request;
|
|
727
735
|
exports.resolveResponse = resolveResponse;
|
|
736
|
+
exports.safeJsonParse = safeJsonParse;
|
|
728
737
|
exports.strPadLeft = strPadLeft;
|
package/dist/cjs/zalo.cjs
CHANGED
|
@@ -116,9 +116,7 @@ class Zalo {
|
|
|
116
116
|
}
|
|
117
117
|
async waitingConfirm(props) {
|
|
118
118
|
const { ctx, loginVersion, code, imei, getPreviousImei } = props;
|
|
119
|
-
console.log(props);
|
|
120
119
|
const loginQRResult = await loginQR.handleWaitingConfirm(ctx, loginVersion, code);
|
|
121
|
-
console.log(loginQRResult);
|
|
122
120
|
if (!loginQRResult || !(ctx === null || ctx === void 0 ? void 0 : ctx.userAgent))
|
|
123
121
|
return null;
|
|
124
122
|
return this.loginCookie({
|
package/dist/utils.d.ts
CHANGED
|
@@ -187,4 +187,5 @@ export declare class FibonacciRetry {
|
|
|
187
187
|
}
|
|
188
188
|
export declare function handleQueueStatus(queueStatus: TypeQueueStatus): TypeQueueStatus;
|
|
189
189
|
export declare function looksLikeJson(str: string): boolean;
|
|
190
|
+
export declare function safeJsonParse<T = any>(input: string): T | undefined;
|
|
190
191
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -749,3 +749,11 @@ export function handleQueueStatus(queueStatus) {
|
|
|
749
749
|
export function looksLikeJson(str) {
|
|
750
750
|
return /^[\[{].*[\]}]$/.test(str.trim());
|
|
751
751
|
}
|
|
752
|
+
export function safeJsonParse(input) {
|
|
753
|
+
try {
|
|
754
|
+
return JSON.parse(input);
|
|
755
|
+
}
|
|
756
|
+
catch (_a) {
|
|
757
|
+
return undefined;
|
|
758
|
+
}
|
|
759
|
+
}
|
package/dist/zalo.js
CHANGED
|
@@ -94,9 +94,7 @@ export class Zalo {
|
|
|
94
94
|
}
|
|
95
95
|
async waitingConfirm(props) {
|
|
96
96
|
const { ctx, loginVersion, code, imei, getPreviousImei } = props;
|
|
97
|
-
console.log(props);
|
|
98
97
|
const loginQRResult = await handleWaitingConfirm(ctx, loginVersion, code);
|
|
99
|
-
console.log(loginQRResult);
|
|
100
98
|
if (!loginQRResult || !(ctx === null || ctx === void 0 ? void 0 : ctx.userAgent))
|
|
101
99
|
return null;
|
|
102
100
|
return this.loginCookie({
|