zalo-toolkit 1.1.2 → 1.1.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/dist/cjs/zalo.cjs +18 -1
- package/dist/zalo.js +18 -1
- package/package.json +1 -1
package/dist/cjs/zalo.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var ZaloApiError = require('./Errors/ZaloApiError.cjs');
|
|
|
8
8
|
var utils = require('./utils.cjs');
|
|
9
9
|
var apis = require('./apis.cjs');
|
|
10
10
|
var listen = require('./apis/listen.cjs');
|
|
11
|
+
var moment = require('moment');
|
|
11
12
|
|
|
12
13
|
function _interopNamespaceDefault(e) {
|
|
13
14
|
var n = Object.create(null);
|
|
@@ -36,9 +37,25 @@ class Zalo {
|
|
|
36
37
|
parseCookies(cookie) {
|
|
37
38
|
var _a;
|
|
38
39
|
const cookieArr = Array.isArray(cookie) ? cookie : cookie.cookies;
|
|
40
|
+
const now = moment();
|
|
41
|
+
const nowPlus7Days = moment().add(7, 'days');
|
|
39
42
|
cookieArr.forEach((e, i) => {
|
|
40
|
-
if (typeof e.domain
|
|
43
|
+
if (typeof e.domain === 'string' && e.domain.startsWith('.')) {
|
|
41
44
|
cookieArr[i].domain = e.domain.slice(1);
|
|
45
|
+
}
|
|
46
|
+
const key = e.key || (e === null || e === void 0 ? void 0 : e.name);
|
|
47
|
+
// 👉 Logic đặc biệt cho zpw_sek
|
|
48
|
+
if (key === 'zpw_sek') {
|
|
49
|
+
const creation = e.creation ? moment(e.creation) : null;
|
|
50
|
+
const lastAccessed = e.lastAccessed ? moment(e.lastAccessed) : null;
|
|
51
|
+
const isDifferentFromNow = (d) => !d || Math.abs(d.diff(now, 'seconds')) > 1;
|
|
52
|
+
if (isDifferentFromNow(creation)) {
|
|
53
|
+
cookieArr[i].creation = nowPlus7Days.toISOString();
|
|
54
|
+
}
|
|
55
|
+
if (isDifferentFromNow(lastAccessed)) {
|
|
56
|
+
cookieArr[i].lastAccessed = nowPlus7Days.toISOString();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
42
59
|
});
|
|
43
60
|
const jar = new ToughCookie__namespace.CookieJar();
|
|
44
61
|
for (const each of cookieArr) {
|
package/dist/zalo.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ZaloApiError } from './Errors/ZaloApiError.js';
|
|
|
6
6
|
import { generateZaloUUID, logger } from './utils.js';
|
|
7
7
|
import { ZaloAPI } from './apis.js';
|
|
8
8
|
import { Listener } from './apis/listen.js';
|
|
9
|
+
import moment from 'moment';
|
|
9
10
|
export class Zalo {
|
|
10
11
|
constructor(options = {}) {
|
|
11
12
|
this.options = options;
|
|
@@ -14,9 +15,25 @@ export class Zalo {
|
|
|
14
15
|
parseCookies(cookie) {
|
|
15
16
|
var _a;
|
|
16
17
|
const cookieArr = Array.isArray(cookie) ? cookie : cookie.cookies;
|
|
18
|
+
const now = moment();
|
|
19
|
+
const nowPlus7Days = moment().add(7, 'days');
|
|
17
20
|
cookieArr.forEach((e, i) => {
|
|
18
|
-
if (typeof e.domain
|
|
21
|
+
if (typeof e.domain === 'string' && e.domain.startsWith('.')) {
|
|
19
22
|
cookieArr[i].domain = e.domain.slice(1);
|
|
23
|
+
}
|
|
24
|
+
const key = e.key || (e === null || e === void 0 ? void 0 : e.name);
|
|
25
|
+
// 👉 Logic đặc biệt cho zpw_sek
|
|
26
|
+
if (key === 'zpw_sek') {
|
|
27
|
+
const creation = e.creation ? moment(e.creation) : null;
|
|
28
|
+
const lastAccessed = e.lastAccessed ? moment(e.lastAccessed) : null;
|
|
29
|
+
const isDifferentFromNow = (d) => !d || Math.abs(d.diff(now, 'seconds')) > 1;
|
|
30
|
+
if (isDifferentFromNow(creation)) {
|
|
31
|
+
cookieArr[i].creation = nowPlus7Days.toISOString();
|
|
32
|
+
}
|
|
33
|
+
if (isDifferentFromNow(lastAccessed)) {
|
|
34
|
+
cookieArr[i].lastAccessed = nowPlus7Days.toISOString();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
20
37
|
});
|
|
21
38
|
const jar = new ToughCookie.CookieJar();
|
|
22
39
|
for (const each of cookieArr) {
|