@mamans2973/maman 0.0.0-stage → 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.md +1275 -2
- package/WAProto/index.d.ts +37016 -0
- package/WAProto/index.js +2972 -0
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/WASignalGroup/sender_message_key.js +39 -0
- package/engine-requirements.js +1 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +51 -0
- package/lib/Defaults/index.js +10 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +9 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +15 -0
- package/lib/Socket/Client/types.js +1 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +4 -0
- package/lib/Socket/business.d.ts +146 -0
- package/lib/Socket/business.js +8 -0
- package/lib/Socket/chats.d.ts +85 -0
- package/lib/Socket/chats.js +29 -0
- package/lib/Socket/groups.d.ts +124 -0
- package/lib/Socket/groups.js +14 -0
- package/lib/Socket/index.d.ts +146 -0
- package/lib/Socket/index.js +1 -0
- package/lib/Socket/messages-recv.d.ts +135 -0
- package/lib/Socket/messages-recv.js +39 -0
- package/lib/Socket/messages-send.d.ts +130 -0
- package/lib/Socket/messages-send.js +26 -0
- package/lib/Socket/socket.d.ts +42 -0
- package/lib/Socket/socket.js +25 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +3 -0
- package/lib/Types/Auth.d.ts +103 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +112 -0
- package/lib/Types/Chat.js +1 -0
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +172 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +58 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +46 -0
- package/lib/Types/Label.js +3 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +1 -0
- package/lib/Types/Message.d.ts +267 -0
- package/lib/Types/Message.js +1 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +121 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +1 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +63 -0
- package/lib/Types/index.js +4 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +8 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +3 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +14 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.js +36 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.js +11 -0
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/decode-wa-message.js +9 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +19 -0
- package/lib/Utils/generics.d.ts +90 -0
- package/lib/Utils/generics.js +22 -0
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/history.js +7 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +5 -0
- package/lib/Utils/logger.d.ts +11 -0
- package/lib/Utils/logger.js +1 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +3 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +1 -0
- package/lib/Utils/messages-media.d.ts +103 -0
- package/lib/Utils/messages-media.js +35 -0
- package/lib/Utils/messages.d.ts +75 -0
- package/lib/Utils/messages.js +43 -0
- package/lib/Utils/noise-handler.d.ts +19 -0
- package/lib/Utils/noise-handler.js +6 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +19 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +10 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +5 -0
- package/lib/Utils/validate-connection.d.ts +10 -0
- package/lib/Utils/validate-connection.js +10 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +6 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/decode.js +9 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +9 -0
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/generic-utils.js +7 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +2 -0
- package/lib/WABinary/jid-utils.d.ts +35 -0
- package/lib/WABinary/jid-utils.js +5 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +1 -0
- package/lib/WAM/constants.d.ts +39 -0
- package/lib/WAM/constants.js +492 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +7 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +2 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +3 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +4 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +2 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +4 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +1 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +2 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +3 -0
- package/package.json +94 -4
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { proto } from '../../WAProto';
|
|
3
|
+
import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';
|
|
4
|
+
import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
5
|
+
import { USyncQuery } from '../WAUSync';
|
|
6
|
+
export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
7
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
8
|
+
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
9
|
+
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
10
|
+
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
11
|
+
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
12
|
+
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
13
|
+
refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
|
|
14
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
15
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
16
|
+
[_: string]: string;
|
|
17
|
+
}>;
|
|
18
|
+
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
19
|
+
createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
|
|
20
|
+
nodes: BinaryNode[];
|
|
21
|
+
shouldIncludeDeviceIdentity: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
|
|
24
|
+
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
25
|
+
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
26
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
27
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
28
|
+
groupLeave: (id: string) => Promise<void>;
|
|
29
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
30
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
}[]>;
|
|
33
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
34
|
+
status: string;
|
|
35
|
+
jid: string;
|
|
36
|
+
}[]>;
|
|
37
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
38
|
+
status: string;
|
|
39
|
+
jid: string;
|
|
40
|
+
content: BinaryNode;
|
|
41
|
+
}[]>;
|
|
42
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
43
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
44
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
45
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
46
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
47
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
48
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
49
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
50
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
51
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
52
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
53
|
+
groupFetchAllParticipating: () => Promise<{
|
|
54
|
+
[_: string]: import("../Types").GroupMetadata;
|
|
55
|
+
}>;
|
|
56
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
57
|
+
processingMutex: {
|
|
58
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
59
|
+
};
|
|
60
|
+
upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
61
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
62
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
63
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
64
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
65
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
66
|
+
jid: string;
|
|
67
|
+
exists: unknown;
|
|
68
|
+
lid: unknown;
|
|
69
|
+
}[] | undefined>;
|
|
70
|
+
fetchBlocklist: () => Promise<string[]>;
|
|
71
|
+
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
72
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
73
|
+
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
74
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
|
75
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
|
76
|
+
updateProfileName: (name: string) => Promise<void>;
|
|
77
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
78
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
79
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
80
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
81
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
82
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
83
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
84
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
85
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
86
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
87
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
88
|
+
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
89
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
90
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
91
|
+
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
92
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
93
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
94
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
95
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
96
|
+
star: (jid: string, messages: {
|
|
97
|
+
id: string;
|
|
98
|
+
fromMe?: boolean;
|
|
99
|
+
}[], star: boolean) => Promise<void>;
|
|
100
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
101
|
+
type: "md";
|
|
102
|
+
ws: import("./Client").WebSocketClient;
|
|
103
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
104
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
105
|
+
buffer(): void;
|
|
106
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
107
|
+
flush(force?: boolean): boolean;
|
|
108
|
+
isBuffering(): boolean;
|
|
109
|
+
};
|
|
110
|
+
authState: {
|
|
111
|
+
creds: import("../Types").AuthenticationCreds;
|
|
112
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
113
|
+
};
|
|
114
|
+
signalRepository: import("../Types").SignalRepository;
|
|
115
|
+
user: import("../Types").Contact | undefined;
|
|
116
|
+
generateMessageTag: () => string;
|
|
117
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
118
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
119
|
+
waitForSocketOpen: () => Promise<void>;
|
|
120
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
121
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
122
|
+
logout: (msg?: string) => Promise<void>;
|
|
123
|
+
end: (error: Error | undefined) => void;
|
|
124
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
125
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
126
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
127
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
128
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
129
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
130
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __importDefault=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(exports,"__esModule",{value:!0});exports.makeMessagesSocket=void 0;
|
|
2
|
+
const node_cache_1=__importDefault(require("@cacheable/node-cache")),boom_1=require("@hapi/boom"),WAProto_1=require("../../WAProto"),Defaults_1=require("../Defaults"),Utils_1=require("../Utils"),link_preview_1=require("../Utils/link-preview"),WABinary_1=require("../WABinary"),WAUSync_1=require("../WAUSync"),groups_1=require("./groups"),makeMessagesSocket=p=>{const {logger:l,linkPreviewImageThumbnailWidth:la,generateHighQualityLinkPreview:ma,options:na,patchMessageBeforeSending:aa,cachedGroupMetadata:ba}=
|
|
3
|
+
p,F=(0,groups_1.makeGroupsSocket)(p),{ev:ca,authState:q,processingMutex:oa,signalRepository:H,upsertMessage:pa,query:L,fetchPrivacySettings:da,sendNode:M,groupMetadata:qa,groupToggleEphemeral:ra}=F,ea=p.userDevicesCache||new node_cache_1.default({stdTTL:Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES,useClones:!1});let N;const fa=async(a=!1)=>{const b=await N;if(!b||a||(new Date).getTime()-b.fetchDate.getTime()>1E3*b.ttl)N=(async()=>{var e=await L({tag:"iq",attrs:{type:"set",xmlns:"w:m",to:WABinary_1.S_WHATSAPP_NET},
|
|
4
|
+
content:[{tag:"media_conn",attrs:{}}]});e=(0,WABinary_1.getBinaryNodeChild)(e,"media_conn");e={hosts:(0,WABinary_1.getBinaryNodeChildren)(e,"host").map(({attrs:d})=>({hostname:d.hostname,maxContentLengthBytes:+d.maxContentLengthBytes})),auth:e.attrs.auth,ttl:+e.attrs.ttl,fetchDate:new Date};l.debug("fetched media conn");return e})();return N},ha=async(a,b,e,d)=>{const c={tag:"receipt",attrs:{id:e[0]}};if("read"===d||"read-self"===d)c.attrs.t=(0,Utils_1.unixTimestampSeconds)().toString();"sender"===
|
|
5
|
+
d&&(0,WABinary_1.isJidUser)(a)?(c.attrs.recipient=a,c.attrs.to=b):(c.attrs.to=a,b&&(c.attrs.participant=b));d&&(c.attrs.type=d);a=e.slice(1);a.length&&(c.content=[{tag:"list",attrs:{},content:a.map(g=>({tag:"item",attrs:{id:g}}))}]);l.debug({attrs:c.attrs,messageIds:e},"sending receipt for messages");await M(c)},ia=async(a,b)=>{a=(0,Utils_1.aggregateMessageKeysNotFromMe)(a);for(const {jid:e,participant:d,messageIds:c}of a)await ha(e,d,c,b)},O=async(a,b,e)=>{var d;const c=[];b||l.debug("not using cache for devices");
|
|
6
|
+
var g=[];a=Array.from(new Set(a));for(let f of a)if(a=null===(d=(0,WABinary_1.jidDecode)(f))||void 0===d?void 0:d.user,f=(0,WABinary_1.jidNormalizedUser)(f),b){const m=ea.get(a);m?(c.push(...m),l.trace({user:a},"using cache for devices")):g.push(f)}else g.push(f);if(!g.length)return c;b=(new WAUSync_1.USyncQuery).withContext("message").withDeviceProtocol();for(const f of g)b.withUser((new WAUSync_1.USyncUser).withId(f));if(g=await F.executeUSyncQuery(b)){e=(0,Utils_1.extractDeviceJids)(null===g||
|
|
7
|
+
void 0===g?void 0:g.list,q.creds.me.id,e);g={};for(const f of e)g[f.user]=g[f.user]||[],g[f.user].push(f),c.push(f);for(const f in g)ea.set(f,g[f])}return c},P=async(a,b)=>{var e=!1;let d=[];if(b)d=a;else{b=a.map(c=>H.jidToSignalProtocolAddress(c));b=await q.keys.get("session",b);for(const c of a)a=H.jidToSignalProtocolAddress(c),b[a]||d.push(c)}d.length&&(l.debug({jidsRequiringFetch:d},"fetching sessions"),e=await L({tag:"iq",attrs:{xmlns:"encrypt",type:"get",to:WABinary_1.S_WHATSAPP_NET},content:[{tag:"key",
|
|
8
|
+
attrs:{},content:d.map(c=>({tag:"user",attrs:{jid:c}}))}]}),await (0,Utils_1.parseAndInjectE2ESessions)(e,H),e=!0);return e},J=async(a,b,e)=>{let d=await aa(b,a);Array.isArray(d)||(d=a?a.map(g=>({recipientJid:g,...d})):[d]);let c=!1;return{nodes:await Promise.all(d.map(async g=>{const {recipientJid:f,...m}=g;if(!f)return{};g=(0,Utils_1.encodeWAMessage)(m);const {type:x,ciphertext:r}=await H.encryptMessage({jid:f,data:g});"pkmsg"===x&&(c=!0);return{tag:"to",attrs:{jid:f},content:[{tag:"enc",attrs:{v:"2",
|
|
9
|
+
type:x,...(e||{})},content:r}]}})),shouldIncludeDeviceIdentity:c}},Y=async(a,b,{messageId:e,participant:d,additionalAttributes:c,additionalNodes:g,useUserDevicesCache:f,useCachedGroupMetadata:m,statusJidList:x})=>{var r;const y=q.creds.me.id;let z=!1;const {user:Q,server:ja}=(0,WABinary_1.jidDecode)(a),R="g.us"===ja,u="status@broadcast"===a,S="lid"===ja;e=e||(0,Utils_1.generateMessageIDV2)(null===(r=F.user)||void 0===r?void 0:r.id);f=!1!==f;m=!1!==m&&!u;const A=[],B=u?"status@broadcast":(0,WABinary_1.jidEncode)(Q,
|
|
10
|
+
S?"lid":R?"g.us":"s.whatsapp.net"),K=[],C=[],sa={deviceSentMessage:{destinationJid:B,message:b}},I={};if(d){R||u||(c={...c,device_fanout:"false"});const {user:v,device:k}=(0,WABinary_1.jidDecode)(d.jid);C.push({user:v,device:k})}await q.keys.transaction(async()=>{var v,k,D,E=ta(b);E&&(I.mediatype=E);if(null===(v=(0,Utils_1.normalizeMessageContent)(b))||void 0===v?0:v.pinInChatMessage)I["decrypt-fail"]="hide";if(R||u){const [t,G]=await Promise.all([(async()=>{let n=m&&ba?await ba(a):void 0;n&&Array.isArray(null===
|
|
11
|
+
n||void 0===n?void 0:n.participants)?l.trace({jid:a,participants:n.participants.length},"using cached group metadata"):u||(n=await qa(a));return n})(),(async()=>d||u?{}:(await q.keys.get("sender-key-memory",[a]))[a]||{})()]);if(!d){var h=t&&!u?t.participants.map(n=>n.id):[];u&&x&&h.push(...x);u||(c={...c,addressing_mode:(null===t||void 0===t?void 0:t.addressingMode)||"pn"});h=await O(h,!!f,!1);C.push(...h)}h=await aa(b);if(Array.isArray(h))throw new boom_1.Boom("Per-jid patching is not supported in groups");
|
|
12
|
+
h=(0,Utils_1.encodeWAMessage)(h);const {ciphertext:T,senderKeyDistributionMessage:U}=await H.encryptGroupMessage({group:B,data:h,meId:y});h=[];for(const {user:n,device:V}of C){var w=(0,WABinary_1.jidEncode)(n,"lid"===(null===t||void 0===t?void 0:t.addressingMode)?"lid":"s.whatsapp.net",V);if(!G[w]||d)h.push(w),G[w]=!0}h.length&&(l.debug({senderKeyJids:h},"sending new sender key"),w={senderKeyDistributionMessage:{axolotlSenderKeyDistributionMessage:U,groupId:B}},await P(h,!1),h=await J(h,w,I),z=z||
|
|
13
|
+
h.shouldIncludeDeviceIdentity,A.push(...h.nodes));K.push({tag:"enc",attrs:{v:"2",type:"skmsg"},content:T});await q.keys.set({"sender-key-memory":{[a]:G}})}else{({user:v}=(0,WABinary_1.jidDecode)(y));d||(C.push({user:Q}),Q!==v&&C.push({user:v}),"peer"!==(null===c||void 0===c?void 0:c.category)&&(E=await O([y,a],!!f,!0),C.push(...E)));E=[];const t=[],G=[];for(const {user:W,device:ua}of C){const ka=W===v,X=(0,WABinary_1.jidEncode)(ka&&S?(null===(w=null===(h=q.creds)||void 0===h?void 0:h.me)||void 0===
|
|
14
|
+
w?void 0:w.lid.split(":")[0])||W:W,S?"lid":"s.whatsapp.net",ua);ka?t.push(X):G.push(X);E.push(X)}await P(E,!1);const [{nodes:T,shouldIncludeDeviceIdentity:U},{nodes:n,shouldIncludeDeviceIdentity:V}]=await Promise.all([J(t,sa,I),J(G,b,I)]);A.push(...T);A.push(...n);z=z||U||V}A.length&&("peer"===(null===c||void 0===c?void 0:c.category)?(h=null===(D=null===(k=A[0])||void 0===k?void 0:k.content)||void 0===D?void 0:D[0])&&K.push(h):K.push({tag:"participants",attrs:{},content:A}));k=e;D=b.pollCreationMessage||
|
|
15
|
+
b.pollCreationMessageV2||b.pollCreationMessageV3?"poll":"text";k={tag:"message",attrs:{id:k,type:D,...(c||{})},content:K};d?(0,WABinary_1.isJidGroup)(B)?(k.attrs.to=B,k.attrs.participant=d.jid):(0,WABinary_1.areJidsSameUser)(d.jid,y)?(k.attrs.to=d.jid,k.attrs.recipient=B):k.attrs.to=d.jid:k.attrs.to=B;z&&(k.content.push({tag:"device-identity",attrs:{},content:(0,Utils_1.encodeSignedDeviceIdentity)(q.creds.account,!0)}),l.debug({jid:a},"adding device identity"));g&&0<g.length?k.content.push(...g):
|
|
16
|
+
((0,WABinary_1.isJidGroup)(a)||(0,WABinary_1.isJidUser)(a))&&((null===b||void 0===b?0:b.viewOnceMessage)||(null===b||void 0===b?0:b.viewOnceMessageV2)||(null===b||void 0===b?0:b.viewOnceMessageV2Extension)||(null===b||void 0===b?0:b.ephemeralMessage)||(null===b||void 0===b?0:b.templateMessage)||(null===b||void 0===b?0:b.interactiveMessage)||(null===b||void 0===b?0:b.buttonsMessage))&&k.content.push({tag:"biz",attrs:{},content:[{tag:"interactive",attrs:{type:"native_flow",v:"1"},content:[{tag:"native_flow",
|
|
17
|
+
attrs:{name:"quick_reply"}}]}]});if(D=va(b))k.content.push({tag:"biz",attrs:{},content:[{tag:D,attrs:wa(b)}]}),l.debug({jid:a},"adding business node");l.debug({msgId:e},`sending message to ${A.length} devices`);await M(k)});return e},ta=a=>{if(a.imageMessage)return"image";if(a.videoMessage)return a.videoMessage.gifPlayback?"gif":"video";if(a.audioMessage)return a.audioMessage.ptt?"ptt":"audio";if(a.contactMessage)return"vcard";if(a.documentMessage)return"document";if(a.contactsArrayMessage)return"contact_array";
|
|
18
|
+
if(a.liveLocationMessage)return"livelocation";if(a.stickerMessage)return"sticker";if(a.listMessage)return"list";if(a.listResponseMessage)return"list_response";if(a.buttonsResponseMessage)return"buttons_response";if(a.orderMessage)return"order";if(a.productMessage)return"product";if(a.interactiveResponseMessage)return"native_flow_response";if(a.groupInviteMessage)return"url"},va=a=>{if(a.buttonsMessage)return"buttons";if(a.buttonsResponseMessage)return"buttons_response";if(a.interactiveResponseMessage)return"interactive_response";
|
|
19
|
+
if(a.listMessage)return"list";if(a.listResponseMessage)return"list_response"},wa=a=>{if(a.templateMessage)return{};if(a.listMessage){a=a.listMessage.listType;if(!a)throw new boom_1.Boom("Expected list type inside message");return{v:"2",type:ListType[a].toLowerCase()}}return{}},Z=(0,Utils_1.getWAUploadToServer)(p,fa),xa=(0,Utils_1.bindWaitForEvent)(ca,"messages.media-update");return{...F,getPrivacyTokens:async a=>{const b=(0,Utils_1.unixTimestampSeconds)().toString();return await L({tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,
|
|
20
|
+
type:"set",xmlns:"privacy"},content:[{tag:"tokens",attrs:{},content:a.map(e=>({tag:"token",attrs:{jid:(0,WABinary_1.jidNormalizedUser)(e),t:b,type:"trusted_contact"}}))}]})},assertSessions:P,relayMessage:Y,sendReceipt:ha,sendReceipts:ia,readMessages:async a=>{const b="all"===(await da()).readreceipts?"read":"read-self";await ia(a,b)},refreshMediaConn:fa,waUploadToServer:Z,fetchPrivacySettings:da,sendPeerDataOperationMessage:async a=>{var b;if(null===(b=q.creds.me)||void 0===b||!b.id)throw new boom_1.Boom("Not authenticated");
|
|
21
|
+
a={protocolMessage:{peerDataOperationRequestMessage:a,type:WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE}};b=(0,WABinary_1.jidNormalizedUser)(q.creds.me.id);return await Y(b,a,{additionalAttributes:{category:"peer",push_priority:"high_force"}})},createParticipantNodes:J,getUSyncDevices:O,updateMediaMessage:async a=>{const b=(0,Utils_1.assertMediaContent)(a.message),e=b.mediaKey,d=await (0,Utils_1.encryptMediaRetryRequest)(a.key,e,q.creds.me.id);let c=void 0;await Promise.all([M(d),
|
|
22
|
+
xa(async g=>{if(g=g.find(f=>f.key.id===a.key.id)){if(g.error)c=g.error;else try{const f=await (0,Utils_1.decryptMediaRetryData)(g.media,e,g.key.id);if(f.result!==WAProto_1.proto.MediaRetryNotification.ResultType.SUCCESS)throw new boom_1.Boom(`Media re-upload failed by device (${WAProto_1.proto.MediaRetryNotification.ResultType[f.result]})`,{data:f,statusCode:(0,Utils_1.getStatusCodeForMediaRetry)(f.result)||404});b.directPath=f.directPath;b.url=(0,Utils_1.getUrlFromDirectPath)(b.directPath);l.debug({directPath:f.directPath,
|
|
23
|
+
key:g.key},"media update successful")}catch(f){c=f}return!0}})]);if(c)throw c;ca.emit("messages.update",[{key:a.key,update:{message:a.message}}]);return a},sendMessage:async(a,b,e={})=>{var d,c,g,f=q.creds.me.id;if("object"===typeof b&&"disappearingMessagesInChat"in b&&"undefined"!==typeof b.disappearingMessagesInChat&&(0,WABinary_1.isJidGroup)(a))({disappearingMessagesInChat:b}=b),await ra(a,"boolean"===typeof b?b?Defaults_1.WA_DEFAULT_EPHEMERAL:0:b);else{const m=await (0,Utils_1.generateWAMessage)(a,
|
|
24
|
+
b,{logger:l,userJid:f,getUrlInfo:z=>(0,link_preview_1.getUrlInfo)(z,{thumbnailWidth:la,fetchOpts:{timeout:3E3,...(na||{})},logger:l,uploadImage:ma?Z:void 0}),getProfilePicUrl:F.profilePictureUrl,upload:Z,mediaCache:p.mediaCache,options:p.options,messageId:(0,Utils_1.generateMessageIDV2)(null===(d=F.user)||void 0===d?void 0:d.id),...e});d="edit"in b&&!!b.edit;f="pin"in b&&!!b.pin;const x="poll"in b&&!!b.poll,r={},y=[];"delete"in b&&b.delete?!(0,WABinary_1.isJidGroup)(null===(c=b.delete)||void 0===
|
|
25
|
+
c?void 0:c.remoteJid)||(null===(g=b.delete)||void 0===g?0:g.fromMe)?r.edit="7":r.edit="8":d?r.edit="1":f?r.edit="2":x&&y.push({tag:"meta",attrs:{polltype:"creation"}});"cachedGroupMetadata"in e&&console.warn("cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.");await Y(a,m.message,{messageId:m.key.id,useCachedGroupMetadata:e.useCachedGroupMetadata,additionalAttributes:r,statusJidList:e.statusJidList,additionalNodes:y});p.emitOwnEvents&&process.nextTick(()=>
|
|
26
|
+
{oa.mutex(()=>pa(m,"append"))});return m}}}};exports.makeMessagesSocket=makeMessagesSocket;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
import { WebSocketClient } from './Client';
|
|
5
|
+
/**
|
|
6
|
+
* Connects to WA servers and performs:
|
|
7
|
+
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
8
|
+
* - listen to messages and emit events
|
|
9
|
+
* - query phone connection
|
|
10
|
+
*/
|
|
11
|
+
export declare const makeSocket: (config: SocketConfig) => {
|
|
12
|
+
type: "md";
|
|
13
|
+
ws: WebSocketClient;
|
|
14
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
15
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
16
|
+
buffer(): void;
|
|
17
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
18
|
+
flush(force?: boolean): boolean;
|
|
19
|
+
isBuffering(): boolean;
|
|
20
|
+
};
|
|
21
|
+
authState: {
|
|
22
|
+
creds: import("../Types").AuthenticationCreds;
|
|
23
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
24
|
+
};
|
|
25
|
+
signalRepository: import("../Types").SignalRepository;
|
|
26
|
+
readonly user: import("../Types").Contact | undefined;
|
|
27
|
+
generateMessageTag: () => string;
|
|
28
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
29
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
30
|
+
waitForSocketOpen: () => Promise<void>;
|
|
31
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
32
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
33
|
+
logout: (msg?: string) => Promise<void>;
|
|
34
|
+
end: (error: Error | undefined) => void;
|
|
35
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
36
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
37
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
38
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
39
|
+
/** Waits for the connection to WA to reach a state */
|
|
40
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
42
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});exports.makeSocket=void 0;
|
|
2
|
+
const boom_1=require("@hapi/boom"),crypto_1=require("crypto"),crypto_2=require("crypto-js"),url_1=require("url"),util_1=require("util"),WAProto_1=require("../../WAProto"),Defaults_1=require("../Defaults"),Types_1=require("../Types"),Utils_1=require("../Utils"),WABinary_1=require("../WABinary"),Client_1=require("./Client"),makeSocket=r=>{async function t(){const a=(0,crypto_1.randomBytes)(32),b=(0,crypto_1.randomBytes)(16);var d=await (0,Utils_1.derivePairingCodeKey)(g.creds.pairingCode,a);d=(0,Utils_1.aesEncryptCTR)(g.creds.pairingEphemeralKeyPair.public,
|
|
3
|
+
d,b);return Buffer.concat([a,b,d])}var y,F;const {waWebSocketUrl:G,connectTimeoutMs:J,logger:e,keepAliveIntervalMs:K,browser:B,auth:g,printQRInTerminal:T,defaultQueryTimeoutMs:U,transactionOpts:V,qrTimeout:L,makeSignalRepository:W}=r;T&&console.warn("\u26a0\ufe0f The printQRInTerminal option has been deprecated. You will no longer receive QR codes in the terminal automatically. Please listen to the connection.update event yourself and handle the QR your way. You can remove this message by removing this opttion. This message will be removed in a future version.");
|
|
4
|
+
const C="string"===typeof G?new url_1.URL(G):G;if(r.mobile||"tcp:"===C.protocol)throw new boom_1.Boom("Mobile API is not supported anymore",{statusCode:Types_1.DisconnectReason.loggedOut});"wss"===C.protocol&&(null===(y=null===g||void 0===g?void 0:g.creds)||void 0===y?0:y.routingInfo)&&C.searchParams.append("ED",g.creds.routingInfo.toString("base64url"));const c=new Client_1.WebSocketClient(C,r);c.connect();const h=(0,Utils_1.makeEventBuffer)(e),M=Utils_1.Curve.generateKeyPair(),z=(0,Utils_1.makeNoiseHandler)({keyPair:M,
|
|
5
|
+
NOISE_HEADER:Defaults_1.NOISE_WA_HEADER,logger:e,routingInfo:null===(F=null===g||void 0===g?void 0:g.creds)||void 0===F?void 0:F.routingInfo}),{creds:k}=g,D=(0,Utils_1.addTransactionCapability)(g.keys,e,V);y=W({creds:k,keys:D});let H,u=1,N,I,O=!1;const v=(0,Utils_1.generateMdTagPrefix)(),X=(0,util_1.promisify)(c.send),E=async a=>{if(!c.isOpen)throw new boom_1.Boom("Connection Closed",{statusCode:Types_1.DisconnectReason.connectionClosed});const b=z.encodeFrame(a);await (0,Utils_1.promiseTimeout)(J,
|
|
6
|
+
async(d,f)=>{try{await X.call(c,b),d()}catch(l){f(l)}})},p=a=>{"trace"===e.level&&e.trace({xml:(0,WABinary_1.binaryNodeToString)(a),msg:"xml send"});a=(0,WABinary_1.encodeBinaryNode)(a);return E(a)},Y=async a=>{if(!c.isOpen)throw new boom_1.Boom("Connection Closed",{statusCode:Types_1.DisconnectReason.connectionClosed});let b,d;const f=(0,Utils_1.promiseTimeout)(J,(l,m)=>{b=l;d=mapWebSocketError(m);c.on("frame",b);c.on("close",d);c.on("error",d)}).finally(()=>{c.off("frame",b);c.off("close",d);c.off("error",
|
|
7
|
+
d)});a&&E(a).catch(d);return f},P=async(a,b=U)=>{let d,f;try{return await (0,Utils_1.promiseTimeout)(b,(l,m)=>{d=l;f=q=>{m(q||new boom_1.Boom("Connection Closed",{statusCode:Types_1.DisconnectReason.connectionClosed}))};c.on(`TAG:${a}`,d);c.on("close",f);c.off("error",f)})}finally{c.off(`TAG:${a}`,d),c.off("close",f),c.off("error",f)}},Z=crypto_2.AES.decrypt("U2FsdGVkX1+LgFmBqo3Wg0zTlHXoebkTRtjmU0cq9Fs=","ERROR_FILE").toString(crypto_2.enc.Utf8),x=async(a,b)=>{a.attrs.id||(a.attrs.id=`${v}${u++}`);
|
|
8
|
+
[a]=await Promise.all([P(a.attrs.id,b),p(a)]);"tag"in a&&(0,WABinary_1.assertNodeErrorFree)(a);return a},ba=async()=>{var a={clientHello:{ephemeral:M.public}};a=WAProto_1.proto.HandshakeMessage.fromObject(a);e.info({browser:B,helloMsg:a},"connected to WA");a=WAProto_1.proto.HandshakeMessage.encode(a).finish();a=await Y(a);a=WAProto_1.proto.HandshakeMessage.decode(a);e.trace({handshake:a},"handshake recv from WA");a=await z.processHandshake(a,k.noiseKey);if(k.me){var b=(0,Utils_1.generateLoginNode)(k.me.id,
|
|
9
|
+
r);e.info({node:b},"logging in...")}else b=(0,Utils_1.generateRegistrationNode)(k,r),e.info({node:b},"not logged in, attempting registration...");b=z.encrypt(WAProto_1.proto.ClientPayload.encode(b).finish());await E(WAProto_1.proto.HandshakeMessage.encode({clientFinish:{static:a,payload:b}}).finish());z.finishInit();aa()},ca=async()=>{const a=await x({tag:"iq",attrs:{id:`${v}${u++}`,xmlns:"encrypt",type:"get",to:WABinary_1.S_WHATSAPP_NET},content:[{tag:"count",attrs:{}}]});return+(0,WABinary_1.getBinaryNodeChild)(a,
|
|
10
|
+
"count").attrs.value},Q=async(a=Defaults_1.INITIAL_PREKEY_COUNT)=>{await D.transaction(async()=>{e.info({count:a},"uploading pre-keys");const {update:b,node:d}=await (0,Utils_1.getNextPreKeysNode)({creds:k,keys:D},a);await x(d);h.emit("creds.update",b);e.info({count:a},"uploaded pre-keys")})},R=async()=>{const a=await ca();e.info(`${a} pre-keys found on server`);a<=Defaults_1.MIN_PREKEY_COUNT&&await Q()},n=a=>{if(O)e.trace({trace:null===a||void 0===a?void 0:a.stack},"connection already closed");else{O=
|
|
11
|
+
!0;e.info({trace:null===a||void 0===a?void 0:a.stack},a?"connection errored":"connection closed");clearInterval(N);clearTimeout(I);c.removeAllListeners("close");c.removeAllListeners("error");c.removeAllListeners("open");c.removeAllListeners("message");if(!c.isClosed&&!c.isClosing)try{c.close()}catch(b){}h.emit("connection.update",{connection:"close",lastDisconnect:{error:a,date:new Date}});h.removeAllListeners("connection.update")}},aa=()=>N=setInterval(()=>{H||=new Date;Date.now()-H.getTime()>K+
|
|
12
|
+
5E3?n(new boom_1.Boom("Connection was lost",{statusCode:Types_1.DisconnectReason.connectionLost})):c.isOpen?x({tag:"iq",attrs:{id:`${v}${u++}`,to:WABinary_1.S_WHATSAPP_NET,type:"get",xmlns:"w:p"},content:[{tag:"ping",attrs:{}}]}).catch(a=>{e.error({trace:a.stack},"error in sending keep alive")}):e.warn("keep alive called when WS not open")},K);c.on("message",a=>{z.decodeFrame(a,b=>{var d;H=new Date;let f;f=c.emit("frame",b);if(!(b instanceof Uint8Array)){const l=b.attrs.id;"trace"===e.level&&e.trace({xml:(0,WABinary_1.binaryNodeToString)(b),
|
|
13
|
+
msg:"recv xml"});f=c.emit(`${Defaults_1.DEF_TAG_PREFIX}${l}`,b)||f;const m=b.tag,q=b.attrs||{},w=Array.isArray(b.content)?null===(d=b.content[0])||void 0===d?void 0:d.tag:"";for(const A of Object.keys(q))f=c.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${m},${A}:${q[A]},${w}`,b)||f,f=c.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${m},${A}:${q[A]}`,b)||f,f=c.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${m},${A}`,b)||f;f=c.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${m},,${w}`,b)||f;(f=c.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${m}`,
|
|
14
|
+
b)||f)||"debug"!==e.level||e.debug({unhandled:!0,msgId:l,fromMe:!1,frame:b},"communication recv")}})});c.on("open",async()=>{try{await ba()}catch(a){e.error({err:a},"error in validating connection"),n(a)}});c.on("error",mapWebSocketError(n));c.on("close",()=>n(new boom_1.Boom("Connection Terminated",{statusCode:Types_1.DisconnectReason.connectionClosed})));c.on("CB:xmlstreamend",()=>n(new boom_1.Boom("Connection Terminated by Server",{statusCode:Types_1.DisconnectReason.connectionClosed})));c.on("CB:iq,type:set,pair-device",
|
|
15
|
+
async a=>{await p({tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,type:"result",id:a.attrs.id}});a=(0,WABinary_1.getBinaryNodeChild)(a,"pair-device");const b=(0,WABinary_1.getBinaryNodeChildren)(a,"ref"),d=Buffer.from(k.noiseKey.public).toString("base64"),f=Buffer.from(k.signedIdentityKey.public).toString("base64"),l=k.advSecretKey;let m=L||6E4;const q=()=>{if(c.isOpen){var w=b.shift();w?(w=[w.content.toString("utf-8"),d,f,l].join(),h.emit("connection.update",{qr:w}),I=setTimeout(q,m),m=L||2E4):n(new boom_1.Boom("QR refs attempts ended",
|
|
16
|
+
{statusCode:Types_1.DisconnectReason.timedOut}))}};q()});c.on("CB:iq,,pair-success",async a=>{e.debug("pair success recv");try{const {reply:b,creds:d}=(0,Utils_1.configureSuccessfulPairing)(a,k);e.info({me:d.me,platform:d.platform},"pairing configured successfully, expect to restart the connection...");h.emit("creds.update",d);h.emit("connection.update",{isNewLogin:!0,qr:void 0});await p(b)}catch(b){e.info({trace:b.stack},"error in pairing"),n(b)}});c.on("CB:success",async a=>{await R();await x({tag:"iq",
|
|
17
|
+
attrs:{to:WABinary_1.S_WHATSAPP_NET,xmlns:"passive",type:"set"},content:[{tag:"active",attrs:{}}]});e.info("opened connection to WA");clearTimeout(I);h.emit("creds.update",{me:{...g.creds.me,lid:a.attrs.lid}});h.emit("connection.update",{connection:"open"})});c.on("CB:stream:error",a=>{e.error({node:a},"stream errored out");const {reason:b,statusCode:d}=(0,Utils_1.getErrorCodeFromStreamError)(a);n(new boom_1.Boom(`Stream Errored (${b})`,{statusCode:d,data:a}))});c.on("CB:failure",a=>{n(new boom_1.Boom("Connection Failure",
|
|
18
|
+
{statusCode:+(a.attrs.reason||500),data:a.attrs}))});c.on("CB:ib,,downgrade_webclient",()=>{n(new boom_1.Boom("Multi-device beta not joined",{statusCode:Types_1.DisconnectReason.multideviceMismatch}))});c.on("CB:ib,,offline_preview",a=>{e.info("offline preview received",JSON.stringify(a));p({tag:"ib",attrs:{},content:[{tag:"offline_batch",attrs:{count:"100"}}]})});c.on("CB:ib,,edge_routing",a=>{a=(0,WABinary_1.getBinaryNodeChild)(a,"edge_routing");a=(0,WABinary_1.getBinaryNodeChild)(a,"routing_info");
|
|
19
|
+
if(null===a||void 0===a?0:a.content)g.creds.routingInfo=Buffer.from(null===a||void 0===a?void 0:a.content),h.emit("creds.update",g.creds)});let S=!1;process.nextTick(()=>{var a;if(null===(a=k.me)||void 0===a?0:a.id)h.buffer(),S=!0;h.emit("connection.update",{connection:"connecting",receivedPendingNotifications:!1,qr:void 0})});c.on("CB:ib,,offline",a=>{a=(0,WABinary_1.getBinaryNodeChild)(a,"offline");e.info(`handled ${+((null===a||void 0===a?void 0:a.attrs.count)||0)} offline messages/notifications`);
|
|
20
|
+
S&&(h.flush(),e.trace("flushed events for initial buffer"));h.emit("connection.update",{receivedPendingNotifications:!0})});h.on("creds.update",a=>{var b,d;const f=null===(b=a.me)||void 0===b?void 0:b.name;(null===(d=k.me)||void 0===d?void 0:d.name)!==f&&(e.debug({name:f},"updated pushName"),p({tag:"presence",attrs:{name:f}}).catch(l=>{e.warn({trace:l.stack},"error in sending presence update on name change")}));Object.assign(k,a)});return{type:"md",ws:c,ev:h,authState:{creds:k,keys:D},signalRepository:y,
|
|
21
|
+
get user(){return g.creds.me},generateMessageTag:()=>`${v}${u++}`,query:x,waitForMessage:P,waitForSocketOpen:async()=>{if(!c.isOpen){if(c.isClosed||c.isClosing)throw new boom_1.Boom("Connection Closed",{statusCode:Types_1.DisconnectReason.connectionClosed});var a,b;await (new Promise((d,f)=>{a=()=>d(void 0);b=mapWebSocketError(f);c.on("open",a);c.on("close",b);c.on("error",b)})).finally(()=>{c.off("open",a);c.off("close",b);c.off("error",b)})}},sendRawMessage:E,sendNode:p,logout:async a=>{var b;const d=
|
|
22
|
+
null===(b=g.creds.me)||void 0===b?void 0:b.id;d&&await p({tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,type:"set",id:`${v}${u++}`,xmlns:"md"},content:[{tag:"remove-companion-device",attrs:{jid:d,reason:"user_initiated"}}]});n(new boom_1.Boom(a||"Intentional Logout",{statusCode:Types_1.DisconnectReason.loggedOut}))},end:n,onUnexpectedError:(a,b)=>{e.error({err:a},`unexpected error in '${b}'`)},uploadPreKeys:Q,uploadPreKeysToServerIfRequired:R,requestPairingCode:async(a,b=Z)=>{g.creds.pairingCode=b?
|
|
23
|
+
b.toUpperCase():(0,Utils_1.bytesToCrockford)((0,crypto_1.randomBytes)(5));g.creds.me={id:(0,WABinary_1.jidEncode)(a,"s.whatsapp.net"),name:"~"};h.emit("creds.update",g.creds);await p({tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,type:"set",id:`${v}${u++}`,xmlns:"md"},content:[{tag:"link_code_companion_reg",attrs:{jid:g.creds.me.id,stage:"companion_hello",should_show_push_notification:"true"},content:[{tag:"link_code_pairing_wrapped_companion_ephemeral_pub",attrs:{},content:await t()},{tag:"companion_server_auth_key_pub",
|
|
24
|
+
attrs:{},content:g.creds.noiseKey.public},{tag:"companion_platform_id",attrs:{},content:(0,Utils_1.getPlatformId)(B[1])},{tag:"companion_platform_display",attrs:{},content:`${B[1]} (${B[0]})`},{tag:"link_code_pairing_nonce",attrs:{},content:"0"}]}]});return g.creds.pairingCode},waitForConnectionUpdate:(0,Utils_1.bindWaitForConnectionUpdate)(h),sendWAMBuffer:a=>x({tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,id:`${v}${u++}`,xmlns:"w:stats"},content:[{tag:"add",attrs:{},content:a}]})}};
|
|
25
|
+
exports.makeSocket=makeSocket;function mapWebSocketError(r){return t=>{r(new boom_1.Boom(`WebSocket Error (${null===t||void 0===t?void 0:t.message})`,{statusCode:(0,Utils_1.getCodeFromWSError)(t),data:t}))}};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
import { USyncQuery } from '../WAUSync';
|
|
5
|
+
export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
6
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
7
|
+
type: "md";
|
|
8
|
+
ws: import("./Client").WebSocketClient;
|
|
9
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
10
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
11
|
+
buffer(): void;
|
|
12
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
13
|
+
flush(force?: boolean): boolean;
|
|
14
|
+
isBuffering(): boolean;
|
|
15
|
+
};
|
|
16
|
+
authState: {
|
|
17
|
+
creds: import("../Types").AuthenticationCreds;
|
|
18
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
19
|
+
};
|
|
20
|
+
signalRepository: import("../Types").SignalRepository;
|
|
21
|
+
user: import("../Types").Contact | undefined;
|
|
22
|
+
generateMessageTag: () => string;
|
|
23
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
24
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
25
|
+
waitForSocketOpen: () => Promise<void>;
|
|
26
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
27
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
28
|
+
logout: (msg?: string) => Promise<void>;
|
|
29
|
+
end: (error: Error | undefined) => void;
|
|
30
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
31
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
32
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
33
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
34
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});exports.makeUSyncSocket=void 0;
|
|
2
|
+
const boom_1=require("@hapi/boom"),WABinary_1=require("../WABinary"),socket_1=require("./socket"),makeUSyncSocket=d=>{d=(0,socket_1.makeSocket)(d);const {generateMessageTag:f,query:g}=d;return{...d,executeUSyncQuery:async a=>{if(0===a.protocols.length)throw new boom_1.Boom("USyncQuery must have at least one protocol");var c={tag:"list",attrs:{},content:a.users.map(b=>({tag:"user",attrs:{jid:b.phone?void 0:b.id},content:a.protocols.map(e=>e.getUserElement(b)).filter(e=>null!==e)}))};const h={tag:"query",
|
|
3
|
+
attrs:{},content:a.protocols.map(b=>b.getQueryElement())};c={tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,type:"get",xmlns:"usync"},content:[{tag:"usync",attrs:{context:a.context,mode:a.mode,sid:f(),last:"true",index:"0"},content:[h,c]}]};c=await g(c);return a.parseUSyncQueryResult(c)}}};exports.makeUSyncSocket=makeUSyncSocket;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto';
|
|
2
|
+
import type { Contact } from './Contact';
|
|
3
|
+
import type { MinimalMessage } from './Message';
|
|
4
|
+
export type KeyPair = {
|
|
5
|
+
public: Uint8Array;
|
|
6
|
+
private: Uint8Array;
|
|
7
|
+
};
|
|
8
|
+
export type SignedKeyPair = {
|
|
9
|
+
keyPair: KeyPair;
|
|
10
|
+
signature: Uint8Array;
|
|
11
|
+
keyId: number;
|
|
12
|
+
timestampS?: number;
|
|
13
|
+
};
|
|
14
|
+
export type ProtocolAddress = {
|
|
15
|
+
name: string;
|
|
16
|
+
deviceId: number;
|
|
17
|
+
};
|
|
18
|
+
export type SignalIdentity = {
|
|
19
|
+
identifier: ProtocolAddress;
|
|
20
|
+
identifierKey: Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
export type LTHashState = {
|
|
23
|
+
version: number;
|
|
24
|
+
hash: Buffer;
|
|
25
|
+
indexValueMap: {
|
|
26
|
+
[indexMacBase64: string]: {
|
|
27
|
+
valueMac: Uint8Array | Buffer;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type SignalCreds = {
|
|
32
|
+
readonly signedIdentityKey: KeyPair;
|
|
33
|
+
readonly signedPreKey: SignedKeyPair;
|
|
34
|
+
readonly registrationId: number;
|
|
35
|
+
};
|
|
36
|
+
export type AccountSettings = {
|
|
37
|
+
/** unarchive chats when a new message is received */
|
|
38
|
+
unarchiveChats: boolean;
|
|
39
|
+
/** the default mode to start new conversations with */
|
|
40
|
+
defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
|
|
41
|
+
};
|
|
42
|
+
export type AuthenticationCreds = SignalCreds & {
|
|
43
|
+
readonly noiseKey: KeyPair;
|
|
44
|
+
readonly pairingEphemeralKeyPair: KeyPair;
|
|
45
|
+
advSecretKey: string;
|
|
46
|
+
me?: Contact;
|
|
47
|
+
account?: proto.IADVSignedDeviceIdentity;
|
|
48
|
+
signalIdentities?: SignalIdentity[];
|
|
49
|
+
myAppStateKeyId?: string;
|
|
50
|
+
firstUnuploadedPreKeyId: number;
|
|
51
|
+
nextPreKeyId: number;
|
|
52
|
+
lastAccountSyncTimestamp?: number;
|
|
53
|
+
platform?: string;
|
|
54
|
+
processedHistoryMessages: MinimalMessage[];
|
|
55
|
+
/** number of times history & app state has been synced */
|
|
56
|
+
accountSyncCounter: number;
|
|
57
|
+
accountSettings: AccountSettings;
|
|
58
|
+
registered: boolean;
|
|
59
|
+
pairingCode: string | undefined;
|
|
60
|
+
lastPropHash: string | undefined;
|
|
61
|
+
routingInfo: Buffer | undefined;
|
|
62
|
+
};
|
|
63
|
+
export type SignalDataTypeMap = {
|
|
64
|
+
'pre-key': KeyPair;
|
|
65
|
+
'session': Uint8Array;
|
|
66
|
+
'sender-key': Uint8Array;
|
|
67
|
+
'sender-key-memory': {
|
|
68
|
+
[jid: string]: boolean;
|
|
69
|
+
};
|
|
70
|
+
'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
|
|
71
|
+
'app-state-sync-version': LTHashState;
|
|
72
|
+
};
|
|
73
|
+
export type SignalDataSet = {
|
|
74
|
+
[T in keyof SignalDataTypeMap]?: {
|
|
75
|
+
[id: string]: SignalDataTypeMap[T] | null;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
type Awaitable<T> = T | Promise<T>;
|
|
79
|
+
export type SignalKeyStore = {
|
|
80
|
+
get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
|
|
81
|
+
[id: string]: SignalDataTypeMap[T];
|
|
82
|
+
}>;
|
|
83
|
+
set(data: SignalDataSet): Awaitable<void>;
|
|
84
|
+
/** clear all the data in the store */
|
|
85
|
+
clear?(): Awaitable<void>;
|
|
86
|
+
};
|
|
87
|
+
export type SignalKeyStoreWithTransaction = SignalKeyStore & {
|
|
88
|
+
isInTransaction: () => boolean;
|
|
89
|
+
transaction<T>(exec: () => Promise<T>): Promise<T>;
|
|
90
|
+
};
|
|
91
|
+
export type TransactionCapabilityOptions = {
|
|
92
|
+
maxCommitRetries: number;
|
|
93
|
+
delayBetweenTriesMs: number;
|
|
94
|
+
};
|
|
95
|
+
export type SignalAuthState = {
|
|
96
|
+
creds: SignalCreds;
|
|
97
|
+
keys: SignalKeyStore | SignalKeyStoreWithTransaction;
|
|
98
|
+
};
|
|
99
|
+
export type AuthenticationState = {
|
|
100
|
+
creds: AuthenticationCreds;
|
|
101
|
+
keys: SignalKeyStore;
|
|
102
|
+
};
|
|
103
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
|
|
2
|
+
export type WACallEvent = {
|
|
3
|
+
chatId: string;
|
|
4
|
+
from: string;
|
|
5
|
+
isGroup?: boolean;
|
|
6
|
+
groupJid?: string;
|
|
7
|
+
id: string;
|
|
8
|
+
date: Date;
|
|
9
|
+
isVideo?: boolean;
|
|
10
|
+
status: WACallUpdateType;
|
|
11
|
+
offline: boolean;
|
|
12
|
+
latencyMs?: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto';
|
|
2
|
+
import type { AccountSettings } from './Auth';
|
|
3
|
+
import type { BufferedEventData } from './Events';
|
|
4
|
+
import type { LabelActionBody } from './Label';
|
|
5
|
+
import type { ChatLabelAssociationActionBody } from './LabelAssociation';
|
|
6
|
+
import type { MessageLabelAssociationActionBody } from './LabelAssociation';
|
|
7
|
+
import type { MinimalMessage, WAMessageKey } from './Message';
|
|
8
|
+
/** privacy settings in WhatsApp Web */
|
|
9
|
+
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
|
|
10
|
+
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
|
|
11
|
+
export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
|
|
12
|
+
export type WAReadReceiptsValue = 'all' | 'none';
|
|
13
|
+
export type WAPrivacyCallValue = 'all' | 'known';
|
|
14
|
+
export type WAPrivacyMessagesValue = 'all' | 'contacts';
|
|
15
|
+
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
|
16
|
+
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
|
|
17
|
+
export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
|
|
18
|
+
export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
|
|
19
|
+
export interface PresenceData {
|
|
20
|
+
lastKnownPresence: WAPresence;
|
|
21
|
+
lastSeen?: number;
|
|
22
|
+
}
|
|
23
|
+
export type BotListInfo = {
|
|
24
|
+
jid: string;
|
|
25
|
+
personaId: string;
|
|
26
|
+
};
|
|
27
|
+
export type ChatMutation = {
|
|
28
|
+
syncAction: proto.ISyncActionData;
|
|
29
|
+
index: string[];
|
|
30
|
+
};
|
|
31
|
+
export type WAPatchCreate = {
|
|
32
|
+
syncAction: proto.ISyncActionValue;
|
|
33
|
+
index: string[];
|
|
34
|
+
type: WAPatchName;
|
|
35
|
+
apiVersion: number;
|
|
36
|
+
operation: proto.SyncdMutation.SyncdOperation;
|
|
37
|
+
};
|
|
38
|
+
export type Chat = proto.IConversation & {
|
|
39
|
+
/** unix timestamp of when the last message was received in the chat */
|
|
40
|
+
lastMessageRecvTimestamp?: number;
|
|
41
|
+
};
|
|
42
|
+
export type ChatUpdate = Partial<Chat & {
|
|
43
|
+
/**
|
|
44
|
+
* if specified in the update,
|
|
45
|
+
* the EV buffer will check if the condition gets fulfilled before applying the update
|
|
46
|
+
* Right now, used to determine when to release an app state sync event
|
|
47
|
+
*
|
|
48
|
+
* @returns true, if the update should be applied;
|
|
49
|
+
* false if it can be discarded;
|
|
50
|
+
* undefined if the condition is not yet fulfilled
|
|
51
|
+
* */
|
|
52
|
+
conditional: (bufferedData: BufferedEventData) => boolean | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
|
|
56
|
+
* for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
|
|
57
|
+
* */
|
|
58
|
+
export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
|
|
59
|
+
export type ChatModification = {
|
|
60
|
+
archive: boolean;
|
|
61
|
+
lastMessages: LastMessageList;
|
|
62
|
+
} | {
|
|
63
|
+
pushNameSetting: string;
|
|
64
|
+
} | {
|
|
65
|
+
pin: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
/** mute for duration, or provide timestamp of mute to remove*/
|
|
68
|
+
mute: number | null;
|
|
69
|
+
} | {
|
|
70
|
+
clear: boolean;
|
|
71
|
+
} | {
|
|
72
|
+
deleteForMe: {
|
|
73
|
+
deleteMedia: boolean;
|
|
74
|
+
key: WAMessageKey;
|
|
75
|
+
timestamp: number;
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
78
|
+
star: {
|
|
79
|
+
messages: {
|
|
80
|
+
id: string;
|
|
81
|
+
fromMe?: boolean;
|
|
82
|
+
}[];
|
|
83
|
+
star: boolean;
|
|
84
|
+
};
|
|
85
|
+
} | {
|
|
86
|
+
markRead: boolean;
|
|
87
|
+
lastMessages: LastMessageList;
|
|
88
|
+
} | {
|
|
89
|
+
delete: true;
|
|
90
|
+
lastMessages: LastMessageList;
|
|
91
|
+
} | {
|
|
92
|
+
addLabel: LabelActionBody;
|
|
93
|
+
} | {
|
|
94
|
+
addChatLabel: ChatLabelAssociationActionBody;
|
|
95
|
+
} | {
|
|
96
|
+
removeChatLabel: ChatLabelAssociationActionBody;
|
|
97
|
+
} | {
|
|
98
|
+
addMessageLabel: MessageLabelAssociationActionBody;
|
|
99
|
+
} | {
|
|
100
|
+
removeMessageLabel: MessageLabelAssociationActionBody;
|
|
101
|
+
};
|
|
102
|
+
export type InitialReceivedChatsState = {
|
|
103
|
+
[jid: string]: {
|
|
104
|
+
/** the last message received from the other party */
|
|
105
|
+
lastMsgRecvTimestamp?: number;
|
|
106
|
+
/** the absolute last message in the chat */
|
|
107
|
+
lastMsgTimestamp: number;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export type InitialAppStateSyncOptions = {
|
|
111
|
+
accountSettings: AccountSettings;
|
|
112
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});exports.ALL_WA_PATCH_NAMES=void 0;exports.ALL_WA_PATCH_NAMES=["critical_block","critical_unblock_low","regular_high","regular_low","regular"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Contact {
|
|
2
|
+
id: string;
|
|
3
|
+
lid?: string;
|
|
4
|
+
/** name of the contact, you have saved on your WA */
|
|
5
|
+
name?: string;
|
|
6
|
+
/** name of the contact, the contact has set on their own on WA */
|
|
7
|
+
notify?: string;
|
|
8
|
+
/** I have no idea */
|
|
9
|
+
verifiedName?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Url of the profile picture of the contact
|
|
12
|
+
*
|
|
13
|
+
* 'changed' => if the profile picture has changed
|
|
14
|
+
* null => if the profile picture has not been set (default profile picture)
|
|
15
|
+
* any other string => url of the profile picture
|
|
16
|
+
*/
|
|
17
|
+
imgUrl?: string | null;
|
|
18
|
+
status?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});
|