jagproject 5.8.2 → 5.8.5
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/Defaults/index.js +47 -35
- package/lib/Socket/business.d.ts +2 -2
- package/lib/Socket/chats.d.ts +2 -2
- package/lib/Socket/groups.d.ts +2 -2
- package/lib/Socket/index.d.ts +2 -2
- package/lib/Socket/messages-recv.d.ts +2 -2
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.d.ts +2 -2
- package/lib/Socket/messages-send.js +10 -29
- package/lib/Socket/newsletter.d.ts +2 -2
- package/lib/Socket/socket.d.ts +2 -2
- package/lib/Socket/usync.d.ts +2 -2
- package/lib/Store/make-in-memory-store.d.ts +4 -4
- package/lib/Store/make-in-memory-store.js +1 -1
- package/lib/Types/Events.d.ts +7 -7
- package/lib/Types/Socket.d.ts +3 -3
- package/lib/Types/index.d.ts +1 -1
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/chat-utils.d.ts +2 -2
- package/lib/Utils/event-buffer.d.ts +6 -6
- package/lib/Utils/event-buffer.js +2 -2
- package/lib/Utils/generics.d.ts +7 -7
- package/lib/Utils/generics.js +43 -7
- package/lib/Utils/index.d.ts +1 -1
- package/lib/Utils/index.js +3 -1
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +1 -2
- package/lib/Utils/process-message.d.ts +2 -2
- package/lib/Utils/use-multi-file-auth-state.js +1 -1
- package/lib/Utils/validate-connection.js +77 -21
- package/lib/Utils/{baileys-event-stream.d.ts → wileys-event-stream.d.ts} +4 -4
- package/lib/Utils/{baileys-event-stream.js → wileys-event-stream.js} +1 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/WAProto/index.d.ts +0 -55057
- package/WAProto/index.ts.ts +0 -53473
- package/lib/Defaults/index.d.ts +0 -51
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/index.d.ts +0 -2
- package/lib/Socket/Client/types.d.ts +0 -16
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Store/index.d.ts +0 -2
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -103
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -109
- package/lib/Types/Contact.d.ts +0 -23
- package/lib/Types/GroupMetadata.d.ts +0 -64
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -400
- package/lib/Types/Newsletter.d.ts +0 -79
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/crypto.d.ts +0 -40
- package/lib/Utils/decode-wa-message.d.ts +0 -35
- package/lib/Utils/history.d.ts +0 -19
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -11
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -120
- package/lib/Utils/messages.d.ts +0 -80
- package/lib/Utils/noise-handler.d.ts +0 -19
- package/lib/Utils/signal.d.ts +0 -33
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/Utils/validate-connection.d.ts +0 -10
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -6
- package/lib/WABinary/encode.d.ts +0 -2
- package/lib/WABinary/generic-utils.d.ts +0 -14
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -37
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -8
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -2
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -16
package/lib/Defaults/index.js
CHANGED
|
@@ -3,61 +3,69 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.
|
|
6
|
+
exports.DEFAULT_CACHE_TTLS = exports.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.UNAUTHORIZED_CODES = exports.version = void 0;
|
|
7
7
|
const WAProto_1 = require("../../WAProto");
|
|
8
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
|
-
const
|
|
9
|
+
const browser_utils_1 = require("../Utils/browser-utils");
|
|
10
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
11
|
-
|
|
11
|
+
exports.version = [2, 3000, 1027934701];
|
|
12
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
13
13
|
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
14
|
+
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
15
|
+
exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
14
16
|
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
15
17
|
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
16
18
|
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
19
|
+
exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
20
|
+
exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
21
|
+
exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
22
|
+
exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
17
23
|
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
18
24
|
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
19
25
|
exports.DICT_VERSION = 3;
|
|
20
26
|
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
21
|
-
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
22
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
27
|
+
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
23
28
|
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
24
29
|
exports.WA_CERT_DETAILS = {
|
|
25
|
-
SERIAL: 0
|
|
30
|
+
SERIAL: 0
|
|
26
31
|
};
|
|
27
32
|
exports.PROCESSABLE_HISTORY_TYPES = [
|
|
28
|
-
WAProto_1.proto.
|
|
29
|
-
WAProto_1.proto.
|
|
30
|
-
WAProto_1.proto.
|
|
31
|
-
WAProto_1.proto.
|
|
32
|
-
WAProto_1.proto.
|
|
33
|
+
WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
34
|
+
WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
35
|
+
WAProto_1.proto.HistorySync.HistorySyncType.RECENT,
|
|
36
|
+
WAProto_1.proto.HistorySync.HistorySyncType.FULL,
|
|
37
|
+
WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
38
|
+
WAProto_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
39
|
+
WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
|
|
33
40
|
];
|
|
34
41
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
35
|
-
version:
|
|
36
|
-
browser:
|
|
42
|
+
version: exports.version,
|
|
43
|
+
browser: (0, browser_utils_1.Browsers)('Chrome'),
|
|
37
44
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
38
|
-
connectTimeoutMs:
|
|
39
|
-
keepAliveIntervalMs:
|
|
45
|
+
connectTimeoutMs: 20_000,
|
|
46
|
+
keepAliveIntervalMs: 30_000,
|
|
40
47
|
logger: logger_1.default.child({ class: 'baileys' }),
|
|
41
|
-
printQRInTerminal: false,
|
|
42
48
|
emitOwnEvents: true,
|
|
43
|
-
defaultQueryTimeoutMs:
|
|
49
|
+
defaultQueryTimeoutMs: 60_000,
|
|
44
50
|
customUploadHosts: [],
|
|
45
51
|
retryRequestDelayMs: 250,
|
|
46
52
|
maxMsgRetryCount: 5,
|
|
47
53
|
fireInitQueries: true,
|
|
48
54
|
auth: undefined,
|
|
49
55
|
markOnlineOnConnect: true,
|
|
50
|
-
syncFullHistory:
|
|
56
|
+
syncFullHistory: true,
|
|
51
57
|
patchMessageBeforeSending: msg => msg,
|
|
52
58
|
shouldSyncHistoryMessage: () => true,
|
|
53
59
|
shouldIgnoreJid: () => false,
|
|
54
60
|
linkPreviewImageThumbnailWidth: 192,
|
|
55
61
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
56
62
|
generateHighQualityLinkPreview: false,
|
|
63
|
+
enableAutoSessionRecreation: true,
|
|
64
|
+
enableRecentMessageCache: true,
|
|
57
65
|
options: {},
|
|
58
66
|
appStateMacVerification: {
|
|
59
67
|
patch: false,
|
|
60
|
-
snapshot: false
|
|
68
|
+
snapshot: false
|
|
61
69
|
},
|
|
62
70
|
countryCode: 'US',
|
|
63
71
|
getMessage: async () => undefined,
|
|
@@ -74,17 +82,18 @@ exports.MEDIA_PATH_MAP = {
|
|
|
74
82
|
'product-catalog-image': '/product/image',
|
|
75
83
|
'md-app-state': '',
|
|
76
84
|
'md-msg-hist': '/mms/md-app-state',
|
|
85
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
77
86
|
};
|
|
78
87
|
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
audio: 'Audio',
|
|
89
|
+
document: 'Document',
|
|
90
|
+
gif: 'Video',
|
|
91
|
+
image: 'Image',
|
|
92
|
+
ppic: '',
|
|
93
|
+
product: 'Image',
|
|
94
|
+
ptt: 'Audio',
|
|
95
|
+
sticker: 'Image',
|
|
96
|
+
video: 'Video',
|
|
88
97
|
'thumbnail-document': 'Document Thumbnail',
|
|
89
98
|
'thumbnail-image': 'Image Thumbnail',
|
|
90
99
|
'thumbnail-video': 'Video Thumbnail',
|
|
@@ -93,14 +102,17 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
|
93
102
|
'md-app-state': 'App State',
|
|
94
103
|
'product-catalog-image': '',
|
|
95
104
|
'payment-bg-image': 'Payment Background',
|
|
96
|
-
|
|
105
|
+
ptv: 'Video',
|
|
106
|
+
'biz-cover-photo': 'Image'
|
|
97
107
|
};
|
|
98
108
|
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
99
109
|
exports.MIN_PREKEY_COUNT = 5;
|
|
100
|
-
exports.INITIAL_PREKEY_COUNT =
|
|
110
|
+
exports.INITIAL_PREKEY_COUNT = 812;
|
|
111
|
+
exports.UPLOAD_TIMEOUT = 30000;
|
|
112
|
+
exports.MIN_UPLOAD_INTERVAL = 5000;
|
|
101
113
|
exports.DEFAULT_CACHE_TTLS = {
|
|
102
|
-
SIGNAL_STORE: 5 * 60,
|
|
103
|
-
MSG_RETRY: 60 * 60,
|
|
104
|
-
CALL_OFFER: 5 * 60,
|
|
105
|
-
USER_DEVICES: 5 * 60
|
|
106
|
-
};
|
|
114
|
+
SIGNAL_STORE: 5 * 60,
|
|
115
|
+
MSG_RETRY: 60 * 60,
|
|
116
|
+
CALL_OFFER: 5 * 60,
|
|
117
|
+
USER_DEVICES: 5 * 60
|
|
118
|
+
};
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -142,8 +142,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
142
142
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
143
143
|
type: "md";
|
|
144
144
|
ws: import("./Client").WebSocketClient;
|
|
145
|
-
ev: import("../Types").
|
|
146
|
-
process(handler: (events: Partial<import("../Types").
|
|
145
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
146
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
147
147
|
buffer(): void;
|
|
148
148
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
149
149
|
flush(force?: boolean): boolean;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -52,8 +52,8 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
52
52
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
53
53
|
type: "md";
|
|
54
54
|
ws: import("./Client").WebSocketClient;
|
|
55
|
-
ev: import("../Types").
|
|
56
|
-
process(handler: (events: Partial<import("../Types").
|
|
55
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
56
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
57
57
|
buffer(): void;
|
|
58
58
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
59
59
|
flush(force?: boolean): boolean;
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -93,8 +93,8 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
93
93
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
94
94
|
type: "md";
|
|
95
95
|
ws: import("./Client").WebSocketClient;
|
|
96
|
-
ev: import("../Types").
|
|
97
|
-
process(handler: (events: Partial<import("../Types").
|
|
96
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
97
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
98
98
|
buffer(): void;
|
|
99
99
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
100
100
|
flush(force?: boolean): boolean;
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -141,8 +141,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
141
141
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
142
142
|
type: "md";
|
|
143
143
|
ws: import("./Client").WebSocketClient;
|
|
144
|
-
ev: import("../Types").
|
|
145
|
-
process(handler: (events: Partial<import("../Types").
|
|
144
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
145
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
146
146
|
buffer(): void;
|
|
147
147
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
148
148
|
flush(force?: boolean): boolean;
|
|
@@ -131,8 +131,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
131
131
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
132
132
|
type: "md";
|
|
133
133
|
ws: import("./Client").WebSocketClient;
|
|
134
|
-
ev: import("../Types").
|
|
135
|
-
process(handler: (events: Partial<import("../Types").
|
|
134
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
135
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
136
136
|
buffer(): void;
|
|
137
137
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
138
138
|
flush(force?: boolean): boolean;
|
|
@@ -332,7 +332,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
332
332
|
break;
|
|
333
333
|
break;
|
|
334
334
|
default:
|
|
335
|
-
// console.log("
|
|
335
|
+
// console.log("WILEYS-DEBUG:", JSON.stringify({ ...child, content: Buffer.isBuffer(child.content) ? child.content.toString() : child.content, participant }, null, 2))
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
338
|
const handleNewsletterNotification = (id, node) => {
|
|
@@ -121,8 +121,8 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
121
121
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
122
122
|
type: "md";
|
|
123
123
|
ws: import("./Client").WebSocketClient;
|
|
124
|
-
ev: import("../Types").
|
|
125
|
-
process(handler: (events: Partial<import("../Types").
|
|
124
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
125
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
126
126
|
buffer(): void;
|
|
127
127
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
128
128
|
flush(force?: boolean): boolean;
|
|
@@ -687,28 +687,16 @@ const makeMessagesSocket = (config) => {
|
|
|
687
687
|
return message;
|
|
688
688
|
},
|
|
689
689
|
|
|
690
|
-
|
|
691
|
-
* === PATCH: upswgc ===
|
|
692
|
-
* Fungsi untuk mengirim group status message / story grup
|
|
693
|
-
* Contoh:
|
|
694
|
-
* await sock.upswgc(jid, { text: "Hello World" })
|
|
695
|
-
*/
|
|
696
|
-
/**
|
|
697
|
-
* === PATCH: upswgc (Final Combo) ===
|
|
698
|
-
* Support teks + semua media (image, video, doc, audio)
|
|
699
|
-
*/
|
|
690
|
+
// === PATCH: upswgc ===
|
|
700
691
|
upswgc: async (jid, storyContent = {}) => {
|
|
701
692
|
try {
|
|
702
693
|
const userJid = authState?.creds?.me?.id || sock?.user?.id;
|
|
703
694
|
let waMsgContent;
|
|
704
|
-
|
|
705
|
-
// Deteksi apakah konten punya media
|
|
706
695
|
const hasMedia = storyContent.image || storyContent.video || storyContent.document || storyContent.audio;
|
|
707
696
|
|
|
708
697
|
if (storyContent.message) {
|
|
709
698
|
waMsgContent = storyContent;
|
|
710
699
|
} else if (hasMedia) {
|
|
711
|
-
// Untuk media
|
|
712
700
|
if (typeof Utils_1.generateWAMessageContent === "function") {
|
|
713
701
|
waMsgContent = await Utils_1.generateWAMessageContent(storyContent, {
|
|
714
702
|
upload: waUploadToServer
|
|
@@ -721,19 +709,14 @@ upswgc: async (jid, storyContent = {}) => {
|
|
|
721
709
|
waMsgContent = storyContent;
|
|
722
710
|
}
|
|
723
711
|
} else if (storyContent.text) {
|
|
724
|
-
|
|
725
|
-
waMsgContent = {
|
|
726
|
-
conversation: storyContent.text
|
|
727
|
-
};
|
|
712
|
+
waMsgContent = { conversation: storyContent.text };
|
|
728
713
|
} else {
|
|
729
714
|
waMsgContent = storyContent;
|
|
730
715
|
}
|
|
731
716
|
|
|
732
717
|
const msg = {
|
|
733
718
|
message: {
|
|
734
|
-
groupStatusMessageV2: {
|
|
735
|
-
message: waMsgContent.message || waMsgContent
|
|
736
|
-
}
|
|
719
|
+
groupStatusMessageV2: { message: waMsgContent.message || waMsgContent }
|
|
737
720
|
}
|
|
738
721
|
};
|
|
739
722
|
|
|
@@ -742,7 +725,6 @@ upswgc: async (jid, storyContent = {}) => {
|
|
|
742
725
|
: Utils_1.generateMessageID();
|
|
743
726
|
|
|
744
727
|
await relayMessage(jid, msg.message, { messageId });
|
|
745
|
-
|
|
746
728
|
console.log("upswgc success:", jid);
|
|
747
729
|
return msg;
|
|
748
730
|
} catch (err) {
|
|
@@ -752,11 +734,12 @@ upswgc: async (jid, storyContent = {}) => {
|
|
|
752
734
|
},
|
|
753
735
|
|
|
754
736
|
|
|
755
|
-
|
|
756
|
-
sendMessage: async (jid, content, options = {}) => {
|
|
757
|
-
var _a, _b, _c;
|
|
758
737
|
|
|
759
|
-
|
|
738
|
+
sendMessage: async (jid, content, options = {}) => {
|
|
739
|
+
var _a, _b, _c;
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
// === AUTO WAVEFORM PATCH START ===
|
|
760
743
|
try {
|
|
761
744
|
const { getAudioWaveform } = require('../Utils/messages-media');
|
|
762
745
|
const fs = require('fs');
|
|
@@ -781,6 +764,8 @@ upswgc: async (jid, storyContent = {}) => {
|
|
|
781
764
|
console.log('[WILEYSS PATCH] Gagal generate waveform otomatis:', err.message);
|
|
782
765
|
}
|
|
783
766
|
// === AUTO WAVEFORM PATCH END ===
|
|
767
|
+
|
|
768
|
+
|
|
784
769
|
const userJid = authState.creds.me.id;
|
|
785
770
|
if (!options.ephemeralExpiration) {
|
|
786
771
|
if ((0, WABinary_1.isJidGroup)(jid)) {
|
|
@@ -872,10 +857,6 @@ upswgc: async (jid, storyContent = {}) => {
|
|
|
872
857
|
}
|
|
873
858
|
else {
|
|
874
859
|
let mediaHandle;
|
|
875
|
-
if (content.waveform) {
|
|
876
|
-
console.log('[VN PATCH] waveform attached len =', content.waveform.length);
|
|
877
|
-
}
|
|
878
|
-
|
|
879
860
|
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
880
861
|
logger,
|
|
881
862
|
userJid,
|
|
@@ -105,8 +105,8 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
105
105
|
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
106
106
|
type: "md";
|
|
107
107
|
ws: import("./Client").WebSocketClient;
|
|
108
|
-
ev: import("../Types").
|
|
109
|
-
process(handler: (events: Partial<import("../Types").
|
|
108
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
109
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
110
110
|
buffer(): void;
|
|
111
111
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
112
112
|
flush(force?: boolean): boolean;
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { WebSocketClient } from './Client';
|
|
|
11
11
|
export declare const makeSocket: (config: SocketConfig) => {
|
|
12
12
|
type: "md";
|
|
13
13
|
ws: WebSocketClient;
|
|
14
|
-
ev: import("../Types").
|
|
15
|
-
process(handler: (events: Partial<import("../Types").
|
|
14
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
15
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
16
16
|
buffer(): void;
|
|
17
17
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
18
18
|
flush(force?: boolean): boolean;
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
6
6
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
7
7
|
type: "md";
|
|
8
8
|
ws: import("./Client").WebSocketClient;
|
|
9
|
-
ev: import("../Types").
|
|
10
|
-
process(handler: (events: Partial<import("../Types").
|
|
9
|
+
ev: import("../Types").WileysEventEmitter & {
|
|
10
|
+
process(handler: (events: Partial<import("../Types").WileysEventMap>) => void | Promise<void>): (() => void);
|
|
11
11
|
buffer(): void;
|
|
12
12
|
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
13
13
|
flush(force?: boolean): boolean;
|
|
@@ -2,7 +2,7 @@ import type KeyedDB from '@adiwajshing/keyed-db';
|
|
|
2
2
|
import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
4
|
import type makeMDSocket from '../Socket';
|
|
5
|
-
import type {
|
|
5
|
+
import type { WileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
|
|
6
6
|
import { Label } from '../Types/Label';
|
|
7
7
|
import { LabelAssociation } from '../Types/LabelAssociation';
|
|
8
8
|
import { ILogger } from '../Utils/logger';
|
|
@@ -14,13 +14,13 @@ export declare const waChatKey: (pin: boolean) => {
|
|
|
14
14
|
};
|
|
15
15
|
export declare const waMessageID: (m: WAMessage) => string;
|
|
16
16
|
export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>;
|
|
17
|
-
export type
|
|
17
|
+
export type WileysInMemoryStoreConfig = {
|
|
18
18
|
chatKey?: Comparable<Chat, string>;
|
|
19
19
|
labelAssociationKey?: Comparable<LabelAssociation, string>;
|
|
20
20
|
logger?: ILogger;
|
|
21
21
|
socket?: WASocket;
|
|
22
22
|
};
|
|
23
|
-
declare const _default: (config:
|
|
23
|
+
declare const _default: (config: WileysInMemoryStoreConfig) => {
|
|
24
24
|
chats: KeyedDB<Chat, string>;
|
|
25
25
|
contacts: {
|
|
26
26
|
[_: string]: Contact;
|
|
@@ -50,7 +50,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
50
50
|
};
|
|
51
51
|
labels: ObjectRepository<Label>;
|
|
52
52
|
labelAssociations: KeyedDB<LabelAssociation, string>;
|
|
53
|
-
bind: (ev:
|
|
53
|
+
bind: (ev: WileysEventEmitter) => void;
|
|
54
54
|
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
55
55
|
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<WAMessage[]>;
|
|
56
56
|
/**
|
|
@@ -65,7 +65,7 @@ exports.default = (config) => {
|
|
|
65
65
|
return Object.keys(contacts);
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
* binds to a
|
|
68
|
+
* binds to a WileysEventEmitter.
|
|
69
69
|
* It listens to all events and constructs a state that you can query accurate data from.
|
|
70
70
|
* Eg. can use the store to fetch chats, contacts, messages etc.
|
|
71
71
|
* @param ev typically the event emitter from the socket connection
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { LabelAssociation } from './LabelAssociation';
|
|
|
10
10
|
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
11
11
|
import { ConnectionState } from './State';
|
|
12
12
|
import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
|
|
13
|
-
export type
|
|
13
|
+
export type WileysEventMap = {
|
|
14
14
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
15
15
|
'connection.update': Partial<ConnectionState>;
|
|
16
16
|
/** credentials updated -- some metadata, keys or something */
|
|
@@ -190,10 +190,10 @@ export type BufferedEventData = {
|
|
|
190
190
|
[jid: string]: Partial<GroupMetadata>;
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
-
export type
|
|
194
|
-
export interface
|
|
195
|
-
on<T extends keyof
|
|
196
|
-
off<T extends keyof
|
|
197
|
-
removeAllListeners<T extends keyof
|
|
198
|
-
emit<T extends keyof
|
|
193
|
+
export type WileysEvent = keyof WileysEventMap;
|
|
194
|
+
export interface WileysEventEmitter {
|
|
195
|
+
on<T extends keyof WileysEventMap>(event: T, listener: (arg: WileysEventMap[T]) => void): void;
|
|
196
|
+
off<T extends keyof WileysEventMap>(event: T, listener: (arg: WileysEventMap[T]) => void): void;
|
|
197
|
+
removeAllListeners<T extends keyof WileysEventMap>(event: T): void;
|
|
198
|
+
emit<T extends keyof WileysEventMap>(event: T, arg: WileysEventMap[T]): boolean;
|
|
199
199
|
}
|
package/lib/Types/Socket.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type SocketConfig = {
|
|
|
31
31
|
defaultQueryTimeoutMs: number | undefined;
|
|
32
32
|
/** ping-pong interval for WS connection */
|
|
33
33
|
keepAliveIntervalMs: number;
|
|
34
|
-
/** should
|
|
34
|
+
/** should wileys use the mobile api instead of the multi device api
|
|
35
35
|
* @deprecated This feature has been removed
|
|
36
36
|
*/
|
|
37
37
|
mobile?: boolean;
|
|
@@ -81,9 +81,9 @@ export type SocketConfig = {
|
|
|
81
81
|
placeholderResendCache?: CacheStore;
|
|
82
82
|
/** width for link preview images */
|
|
83
83
|
linkPreviewImageThumbnailWidth: number;
|
|
84
|
-
/** Should
|
|
84
|
+
/** Should Wileys ask the phone for full history, will be received async */
|
|
85
85
|
syncFullHistory: boolean;
|
|
86
|
-
/** Should
|
|
86
|
+
/** Should wileys fire init queries automatically, default true */
|
|
87
87
|
fireInitQueries: boolean;
|
|
88
88
|
/**
|
|
89
89
|
* generate a high quality link preview,
|
package/lib/Types/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
|
|
18
18
|
export type BrowsersMap = {
|
|
19
19
|
ubuntu(browser: string): [string, string, string];
|
|
20
20
|
macOS(browser: string): [string, string, string];
|
|
21
|
-
|
|
21
|
+
wileys(browser: string): [string, string, string];
|
|
22
22
|
windows(browser: string): [string, string, string];
|
|
23
23
|
appropriate(browser: string): [string, string, string];
|
|
24
24
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlatformId = exports.Browsers = void 0;
|
|
4
|
+
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const { proto } = require("../../WAProto/index.js");
|
|
7
|
+
|
|
8
|
+
const PLATFORM_MAP = {
|
|
9
|
+
'aix': 'AIX',
|
|
10
|
+
'darwin': 'Mac OS',
|
|
11
|
+
'win32': 'Windows',
|
|
12
|
+
'android': 'Android',
|
|
13
|
+
'freebsd': 'FreeBSD',
|
|
14
|
+
'openbsd': 'OpenBSD',
|
|
15
|
+
'sunos': 'Solaris',
|
|
16
|
+
'linux': undefined, // Default ke Ubuntu untuk Linux
|
|
17
|
+
'haiku': undefined,
|
|
18
|
+
'cygwin': undefined,
|
|
19
|
+
'netbsd': undefined
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Fixed: Browsers sekarang fungsi yang return array [platform, browser, version]
|
|
23
|
+
// Ini kompatibel dengan pemanggilan Browsers('Chrome') di Defaults/index.js
|
|
24
|
+
exports.Browsers = (browser) => {
|
|
25
|
+
const osName = PLATFORM_MAP[os.platform()] || 'Ubuntu'; // Default Ubuntu kalau undefined
|
|
26
|
+
const osRelease = os.release(); // Ambil versi OS real-time
|
|
27
|
+
return [osName, browser, osRelease];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getPlatformId = (browser) => {
|
|
31
|
+
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
32
|
+
return platformType ? platformType.toString() : '1'; // Default Chrome
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getPlatformId = getPlatformId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { proto } from '../../WAProto';
|
|
3
|
-
import {
|
|
3
|
+
import { WileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
|
|
4
4
|
import { BinaryNode } from '../WABinary';
|
|
5
5
|
import { ILogger } from './logger';
|
|
6
6
|
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
|
@@ -66,5 +66,5 @@ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatc
|
|
|
66
66
|
mutationMap: ChatMutationMap;
|
|
67
67
|
}>;
|
|
68
68
|
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
|
69
|
-
export declare const processSyncAction: (syncAction: ChatMutation, ev:
|
|
69
|
+
export declare const processSyncAction: (syncAction: ChatMutation, ev: WileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void;
|
|
70
70
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WileysEventEmitter, WileysEventMap } from '../Types';
|
|
2
2
|
import { ILogger } from './logger';
|
|
3
3
|
/**
|
|
4
4
|
* A map that contains a list of all events that have been triggered
|
|
@@ -7,10 +7,10 @@ import { ILogger } from './logger';
|
|
|
7
7
|
* this can make processing events extremely efficient -- since everything
|
|
8
8
|
* can be done in a single transaction
|
|
9
9
|
*/
|
|
10
|
-
type
|
|
11
|
-
type
|
|
10
|
+
type WileysEventData = Partial<WileysEventMap>;
|
|
11
|
+
type WileysBufferableEventEmitter = WileysEventEmitter & {
|
|
12
12
|
/** Use to process events in a batch */
|
|
13
|
-
process(handler: (events:
|
|
13
|
+
process(handler: (events: WileysEventData) => void | Promise<void>): (() => void);
|
|
14
14
|
/**
|
|
15
15
|
* starts buffering events, call flush() to release them
|
|
16
16
|
* */
|
|
@@ -29,7 +29,7 @@ type BaileysBufferableEventEmitter = BaileysEventEmitter & {
|
|
|
29
29
|
/**
|
|
30
30
|
* The event buffer logically consolidates different events into a single event
|
|
31
31
|
* making the data processing more efficient.
|
|
32
|
-
* @param ev the
|
|
32
|
+
* @param ev the wileys event emitter
|
|
33
33
|
*/
|
|
34
|
-
export declare const makeEventBuffer: (logger: ILogger) =>
|
|
34
|
+
export declare const makeEventBuffer: (logger: ILogger) => WileysBufferableEventEmitter;
|
|
35
35
|
export {};
|
|
@@ -27,14 +27,14 @@ const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
|
|
|
27
27
|
/**
|
|
28
28
|
* The event buffer logically consolidates different events into a single event
|
|
29
29
|
* making the data processing more efficient.
|
|
30
|
-
* @param ev the
|
|
30
|
+
* @param ev the wileys event emitter
|
|
31
31
|
*/
|
|
32
32
|
const makeEventBuffer = (logger) => {
|
|
33
33
|
const ev = new events_1.default();
|
|
34
34
|
const historyCache = new Set();
|
|
35
35
|
let data = makeBufferData();
|
|
36
36
|
let buffersInProgress = 0;
|
|
37
|
-
// take the generic event and fire it as a
|
|
37
|
+
// take the generic event and fire it as a wileys event
|
|
38
38
|
ev.on('event', (map) => {
|
|
39
39
|
for (const event in map) {
|
|
40
40
|
ev.emit(event, map[event]);
|
package/lib/Utils/generics.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { ILogger } from './logger';
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
|
-
import {
|
|
4
|
+
import { WileysEventEmitter, WileysEventMap, BrowsersMap, WACallUpdateType, WAVersion } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
6
|
export declare const Browsers: BrowsersMap;
|
|
7
7
|
export declare const getPlatformId: (browser: string) => any;
|
|
@@ -34,14 +34,14 @@ export declare const delayCancellable: (ms: number) => {
|
|
|
34
34
|
export declare function promiseTimeout<T>(ms: number | undefined, promise: (resolve: (v: T) => void, reject: (error: any) => void) => void): Promise<T>;
|
|
35
35
|
export declare const generateMessageIDV2: (userId?: string) => string;
|
|
36
36
|
export declare const generateMessageID: () => string;
|
|
37
|
-
export declare function bindWaitForEvent<T extends keyof
|
|
38
|
-
export declare const bindWaitForConnectionUpdate: (ev:
|
|
39
|
-
export declare const printQRIfNecessaryListener: (ev:
|
|
37
|
+
export declare function bindWaitForEvent<T extends keyof WileysEventMap>(ev: WileysEventEmitter, event: T): (check: (u: WileysEventMap[T]) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
38
|
+
export declare const bindWaitForConnectionUpdate: (ev: WileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
39
|
+
export declare const printQRIfNecessaryListener: (ev: WileysEventEmitter, logger: ILogger) => void;
|
|
40
40
|
/**
|
|
41
|
-
* utility that fetches latest
|
|
41
|
+
* utility that fetches latest wileys version from the master branch.
|
|
42
42
|
* Use to ensure your WA connection is always on the latest version
|
|
43
43
|
*/
|
|
44
|
-
export declare const
|
|
44
|
+
export declare const fetchLatestWileysVersion: (options?: AxiosRequestConfig<any>) => Promise<{
|
|
45
45
|
version: WAVersion;
|
|
46
46
|
isLatest: boolean;
|
|
47
47
|
error?: undefined;
|
|
@@ -71,7 +71,7 @@ export declare const generateMdTagPrefix: () => string;
|
|
|
71
71
|
*/
|
|
72
72
|
export declare const getStatusFromReceiptType: (type: string | undefined) => proto.WebMessageInfo.Status;
|
|
73
73
|
/**
|
|
74
|
-
* Stream errors generally provide a reason, map that to a
|
|
74
|
+
* Stream errors generally provide a reason, map that to a wileys DisconnectReason
|
|
75
75
|
* @param reason the string reason given, eg. "conflict"
|
|
76
76
|
*/
|
|
77
77
|
export declare const getErrorCodeFromStreamError: (node: BinaryNode) => {
|