@kelvdra/baileys 1.0.3 → 1.0.4
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/README.md +75 -1499
- package/lib/Defaults/index.d.ts +62 -0
- package/lib/Defaults/index.js +2 -2
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/lid-mapping.d.ts +23 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/business.d.ts +190 -0
- package/lib/Socket/chats.d.ts +100 -0
- package/lib/Socket/chats.js +14 -13
- package/lib/Socket/communities.d.ts +246 -0
- package/lib/Socket/groups.d.ts +139 -0
- package/lib/Socket/groups.js +2 -3
- package/lib/Socket/hydra.js +1 -2
- package/lib/Socket/index.d.ts +233 -0
- package/lib/Socket/messages-recv.d.ts +175 -0
- package/lib/Socket/messages-recv.js +325 -515
- package/lib/Socket/messages-send.d.ts +171 -0
- package/lib/Socket/messages-send.js +104 -467
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/newsletter.d.ts +149 -0
- package/lib/Socket/socket.d.ts +53 -0
- package/lib/Socket/socket.js +52 -51
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-in-memory-store.d.ts +123 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Types/Auth.d.ts +115 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Call.d.ts +14 -0
- package/lib/Types/Chat.d.ts +123 -0
- package/lib/Types/Contact.d.ts +24 -0
- package/lib/Types/Events.d.ts +202 -0
- package/lib/Types/GroupMetadata.d.ts +67 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/Message.d.ts +382 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Signal.d.ts +76 -0
- package/lib/Types/Socket.d.ts +133 -0
- package/lib/Types/State.d.ts +39 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/index.d.ts +65 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.js +5 -7
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/generics.d.ts +90 -0
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/index.d.ts +19 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/lt-hash.d.ts +13 -0
- package/lib/Utils/make-mutex.d.ts +8 -0
- package/lib/Utils/message-retry-manager.d.ts +82 -0
- package/lib/Utils/messages-media.d.ts +114 -0
- package/lib/Utils/messages-media.js +69 -33
- package/lib/Utils/messages.d.ts +89 -0
- package/lib/Utils/messages.js +42 -12
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.js +7 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/index.d.ts +13 -0
- package/package.json +3 -34
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BinaryNode } from '../WABinary/index.js';
|
|
2
|
+
export declare const executeWMexQuery: <T>(variables: Record<string, unknown>, queryId: string, dataPath: string, query: (node: BinaryNode) => Promise<BinaryNode>, generateMessageTag: () => string) => Promise<T>;
|
|
3
|
+
//# sourceMappingURL=mex.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { SocketConfig, WAMediaUpload } from '../Types/index.js';
|
|
2
|
+
import type { NewsletterMetadata, NewsletterUpdate } from '../Types/index.js';
|
|
3
|
+
export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
4
|
+
newsletterCreate: (name: string, description?: string) => Promise<NewsletterMetadata>;
|
|
5
|
+
newsletterUpdate: (jid: string, updates: NewsletterUpdate) => Promise<unknown>;
|
|
6
|
+
newsletterSubscribers: (jid: string) => Promise<{
|
|
7
|
+
subscribers: number;
|
|
8
|
+
}>;
|
|
9
|
+
newsletterMetadata: (type: "invite" | "jid", key: string) => Promise<NewsletterMetadata | null>;
|
|
10
|
+
newsletterFollow: (jid: string) => Promise<unknown>;
|
|
11
|
+
newsletterUnfollow: (jid: string) => Promise<unknown>;
|
|
12
|
+
newsletterMute: (jid: string) => Promise<unknown>;
|
|
13
|
+
newsletterUnmute: (jid: string) => Promise<unknown>;
|
|
14
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<unknown>;
|
|
15
|
+
newsletterUpdateDescription: (jid: string, description: string) => Promise<unknown>;
|
|
16
|
+
newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<unknown>;
|
|
17
|
+
newsletterRemovePicture: (jid: string) => Promise<unknown>;
|
|
18
|
+
newsletterReactMessage: (jid: string, serverId: string, reaction?: string) => Promise<void>;
|
|
19
|
+
newsletterFetchMessages: (jid: string, count: number, since: number, after: number) => Promise<any>;
|
|
20
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
21
|
+
duration: string;
|
|
22
|
+
} | null>;
|
|
23
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
24
|
+
newsletterChangeOwner: (jid: string, newOwnerJid: string) => Promise<void>;
|
|
25
|
+
newsletterDemote: (jid: string, userJid: string) => Promise<void>;
|
|
26
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
27
|
+
groupMetadata: (jid: string) => Promise<import("../index.js").GroupMetadata>;
|
|
28
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../index.js").GroupMetadata>;
|
|
29
|
+
groupLeave: (id: string) => Promise<void>;
|
|
30
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
31
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
}[]>;
|
|
34
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
35
|
+
status: string;
|
|
36
|
+
jid: string | undefined;
|
|
37
|
+
}[]>;
|
|
38
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../index.js").ParticipantAction) => Promise<{
|
|
39
|
+
status: string;
|
|
40
|
+
jid: string | undefined;
|
|
41
|
+
content: import("../index.js").BinaryNode;
|
|
42
|
+
}[]>;
|
|
43
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
44
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
45
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
46
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
47
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
48
|
+
groupAcceptInviteV4: (key: string | import("../index.js").WAMessageKey, inviteMessage: import("../index.js").proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
49
|
+
groupGetInviteInfo: (code: string) => Promise<import("../index.js").GroupMetadata>;
|
|
50
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
51
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
52
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
53
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
54
|
+
groupFetchAllParticipating: () => Promise<{
|
|
55
|
+
[_: string]: import("../index.js").GroupMetadata;
|
|
56
|
+
}>;
|
|
57
|
+
createCallLink: (type: "audio" | "video", event?: {
|
|
58
|
+
startTime: number;
|
|
59
|
+
}, timeoutMs?: number) => Promise<string | undefined>;
|
|
60
|
+
getBotListV2: () => Promise<import("../index.js").BotListInfo[]>;
|
|
61
|
+
processingMutex: {
|
|
62
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
63
|
+
};
|
|
64
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
65
|
+
[_: string]: string;
|
|
66
|
+
}>;
|
|
67
|
+
upsertMessage: (msg: import("../index.js").WAMessage, type: import("../index.js").MessageUpsertType) => Promise<void>;
|
|
68
|
+
appPatch: (patchCreate: import("../index.js").WAPatchCreate) => Promise<void>;
|
|
69
|
+
sendPresenceUpdate: (type: import("../index.js").WAPresence, toJid?: string) => Promise<void>;
|
|
70
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
71
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
72
|
+
fetchBlocklist: () => Promise<(string | undefined)[]>;
|
|
73
|
+
fetchStatus: (...jids: string[]) => Promise<import("../index.js").USyncQueryResultList[] | undefined>;
|
|
74
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index.js").USyncQueryResultList[] | undefined>;
|
|
75
|
+
updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
}) => Promise<void>;
|
|
79
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
|
80
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
|
81
|
+
updateProfileName: (name: string) => Promise<void>;
|
|
82
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
83
|
+
updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
|
|
84
|
+
updateCallPrivacy: (value: import("../index.js").WAPrivacyCallValue) => Promise<void>;
|
|
85
|
+
updateMessagesPrivacy: (value: import("../index.js").WAPrivacyMessagesValue) => Promise<void>;
|
|
86
|
+
updateLastSeenPrivacy: (value: import("../index.js").WAPrivacyValue) => Promise<void>;
|
|
87
|
+
updateOnlinePrivacy: (value: import("../index.js").WAPrivacyOnlineValue) => Promise<void>;
|
|
88
|
+
updateProfilePicturePrivacy: (value: import("../index.js").WAPrivacyValue) => Promise<void>;
|
|
89
|
+
updateStatusPrivacy: (value: import("../index.js").WAPrivacyValue) => Promise<void>;
|
|
90
|
+
updateReadReceiptsPrivacy: (value: import("../index.js").WAReadReceiptsValue) => Promise<void>;
|
|
91
|
+
updateGroupsAddPrivacy: (value: import("../index.js").WAPrivacyGroupAddValue) => Promise<void>;
|
|
92
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
93
|
+
getBusinessProfile: (jid: string) => Promise<import("../index.js").WABusinessProfile | void>;
|
|
94
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
95
|
+
chatModify: (mod: import("../index.js").ChatModification, jid: string) => Promise<void>;
|
|
96
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
97
|
+
addOrEditContact: (jid: string, contact: import("../index.js").proto.SyncActionValue.IContactAction) => Promise<void>;
|
|
98
|
+
removeContact: (jid: string) => Promise<void>;
|
|
99
|
+
addLabel: (jid: string, labels: import("../Types/Label.js").LabelActionBody) => Promise<void>;
|
|
100
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
101
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
102
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
103
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
104
|
+
star: (jid: string, messages: {
|
|
105
|
+
id: string;
|
|
106
|
+
fromMe?: boolean;
|
|
107
|
+
}[], star: boolean) => Promise<void>;
|
|
108
|
+
addOrEditQuickReply: (quickReply: import("../Types/Bussines.js").QuickReplyAction) => Promise<void>;
|
|
109
|
+
removeQuickReply: (timestamp: string) => Promise<void>;
|
|
110
|
+
type: "md";
|
|
111
|
+
ws: import("./Client/index.js").WebSocketClient;
|
|
112
|
+
ev: import("../index.js").BaileysEventEmitter & {
|
|
113
|
+
process(handler: (events: Partial<import("../index.js").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
114
|
+
buffer(): void;
|
|
115
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
|
|
116
|
+
flush(): boolean;
|
|
117
|
+
isBuffering(): boolean;
|
|
118
|
+
};
|
|
119
|
+
authState: {
|
|
120
|
+
creds: import("../index.js").AuthenticationCreds;
|
|
121
|
+
keys: import("../index.js").SignalKeyStoreWithTransaction;
|
|
122
|
+
};
|
|
123
|
+
signalRepository: import("../index.js").SignalRepositoryWithLIDStore;
|
|
124
|
+
user: import("../index.js").Contact | undefined;
|
|
125
|
+
generateMessageTag: () => string;
|
|
126
|
+
query: (node: import("../index.js").BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
127
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
|
|
128
|
+
waitForSocketOpen: () => Promise<void>;
|
|
129
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
130
|
+
sendNode: (frame: import("../index.js").BinaryNode) => Promise<void>;
|
|
131
|
+
logout: (msg?: string) => Promise<void>;
|
|
132
|
+
end: (error: Error | undefined) => void;
|
|
133
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
134
|
+
uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
|
|
135
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
136
|
+
digestKeyBundle: () => Promise<void>;
|
|
137
|
+
rotateSignedPreKey: () => Promise<void>;
|
|
138
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
139
|
+
wamBuffer: import("../index.js").BinaryInfo;
|
|
140
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
141
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
142
|
+
executeUSyncQuery: (usyncQuery: import("../index.js").USyncQuery) => Promise<import("../index.js").USyncQueryResult | undefined>;
|
|
143
|
+
onWhatsApp: (...phoneNumber: string[]) => Promise<{
|
|
144
|
+
jid: string;
|
|
145
|
+
exists: boolean;
|
|
146
|
+
}[] | undefined>;
|
|
147
|
+
};
|
|
148
|
+
export type NewsletterSocket = ReturnType<typeof makeNewsletterSocket>;
|
|
149
|
+
//# sourceMappingURL=newsletter.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import type { SocketConfig } from '../Types/index.js';
|
|
3
|
+
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
|
+
import { BinaryInfo } from '../WAM/BinaryInfo.js';
|
|
5
|
+
import { USyncQuery } from '../WAUSync/index.js';
|
|
6
|
+
import { WebSocketClient } from './Client/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Connects to WA servers and performs:
|
|
9
|
+
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
10
|
+
* - listen to messages and emit events
|
|
11
|
+
* - query phone connection
|
|
12
|
+
*/
|
|
13
|
+
export declare const makeSocket: (config: SocketConfig) => {
|
|
14
|
+
type: "md";
|
|
15
|
+
ws: WebSocketClient;
|
|
16
|
+
ev: import("../Types/index.js").BaileysEventEmitter & {
|
|
17
|
+
process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
18
|
+
buffer(): void;
|
|
19
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
|
|
20
|
+
flush(): boolean;
|
|
21
|
+
isBuffering(): boolean;
|
|
22
|
+
};
|
|
23
|
+
authState: {
|
|
24
|
+
creds: import("../Types/index.js").AuthenticationCreds;
|
|
25
|
+
keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
|
|
26
|
+
};
|
|
27
|
+
signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
|
|
28
|
+
readonly user: import("../Types/index.js").Contact | undefined;
|
|
29
|
+
generateMessageTag: () => string;
|
|
30
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
31
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
|
|
32
|
+
waitForSocketOpen: () => Promise<void>;
|
|
33
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
34
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
35
|
+
logout: (msg?: string) => Promise<void>;
|
|
36
|
+
end: (error: Error | undefined) => void;
|
|
37
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
38
|
+
uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
|
|
39
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
40
|
+
digestKeyBundle: () => Promise<void>;
|
|
41
|
+
rotateSignedPreKey: () => Promise<void>;
|
|
42
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
43
|
+
wamBuffer: BinaryInfo;
|
|
44
|
+
/** Waits for the connection to WA to reach a state */
|
|
45
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
46
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
47
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../index.js").USyncQueryResult | undefined>;
|
|
48
|
+
onWhatsApp: (...phoneNumber: string[]) => Promise<{
|
|
49
|
+
jid: string;
|
|
50
|
+
exists: boolean;
|
|
51
|
+
}[] | undefined>;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=socket.d.ts.map
|
package/lib/Socket/socket.js
CHANGED
|
@@ -582,16 +582,17 @@ export const makeSocket = (config) => {
|
|
|
582
582
|
}
|
|
583
583
|
end(new Boom(msg || 'Intentional Logout', { statusCode: DisconnectReason.loggedOut }));
|
|
584
584
|
};
|
|
585
|
-
const requestPairingCode = async (phoneNumber,
|
|
586
|
-
|
|
587
|
-
|
|
585
|
+
const requestPairingCode = async (phoneNumber, customPairingCode) => {
|
|
586
|
+
const pairingCode = customPairingCode ?? bytesToCrockford(randomBytes(5));
|
|
587
|
+
if (customPairingCode && customPairingCode?.length !== 8) {
|
|
588
|
+
throw new Error('Custom pairing code must be exactly 8 chars');
|
|
589
|
+
}
|
|
590
|
+
authState.creds.pairingCode = pairingCode;
|
|
588
591
|
authState.creds.me = {
|
|
589
592
|
id: jidEncode(phoneNumber, 's.whatsapp.net'),
|
|
590
593
|
name: '~'
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
ev.emit('creds.update', authState.creds)
|
|
594
|
-
|
|
594
|
+
};
|
|
595
|
+
ev.emit('creds.update', authState.creds);
|
|
595
596
|
await sendNode({
|
|
596
597
|
tag: 'iq',
|
|
597
598
|
attrs: {
|
|
@@ -600,52 +601,52 @@ export const makeSocket = (config) => {
|
|
|
600
601
|
id: generateMessageTag(),
|
|
601
602
|
xmlns: 'md'
|
|
602
603
|
},
|
|
603
|
-
content: [
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
content: [{
|
|
611
|
-
tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
|
|
612
|
-
attrs: {},
|
|
613
|
-
content: await generatePairingKey()
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
tag: 'companion_server_auth_key_pub',
|
|
617
|
-
attrs: {},
|
|
618
|
-
content: authState.creds.noiseKey.public
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
tag: 'companion_platform_id',
|
|
622
|
-
attrs: {},
|
|
623
|
-
content: getPlatformId(browser[1])
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
tag: 'companion_platform_display',
|
|
627
|
-
attrs: {},
|
|
628
|
-
content: `${browser[1]} (${browser[0]})`
|
|
604
|
+
content: [
|
|
605
|
+
{
|
|
606
|
+
tag: 'link_code_companion_reg',
|
|
607
|
+
attrs: {
|
|
608
|
+
jid: authState.creds.me.id,
|
|
609
|
+
stage: 'companion_hello',
|
|
610
|
+
should_show_push_notification: 'true'
|
|
629
611
|
},
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
612
|
+
content: [
|
|
613
|
+
{
|
|
614
|
+
tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
|
|
615
|
+
attrs: {},
|
|
616
|
+
content: await generatePairingKey()
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
tag: 'companion_server_auth_key_pub',
|
|
620
|
+
attrs: {},
|
|
621
|
+
content: authState.creds.noiseKey.public
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
tag: 'companion_platform_id',
|
|
625
|
+
attrs: {},
|
|
626
|
+
content: getPlatformId(browser[1])
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
tag: 'companion_platform_display',
|
|
630
|
+
attrs: {},
|
|
631
|
+
content: `${browser[1]} (${browser[0]})`
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
tag: 'link_code_pairing_nonce',
|
|
635
|
+
attrs: {},
|
|
636
|
+
content: '0'
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
]
|
|
641
|
+
});
|
|
642
|
+
return authState.creds.pairingCode;
|
|
643
|
+
};
|
|
642
644
|
async function generatePairingKey() {
|
|
643
|
-
const salt = randomBytes(32)
|
|
644
|
-
const randomIv = randomBytes(16)
|
|
645
|
-
const key = await derivePairingCodeKey(authState.creds.pairingCode, salt)
|
|
646
|
-
const ciphered = aesEncryptCTR(authState.creds.pairingEphemeralKeyPair.public, key, randomIv)
|
|
647
|
-
|
|
648
|
-
return Buffer.concat([salt, randomIv, ciphered])
|
|
645
|
+
const salt = randomBytes(32);
|
|
646
|
+
const randomIv = randomBytes(16);
|
|
647
|
+
const key = await derivePairingCodeKey(authState.creds.pairingCode, salt);
|
|
648
|
+
const ciphered = aesEncryptCTR(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
|
|
649
|
+
return Buffer.concat([salt, randomIv, ciphered]);
|
|
649
650
|
}
|
|
650
651
|
const sendWAMBuffer = (wamBuffer) => {
|
|
651
652
|
return query({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Store } from 'cache-manager'
|
|
2
|
+
import { AuthenticationCreds } from '../Types'
|
|
3
|
+
|
|
4
|
+
export declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{
|
|
5
|
+
clearState: () => Promise<void>
|
|
6
|
+
saveCreds: () => Promise<void>
|
|
7
|
+
state: {
|
|
8
|
+
creds: AuthenticationCreds
|
|
9
|
+
keys: {
|
|
10
|
+
get: (type: string, ids: string[]) => Promise<{}>
|
|
11
|
+
set: (data: any) => Promise<void>
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type KeyedDB from '@adiwajshing/keyed-db'
|
|
2
|
+
import type { Comparable } from '@adiwajshing/keyed-db/lib/Types'
|
|
3
|
+
import type { Logger } from 'pino'
|
|
4
|
+
import { proto } from '../../WAProto'
|
|
5
|
+
import type makeMDSocket from '../Socket'
|
|
6
|
+
import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types'
|
|
7
|
+
import { Label } from '../Types/Label'
|
|
8
|
+
import { LabelAssociation } from '../Types/LabelAssociation'
|
|
9
|
+
import { ObjectRepository } from './object-repository'
|
|
10
|
+
|
|
11
|
+
type WASocket = ReturnType<typeof makeMDSocket>
|
|
12
|
+
|
|
13
|
+
export declare const waChatKey: (pin: boolean) => {
|
|
14
|
+
key: (c: Chat) => string
|
|
15
|
+
compare: (k1: string, k2: string) => number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare const waMessageID: (m: WAMessage) => string
|
|
19
|
+
|
|
20
|
+
export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>
|
|
21
|
+
|
|
22
|
+
export type BaileysInMemoryStoreConfig = {
|
|
23
|
+
chatKey?: Comparable<Chat, string>
|
|
24
|
+
labelAssociationKey?: Comparable<LabelAssociation, string>
|
|
25
|
+
logger?: Logger
|
|
26
|
+
socket?: WASocket
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare const makeInMemoryStore: (config: BaileysInMemoryStoreConfig) => {
|
|
30
|
+
chats: KeyedDB<Chat, string>
|
|
31
|
+
contacts: {
|
|
32
|
+
[_: string]: Contact
|
|
33
|
+
}
|
|
34
|
+
messages: {
|
|
35
|
+
[_: string]: {
|
|
36
|
+
array: proto.IWebMessageInfo[]
|
|
37
|
+
get: (id: string) => proto.IWebMessageInfo | undefined
|
|
38
|
+
upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void
|
|
39
|
+
update: (item: proto.IWebMessageInfo) => boolean
|
|
40
|
+
remove: (item: proto.IWebMessageInfo) => boolean
|
|
41
|
+
updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean
|
|
42
|
+
clear: () => void
|
|
43
|
+
filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void
|
|
44
|
+
toJSON: () => proto.IWebMessageInfo[]
|
|
45
|
+
fromJSON: (newItems: proto.IWebMessageInfo[]) => void
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
groupMetadata: {
|
|
49
|
+
[_: string]: GroupMetadata
|
|
50
|
+
}
|
|
51
|
+
state: ConnectionState
|
|
52
|
+
presences: {
|
|
53
|
+
[id: string]: {
|
|
54
|
+
[participant: string]: PresenceData
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
labels: ObjectRepository<Label>
|
|
58
|
+
labelAssociations: KeyedDB<LabelAssociation, string>
|
|
59
|
+
bind: (ev: BaileysEventEmitter) => void
|
|
60
|
+
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
61
|
+
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<proto.IWebMessageInfo[]>
|
|
62
|
+
/**
|
|
63
|
+
* Get all available labels for profile
|
|
64
|
+
*
|
|
65
|
+
* Keep in mind that the list is formed from predefined tags and tags
|
|
66
|
+
* that were "caught" during their editing.
|
|
67
|
+
*/
|
|
68
|
+
getLabels: () => ObjectRepository<Label>
|
|
69
|
+
/**
|
|
70
|
+
* Get labels for chat
|
|
71
|
+
*
|
|
72
|
+
* @returns Label IDs
|
|
73
|
+
**/
|
|
74
|
+
getChatLabels: (chatId: string) => LabelAssociation[]
|
|
75
|
+
/**
|
|
76
|
+
* Get labels for message
|
|
77
|
+
*
|
|
78
|
+
* @returns Label IDs
|
|
79
|
+
**/
|
|
80
|
+
getMessageLabels: (messageId: string) => string[]
|
|
81
|
+
loadMessage: (jid: string, id: string) => Promise<proto.IWebMessageInfo | undefined>
|
|
82
|
+
mostRecentMessage: (jid: string) => Promise<proto.IWebMessageInfo>
|
|
83
|
+
fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>
|
|
84
|
+
fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>
|
|
85
|
+
fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>
|
|
86
|
+
toJSON: () => {
|
|
87
|
+
chats: KeyedDB<Chat, string>
|
|
88
|
+
contacts: {
|
|
89
|
+
[_: string]: Contact
|
|
90
|
+
}
|
|
91
|
+
messages: {
|
|
92
|
+
[_: string]: {
|
|
93
|
+
array: proto.IWebMessageInfo[]
|
|
94
|
+
get: (id: string) => proto.IWebMessageInfo | undefined
|
|
95
|
+
upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void
|
|
96
|
+
update: (item: proto.IWebMessageInfo) => boolean
|
|
97
|
+
remove: (item: proto.IWebMessageInfo) => boolean
|
|
98
|
+
updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean
|
|
99
|
+
clear: () => void
|
|
100
|
+
filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void
|
|
101
|
+
toJSON: () => proto.IWebMessageInfo[]
|
|
102
|
+
fromJSON: (newItems: proto.IWebMessageInfo[]) => void
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
labels: ObjectRepository<Label>
|
|
106
|
+
labelAssociations: KeyedDB<LabelAssociation, string>
|
|
107
|
+
}
|
|
108
|
+
fromJSON: (json: {
|
|
109
|
+
chats: Chat[]
|
|
110
|
+
contacts: {
|
|
111
|
+
[id: string]: Contact
|
|
112
|
+
}
|
|
113
|
+
messages: {
|
|
114
|
+
[id: string]: proto.IWebMessageInfo[]
|
|
115
|
+
}
|
|
116
|
+
labels: {
|
|
117
|
+
[labelId: string]: Label
|
|
118
|
+
}
|
|
119
|
+
labelAssociations: LabelAssociation[]
|
|
120
|
+
}) => void
|
|
121
|
+
writeToFile: (path: string) => void
|
|
122
|
+
readFromFile: (path: string) => void
|
|
123
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
|
|
2
|
+
array: T[]
|
|
3
|
+
get: (id: string) => T | undefined
|
|
4
|
+
upsert: (item: T, mode: 'append' | 'prepend') => void
|
|
5
|
+
update: (item: T) => boolean
|
|
6
|
+
remove: (item: T) => boolean
|
|
7
|
+
updateAssign: (id: string, update: Partial<T>) => boolean
|
|
8
|
+
clear: () => void
|
|
9
|
+
filter: (contain: (item: T) => boolean) => void
|
|
10
|
+
toJSON: () => T[]
|
|
11
|
+
fromJSON: (newItems: T[]) => void
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class ObjectRepository<T extends object> {
|
|
2
|
+
readonly entityMap: Map<string, T>
|
|
3
|
+
constructor(entities?: Record<string, T>)
|
|
4
|
+
findById(id: string): T | undefined
|
|
5
|
+
findAll(): T[]
|
|
6
|
+
upsertById(id: string, entity: T): Map<string, T>
|
|
7
|
+
deleteById(id: string): boolean
|
|
8
|
+
count(): number
|
|
9
|
+
toJSON(): T[]
|
|
10
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { Contact } from './Contact.js';
|
|
3
|
+
import type { MinimalMessage } from './Message.js';
|
|
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 LIDMapping = {
|
|
23
|
+
pn: string;
|
|
24
|
+
lid: string;
|
|
25
|
+
};
|
|
26
|
+
export type LTHashState = {
|
|
27
|
+
version: number;
|
|
28
|
+
hash: Buffer;
|
|
29
|
+
indexValueMap: {
|
|
30
|
+
[indexMacBase64: string]: {
|
|
31
|
+
valueMac: Uint8Array | Buffer;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type SignalCreds = {
|
|
36
|
+
readonly signedIdentityKey: KeyPair;
|
|
37
|
+
readonly signedPreKey: SignedKeyPair;
|
|
38
|
+
readonly registrationId: number;
|
|
39
|
+
};
|
|
40
|
+
export type AccountSettings = {
|
|
41
|
+
/** unarchive chats when a new message is received */
|
|
42
|
+
unarchiveChats: boolean;
|
|
43
|
+
/** the default mode to start new conversations with */
|
|
44
|
+
defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
|
|
45
|
+
};
|
|
46
|
+
export type AuthenticationCreds = SignalCreds & {
|
|
47
|
+
readonly noiseKey: KeyPair;
|
|
48
|
+
readonly pairingEphemeralKeyPair: KeyPair;
|
|
49
|
+
advSecretKey: string;
|
|
50
|
+
me?: Contact;
|
|
51
|
+
account?: proto.IADVSignedDeviceIdentity;
|
|
52
|
+
signalIdentities?: SignalIdentity[];
|
|
53
|
+
myAppStateKeyId?: string;
|
|
54
|
+
firstUnuploadedPreKeyId: number;
|
|
55
|
+
nextPreKeyId: number;
|
|
56
|
+
lastAccountSyncTimestamp?: number;
|
|
57
|
+
platform?: string;
|
|
58
|
+
processedHistoryMessages: MinimalMessage[];
|
|
59
|
+
/** number of times history & app state has been synced */
|
|
60
|
+
accountSyncCounter: number;
|
|
61
|
+
accountSettings: AccountSettings;
|
|
62
|
+
registered: boolean;
|
|
63
|
+
pairingCode: string | undefined;
|
|
64
|
+
lastPropHash: string | undefined;
|
|
65
|
+
routingInfo: Buffer | undefined;
|
|
66
|
+
additionalData?: any | undefined;
|
|
67
|
+
};
|
|
68
|
+
export type SignalDataTypeMap = {
|
|
69
|
+
'pre-key': KeyPair;
|
|
70
|
+
session: Uint8Array;
|
|
71
|
+
'sender-key': Uint8Array;
|
|
72
|
+
'sender-key-memory': {
|
|
73
|
+
[jid: string]: boolean;
|
|
74
|
+
};
|
|
75
|
+
'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
|
|
76
|
+
'app-state-sync-version': LTHashState;
|
|
77
|
+
'lid-mapping': string;
|
|
78
|
+
'device-list': string[];
|
|
79
|
+
tctoken: {
|
|
80
|
+
token: Buffer;
|
|
81
|
+
timestamp?: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type SignalDataSet = {
|
|
85
|
+
[T in keyof SignalDataTypeMap]?: {
|
|
86
|
+
[id: string]: SignalDataTypeMap[T] | null;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
type Awaitable<T> = T | Promise<T>;
|
|
90
|
+
export type SignalKeyStore = {
|
|
91
|
+
get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
|
|
92
|
+
[id: string]: SignalDataTypeMap[T];
|
|
93
|
+
}>;
|
|
94
|
+
set(data: SignalDataSet): Awaitable<void>;
|
|
95
|
+
/** clear all the data in the store */
|
|
96
|
+
clear?(): Awaitable<void>;
|
|
97
|
+
};
|
|
98
|
+
export type SignalKeyStoreWithTransaction = SignalKeyStore & {
|
|
99
|
+
isInTransaction: () => boolean;
|
|
100
|
+
transaction<T>(exec: () => Promise<T>, key: string): Promise<T>;
|
|
101
|
+
};
|
|
102
|
+
export type TransactionCapabilityOptions = {
|
|
103
|
+
maxCommitRetries: number;
|
|
104
|
+
delayBetweenTriesMs: number;
|
|
105
|
+
};
|
|
106
|
+
export type SignalAuthState = {
|
|
107
|
+
creds: SignalCreds;
|
|
108
|
+
keys: SignalKeyStore | SignalKeyStoreWithTransaction;
|
|
109
|
+
};
|
|
110
|
+
export type AuthenticationState = {
|
|
111
|
+
creds: AuthenticationCreds;
|
|
112
|
+
keys: SignalKeyStore;
|
|
113
|
+
};
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=Auth.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { proto } from '../../WAProto';
|
|
2
|
+
export type DayOfWeekBussines = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat';
|
|
3
|
+
export type HoursDay = {
|
|
4
|
+
day: DayOfWeekBussines;
|
|
5
|
+
mode: 'specific_hours';
|
|
6
|
+
openTimeInMinutes: string;
|
|
7
|
+
closeTimeInMinutes: string;
|
|
8
|
+
} | {
|
|
9
|
+
day: DayOfWeekBussines;
|
|
10
|
+
mode: 'open_24h' | 'appointment_only';
|
|
11
|
+
};
|
|
12
|
+
export type UpdateBussinesProfileProps = {
|
|
13
|
+
address?: string;
|
|
14
|
+
websites?: string[];
|
|
15
|
+
email?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
hours?: {
|
|
18
|
+
timezone: string;
|
|
19
|
+
days: HoursDay[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type QuickReplyAction = proto.SyncActionValue.IQuickReplyAction & {
|
|
23
|
+
timestamp?: string;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=Bussines.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
14
|
+
//# sourceMappingURL=Call.d.ts.map
|