xhyphersockets 1.4.3 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/LICENSE +1 -1
  2. package/README.MD +1295 -0
  3. package/WAProto/p.html +1 -0
  4. package/lib/Defaults/index.js +47 -35
  5. package/lib/Defaults/wileys-version.json +3 -0
  6. package/lib/Socket/chats.js +132 -125
  7. package/lib/Socket/messages-recv.js +1 -1
  8. package/lib/Socket/messages-send.js +1 -32
  9. package/lib/Socket/newsletter.js +71 -124
  10. package/lib/Socket/socket.js +1 -1
  11. package/lib/Store/make-in-memory-store.js +1 -1
  12. package/lib/Types/Newsletter.js +18 -38
  13. package/lib/Utils/browser-utils.js +35 -0
  14. package/lib/Utils/event-buffer.js +2 -2
  15. package/lib/Utils/generics.js +47 -8
  16. package/lib/Utils/index.js +3 -4
  17. package/lib/Utils/message-retry-manager.js +128 -0
  18. package/lib/Utils/messages-media.js +37 -45
  19. package/lib/Utils/messages.js +19 -0
  20. package/lib/Utils/process-message.js +19 -0
  21. package/lib/Utils/use-multi-file-auth-state.js +1 -1
  22. package/lib/Utils/validate-connection.js +77 -21
  23. package/lib/Utils/{baileys-event-stream.js → wileys-event-stream.js} +1 -1
  24. package/lib/WABinary/jid-utils.js +3 -1
  25. package/lib/index.js +12 -18
  26. package/package.json +28 -22
  27. package/README.md +0 -252
  28. package/WAProto/index.d.ts +0 -55057
  29. package/WAProto/index.ts.ts +0 -53473
  30. package/lib/Defaults/baileys-version.json +0 -3
  31. package/lib/Defaults/index.d.ts +0 -51
  32. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  33. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  34. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  35. package/lib/Signal/Group/index.d.ts +0 -11
  36. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  37. package/lib/Signal/Group/queue-job.d.ts +0 -1
  38. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  39. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  40. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  41. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  42. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  43. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  44. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  45. package/lib/Signal/libsignal.d.ts +0 -3
  46. package/lib/Socket/Client/index.d.ts +0 -2
  47. package/lib/Socket/Client/types.d.ts +0 -16
  48. package/lib/Socket/Client/websocket.d.ts +0 -13
  49. package/lib/Socket/RHandler.d.ts +0 -416
  50. package/lib/Socket/RHandler.js +0 -530
  51. package/lib/Socket/business.d.ts +0 -172
  52. package/lib/Socket/chats.d.ts +0 -94
  53. package/lib/Socket/groups.d.ts +0 -124
  54. package/lib/Socket/index.d.ts +0 -172
  55. package/lib/Socket/messages-recv.d.ts +0 -161
  56. package/lib/Socket/messages-send.d.ts +0 -152
  57. package/lib/Socket/newsletter.d.ts +0 -136
  58. package/lib/Socket/socket.d.ts +0 -43
  59. package/lib/Socket/usync.d.ts +0 -36
  60. package/lib/Store/index.d.ts +0 -2
  61. package/lib/Store/make-in-memory-store.d.ts +0 -118
  62. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  63. package/lib/Store/object-repository.d.ts +0 -10
  64. package/lib/Types/Auth.d.ts +0 -103
  65. package/lib/Types/Call.d.ts +0 -13
  66. package/lib/Types/Chat.d.ts +0 -109
  67. package/lib/Types/Contact.d.ts +0 -23
  68. package/lib/Types/Events.d.ts +0 -199
  69. package/lib/Types/GroupMetadata.d.ts +0 -64
  70. package/lib/Types/Label.d.ts +0 -35
  71. package/lib/Types/LabelAssociation.d.ts +0 -29
  72. package/lib/Types/Message.d.ts +0 -402
  73. package/lib/Types/Newsletter.d.ts +0 -103
  74. package/lib/Types/Product.d.ts +0 -78
  75. package/lib/Types/Signal.d.ts +0 -57
  76. package/lib/Types/Socket.d.ts +0 -119
  77. package/lib/Types/State.d.ts +0 -27
  78. package/lib/Types/USync.d.ts +0 -25
  79. package/lib/Types/index.d.ts +0 -64
  80. package/lib/Utils/audioToBuffer.js +0 -29
  81. package/lib/Utils/auth-utils.d.ts +0 -18
  82. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  83. package/lib/Utils/business.d.ts +0 -22
  84. package/lib/Utils/chat-utils.d.ts +0 -70
  85. package/lib/Utils/crypto.d.ts +0 -40
  86. package/lib/Utils/decode-wa-message.d.ts +0 -35
  87. package/lib/Utils/event-buffer.d.ts +0 -35
  88. package/lib/Utils/generics.d.ts +0 -89
  89. package/lib/Utils/history.d.ts +0 -19
  90. package/lib/Utils/index.d.ts +0 -19
  91. package/lib/Utils/link-preview.d.ts +0 -21
  92. package/lib/Utils/logger.d.ts +0 -11
  93. package/lib/Utils/lt-hash.d.ts +0 -12
  94. package/lib/Utils/make-mutex.d.ts +0 -7
  95. package/lib/Utils/messages-media.d.ts +0 -124
  96. package/lib/Utils/messages.d.ts +0 -75
  97. package/lib/Utils/noise-handler.d.ts +0 -19
  98. package/lib/Utils/process-message.d.ts +0 -42
  99. package/lib/Utils/signal.d.ts +0 -33
  100. package/lib/Utils/streamToBuffer.js +0 -15
  101. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  102. package/lib/Utils/validate-connection.d.ts +0 -10
  103. package/lib/WABinary/constants.d.ts +0 -27
  104. package/lib/WABinary/decode.d.ts +0 -6
  105. package/lib/WABinary/encode.d.ts +0 -2
  106. package/lib/WABinary/generic-utils.d.ts +0 -14
  107. package/lib/WABinary/index.d.ts +0 -5
  108. package/lib/WABinary/jid-utils.d.ts +0 -36
  109. package/lib/WABinary/jid-utils.js.bak +0 -83
  110. package/lib/WABinary/types.d.ts +0 -18
  111. package/lib/WAM/BinaryInfo.d.ts +0 -8
  112. package/lib/WAM/constants.d.ts +0 -38
  113. package/lib/WAM/encode.d.ts +0 -2
  114. package/lib/WAM/index.d.ts +0 -3
  115. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  116. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  117. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  118. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  119. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  120. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  121. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  122. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  123. package/lib/WAUSync/USyncUser.d.ts +0 -12
  124. package/lib/WAUSync/index.d.ts +0 -3
  125. package/lib/index.d.ts +0 -16
@@ -1,11 +0,0 @@
1
- export interface ILogger {
2
- level: string;
3
- child(obj: Record<string, unknown>): ILogger;
4
- trace(obj: unknown, msg?: string): any;
5
- debug(obj: unknown, msg?: string): any;
6
- info(obj: unknown, msg?: string): any;
7
- warn(obj: unknown, msg?: string): any;
8
- error(obj: unknown, msg?: string): any;
9
- }
10
- declare const _default: import("pino").Logger<never, boolean>;
11
- export default _default;
@@ -1,12 +0,0 @@
1
- declare class d {
2
- salt: string;
3
- constructor(e: string);
4
- add(e: any, t: any): any;
5
- subtract(e: any, t: any): any;
6
- subtractThenAdd(e: any, t: any, r: any): any;
7
- _addSingle(e: any, t: any): Promise<ArrayBuffer>;
8
- _subtractSingle(e: any, t: any): Promise<ArrayBuffer>;
9
- performPointwiseWithOverflow(e: any, t: any, r: any): ArrayBuffer;
10
- }
11
- export declare const LT_HASH_ANTI_TAMPERING: d;
12
- export {};
@@ -1,7 +0,0 @@
1
- export declare const makeMutex: () => {
2
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
3
- };
4
- export type Mutex = ReturnType<typeof makeMutex>;
5
- export declare const makeKeyedMutex: () => {
6
- mutex<T>(key: string, task: () => Promise<T> | T): Promise<T>;
7
- };
@@ -1,124 +0,0 @@
1
- import { Boom } from '@hapi/boom';
2
- import { AxiosRequestConfig } from 'axios';
3
- import { Readable, Transform } from 'stream';
4
- import { URL } from 'url';
5
- import { proto } from '../../WAProto';
6
- import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
7
- import { BinaryNode } from '../WABinary';
8
- import { ILogger } from './logger';
9
- export declare const hkdfInfoKey: (type: MediaType) => string;
10
- /** generates all the keys required to encrypt/decrypt & sign a media message */
11
- export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): Promise<MediaDecryptionKeyInfo>;
12
- export declare function uploadFile(buffer: Buffer, logger?: ILogger): Promise<string>;
13
- export declare function vid2jpg(videoUrl: string): Promise<string>;
14
- /**
15
- * Originally written by Techwiz (https://github.com/techwiz37)
16
- * Modified for customization and improvements
17
- */
18
- export declare const extractVideoThumb: (videoPath: string) => Promise<Buffer<ArrayBufferLike>>;
19
- export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
20
- buffer: Buffer<ArrayBufferLike>;
21
- original: {
22
- width: number;
23
- height: number;
24
- };
25
- }>;
26
- export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
27
- export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
28
- img: Buffer<ArrayBufferLike>;
29
- }>;
30
- /** gets the SHA256 of the given media message */
31
- export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
32
- export declare function getAudioDuration(buffer: Buffer | string | Readable): Promise<number | undefined>;
33
- /**
34
- referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
35
- */
36
- export declare function getAudioWaveform(
37
- buffer: Buffer | string | Readable,
38
- logger?: ILogger
39
- ): Promise<Uint8Array | undefined>;
40
-
41
- export declare const toReadable: (buffer: Buffer) => Readable;
42
- export declare const toBuffer: (stream: Readable) => Promise<Buffer<ArrayBuffer>>;
43
- export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
44
- readonly stream: Readable;
45
- readonly type: "buffer";
46
- } | {
47
- readonly stream: Readable;
48
- readonly type: "readable";
49
- } | {
50
- readonly stream: Readable;
51
- readonly type: "remote";
52
- } | {
53
- readonly stream: import("fs").ReadStream;
54
- readonly type: "file";
55
- }>;
56
- /** generates a thumbnail for a given media, if required */
57
- export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
58
- logger?: ILogger;
59
- }): Promise<{
60
- thumbnail: string | undefined;
61
- originalImageDimensions: {
62
- width: number;
63
- height: number;
64
- } | undefined;
65
- }>;
66
- export declare const getHttpStream: (url: string | URL, options?: AxiosRequestConfig & {
67
- isStream?: true;
68
- }) => Promise<Readable>;
69
- type EncryptedStreamOptions = {
70
- saveOriginalFileIfRequired?: boolean;
71
- logger?: ILogger;
72
- opts?: AxiosRequestConfig;
73
- };
74
- export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
75
- mediaKey: undefined;
76
- encWriteStream: Buffer<ArrayBuffer>;
77
- fileLength: number;
78
- fileSha256: Buffer<ArrayBufferLike>;
79
- fileEncSha256: undefined;
80
- bodyPath: string | undefined;
81
- didSaveToTmpPath: boolean;
82
- }>;
83
- export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
84
- mediaKey: Buffer<ArrayBufferLike>;
85
- encWriteStream: Readable;
86
- bodyPath: string | undefined;
87
- mac: Buffer<ArrayBuffer>;
88
- fileEncSha256: Buffer<ArrayBufferLike>;
89
- fileSha256: Buffer<ArrayBufferLike>;
90
- fileLength: number;
91
- didSaveToTmpPath: boolean;
92
- }>;
93
- export type MediaDownloadOptions = {
94
- startByte?: number;
95
- endByte?: number;
96
- options?: AxiosRequestConfig<any>;
97
- };
98
- export declare const getUrlFromDirectPath: (directPath: string) => string;
99
- export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
100
- /**
101
- * Decrypts and downloads an AES256-CBC encrypted file given the keys.
102
- * Assumes the SHA256 of the plaintext is appended to the end of the ciphertext
103
- * */
104
- export declare const downloadEncryptedContent: (downloadUrl: string, { cipherKey, iv }: MediaDecryptionKeyInfo, { startByte, endByte, options }?: MediaDownloadOptions) => Promise<Transform>;
105
- export declare function extensionForMediaMessage(message: WAMessageContent): string;
106
- export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logger, options }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>) => WAMediaUploadFunction;
107
- /**
108
- * Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
109
- */
110
- export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => Promise<BinaryNode>;
111
- export declare const decodeMediaRetryNode: (node: BinaryNode) => {
112
- key: import("../Types").WAMessageKey;
113
- media?: {
114
- ciphertext: Uint8Array;
115
- iv: Uint8Array;
116
- };
117
- error?: Boom;
118
- };
119
- export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
120
- ciphertext: Uint8Array;
121
- iv: Uint8Array;
122
- }, mediaKey: Uint8Array, msgId: string) => Promise<proto.MediaRetryNotification>;
123
- export declare const getStatusCodeForMediaRetry: (code: number) => any;
124
- export {};
@@ -1,75 +0,0 @@
1
- import { type Transform } from 'stream';
2
- import { proto } from '../../WAProto';
3
- import { ILogger } from './logger';
4
- import { AnyMediaMessageContent, AnyMessageContent, MediaGenerationOptions, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAProto } from '../Types';
5
- import { MediaDownloadOptions } from './messages-media';
6
- /**
7
- * Uses a regex to test whether the string contains a URL, and returns the URL if it does.
8
- * @param text eg. hello https://google.com
9
- * @returns the URL, eg. https://google.com
10
- */
11
- export declare const extractUrlFromText: (text: string) => string | undefined;
12
- export declare const generateLinkPreviewIfRequired: (text: string, getUrlInfo: MessageGenerationOptions["getUrlInfo"], logger: MessageGenerationOptions["logger"]) => Promise<import("../Types").WAUrlInfo | undefined>;
13
- export declare const prepareWAMessageMedia: (message: AnyMediaMessageContent, options: MediaGenerationOptions) => Promise<proto.Message>;
14
- export declare const prepareDisappearingMessageSettingContent: (ephemeralExpiration?: number) => proto.Message;
15
- /**
16
- * Generate forwarded message content like WA does
17
- * @param message the message to forward
18
- * @param options.forceForward will show the message as forwarded even if it is from you
19
- */
20
- export declare const generateForwardMessageContent: (message: WAMessage, forceForward?: boolean) => proto.IMessage;
21
- export declare const generateWAMessageContent: (message: AnyMessageContent, options: MessageContentGenerationOptions) => Promise<proto.Message>;
22
- export declare const generateWAMessageFromContent: (jid: string, message: WAMessageContent, options: MessageGenerationOptionsFromContent) => proto.WebMessageInfo;
23
- export declare const generateWAMessage: (jid: string, content: AnyMessageContent, options: MessageGenerationOptions) => Promise<proto.WebMessageInfo>;
24
- /** Get the key to access the true type of content */
25
- export declare const getContentType: (content: WAProto.IMessage | undefined) => keyof proto.IMessage | undefined;
26
- /**
27
- * Normalizes ephemeral, view once messages to regular message content
28
- * Eg. image messages in ephemeral messages, in view once messages etc.
29
- * @param content
30
- * @returns
31
- */
32
- export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined;
33
- /**
34
- * Extract the true message content from a message
35
- * Eg. extracts the inner message from a disappearing message/view once message
36
- */
37
- export declare const extractMessageContent: (content: WAMessageContent | undefined | null) => WAMessageContent | undefined;
38
- /**
39
- * Returns the device predicted by message ID
40
- */
41
- export declare const getDevice: (id: string) => "web" | "unknown" | "android" | "ios" | "desktop";
42
- /** Upserts a receipt in the message */
43
- export declare const updateMessageWithReceipt: (msg: Pick<WAMessage, "userReceipt">, receipt: MessageUserReceipt) => void;
44
- /** Update the message with a new reaction */
45
- export declare const updateMessageWithReaction: (msg: Pick<WAMessage, "reactions">, reaction: proto.IReaction) => void;
46
- /** Update the message with a new poll update */
47
- export declare const updateMessageWithPollUpdate: (msg: Pick<WAMessage, "pollUpdates">, update: proto.IPollUpdate) => void;
48
- type VoteAggregation = {
49
- name: string;
50
- voters: string[];
51
- };
52
- /**
53
- * Aggregates all poll updates in a poll.
54
- * @param msg the poll creation message
55
- * @param meId your jid
56
- * @returns A list of options & their voters
57
- */
58
- export declare function getAggregateVotesInPollMessage({ message, pollUpdates }: Pick<WAMessage, 'pollUpdates' | 'message'>, meId?: string): VoteAggregation[];
59
- /** Given a list of message keys, aggregates them by chat & sender. Useful for sending read receipts in bulk */
60
- export declare const aggregateMessageKeysNotFromMe: (keys: proto.IMessageKey[]) => {
61
- jid: string;
62
- participant: string | undefined;
63
- messageIds: string[];
64
- }[];
65
- type DownloadMediaMessageContext = {
66
- reuploadRequest: (msg: WAMessage) => Promise<WAMessage>;
67
- logger: ILogger;
68
- };
69
- /**
70
- * Downloads the given message. Throws an error if it's not a media message
71
- */
72
- export declare const downloadMediaMessage: <Type extends "buffer" | "stream">(message: WAMessage, type: Type, options: MediaDownloadOptions, ctx?: DownloadMediaMessageContext) => Promise<Type extends "buffer" ? Buffer<ArrayBufferLike> : Transform>;
73
- /** Checks whether the given message is a media message; if it is returns the inner content */
74
- export declare const assertMediaContent: (content: proto.IMessage | null | undefined) => proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
75
- export {};
@@ -1,19 +0,0 @@
1
- import { ILogger } from './logger';
2
- import { proto } from '../../WAProto';
3
- import { KeyPair } from '../Types';
4
- import { BinaryNode } from '../WABinary';
5
- export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }: {
6
- keyPair: KeyPair;
7
- NOISE_HEADER: Uint8Array;
8
- logger: ILogger;
9
- routingInfo?: Buffer | undefined;
10
- }) => {
11
- encrypt: (plaintext: Uint8Array) => Buffer<ArrayBuffer>;
12
- decrypt: (ciphertext: Uint8Array) => Buffer<ArrayBuffer>;
13
- authenticate: (data: Uint8Array) => void;
14
- mixIntoKey: (data: Uint8Array) => Promise<void>;
15
- finishInit: () => Promise<void>;
16
- processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => Promise<Buffer<ArrayBuffer>>;
17
- encodeFrame: (data: Buffer | Uint8Array) => Buffer<ArrayBuffer>;
18
- decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => Promise<void>;
19
- };
@@ -1,42 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import { proto } from '../../WAProto';
3
- import { AuthenticationCreds, BaileysEventEmitter, CacheStore, SignalKeyStoreWithTransaction, SocketConfig } from '../Types';
4
- import { ILogger } from './logger';
5
- type ProcessMessageContext = {
6
- shouldProcessHistoryMsg: boolean;
7
- placeholderResendCache?: CacheStore;
8
- creds: AuthenticationCreds;
9
- keyStore: SignalKeyStoreWithTransaction;
10
- ev: BaileysEventEmitter;
11
- getMessage: SocketConfig['getMessage'];
12
- logger?: ILogger;
13
- options: AxiosRequestConfig<{}>;
14
- };
15
- /** Cleans a received message to further processing */
16
- export declare const cleanMessage: (message: proto.IWebMessageInfo, meId: string) => void;
17
- export declare const isRealMessage: (message: proto.IWebMessageInfo, meId: string) => boolean | undefined;
18
- export declare const shouldIncrementChatUnread: (message: proto.IWebMessageInfo) => boolean;
19
- /**
20
- * Get the ID of the chat from the given key.
21
- * Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
22
- */
23
- export declare const getChatId: ({ remoteJid, participant, fromMe }: proto.IMessageKey) => string;
24
- type PollContext = {
25
- /** normalised jid of the person that created the poll */
26
- pollCreatorJid: string;
27
- /** ID of the poll creation message */
28
- pollMsgId: string;
29
- /** poll creation message enc key */
30
- pollEncKey: Uint8Array;
31
- /** jid of the person that voted */
32
- voterJid: string;
33
- };
34
- /**
35
- * Decrypt a poll vote
36
- * @param vote encrypted vote
37
- * @param ctx additional info about the poll required for decryption
38
- * @returns list of SHA256 options
39
- */
40
- export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid, }: PollContext): proto.Message.PollVoteMessage;
41
- declare const processMessage: (message: proto.IWebMessageInfo, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, keyStore, logger, options, getMessage }: ProcessMessageContext) => Promise<void>;
42
- export default processMessage;
@@ -1,33 +0,0 @@
1
- import { SignalRepository } from '../Types';
2
- import { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth';
3
- import { BinaryNode, JidWithDevice } from '../WABinary';
4
- import { USyncQueryResultList } from '../WAUSync';
5
- export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
6
- export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
7
- [id: string]: KeyPair;
8
- }>;
9
- export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: number) => {
10
- newPreKeys: {
11
- [id: number]: KeyPair;
12
- };
13
- lastPreKeyId: number;
14
- preKeysRange: readonly [number, number];
15
- };
16
- export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
17
- export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
18
- export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepository) => Promise<void>;
19
- export declare const extractDeviceJids: (result: USyncQueryResultList[], myJid: string, excludeZeroDevices: boolean) => JidWithDevice[];
20
- /**
21
- * get the next N keys for upload or processing
22
- * @param count number of pre-keys to get or generate
23
- */
24
- export declare const getNextPreKeys: ({ creds, keys }: AuthenticationState, count: number) => Promise<{
25
- update: Partial<AuthenticationCreds>;
26
- preKeys: {
27
- [id: string]: KeyPair;
28
- };
29
- }>;
30
- export declare const getNextPreKeysNode: (state: AuthenticationState, count: number) => Promise<{
31
- update: Partial<AuthenticationCreds>;
32
- node: BinaryNode;
33
- }>;
@@ -1,15 +0,0 @@
1
- const { Readable } = require("stream");
2
-
3
- /**
4
- * Mengonversi Node.js Readable Stream menjadi Buffer.
5
- * * @param {Readable} stream Aliran data yang dapat dibaca.
6
- * @returns {Promise<Buffer>} Promise yang diselesaikan dengan Buffer berisi semua data dari aliran.
7
- */
8
- async function streamToBuffer(stream) {
9
- const chunks = [];
10
- return new Promise((resolve, reject) => {
11
- stream.on('data', chunk => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
12
- stream.on('end', () => resolve(Buffer.concat(chunks)));
13
- stream.on('error', reject);
14
- });
15
- }
@@ -1,12 +0,0 @@
1
- import { AuthenticationState } from '../Types';
2
- /**
3
- * stores the full authentication state in a single folder.
4
- * Far more efficient than singlefileauthstate
5
- *
6
- * Again, I wouldn't endorse this for any production level use other than perhaps a bot.
7
- * Would recommend writing an auth state for use with a proper SQL or No-SQL DB
8
- * */
9
- export declare const useMultiFileAuthState: (folder: string) => Promise<{
10
- state: AuthenticationState;
11
- saveCreds: () => Promise<void>;
12
- }>;
@@ -1,10 +0,0 @@
1
- import { proto } from '../../WAProto';
2
- import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
3
- import { BinaryNode } from '../WABinary';
4
- export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
5
- export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
6
- export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, "advSecretKey" | "signedIdentityKey" | "signalIdentities">) => {
7
- creds: Partial<AuthenticationCreds>;
8
- reply: BinaryNode;
9
- };
10
- export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array<ArrayBufferLike>;
@@ -1,27 +0,0 @@
1
- export declare const TAGS: {
2
- LIST_EMPTY: number;
3
- DICTIONARY_0: number;
4
- DICTIONARY_1: number;
5
- DICTIONARY_2: number;
6
- DICTIONARY_3: number;
7
- INTEROP_JID: number;
8
- FB_JID: number;
9
- AD_JID: number;
10
- LIST_8: number;
11
- LIST_16: number;
12
- JID_PAIR: number;
13
- HEX_8: number;
14
- BINARY_8: number;
15
- BINARY_20: number;
16
- BINARY_32: number;
17
- NIBBLE_8: number;
18
- PACKED_MAX: number;
19
- };
20
- export declare const DOUBLE_BYTE_TOKENS: readonly [readonly ["read-self", "active", "fbns", "protocol", "reaction", "screen_width", "heartbeat", "deviceid", "2:47DEQpj8", "uploadfieldstat", "voip_settings", "retry", "priority", "longitude", "conflict", "false", "ig_professional", "replaced", "preaccept", "cover_photo", "uncompressed", "encopt", "ppic", "04", "passive", "status-revoke-drop", "keygen", "540", "offer", "rate", "opus", "latitude", "w:gp2", "ver", "4", "business_profile", "medium", "sender", "prev_v_id", "email", "website", "invited", "sign_credential", "05", "transport", "skey", "reason", "peer_abtest_bucket", "America/Sao_Paulo", "appid", "refresh", "100", "06", "404", "101", "104", "107", "102", "109", "103", "member_add_mode", "105", "transaction-id", "110", "106", "outgoing", "108", "111", "tokens", "followers", "ig_handle", "self_pid", "tue", "dec", "thu", "joinable", "peer_pid", "mon", "features", "wed", "peer_device_presence", "pn", "delete", "07", "fri", "audio_duration", "admin", "connected", "delta", "rcat", "disable", "collection", "08", "480", "sat", "phash", "all", "invite", "accept", "critical_unblock_low", "group_update", "signed_credential", "blinded_credential", "eph_setting", "net", "09", "background_location", "refresh_id", "Asia/Kolkata", "privacy_mode_ts", "account_sync", "voip_payload_type", "service_areas", "acs_public_key", "v_id", "0a", "fallback_class", "relay", "actual_actors", "metadata", "w:biz", "5", "connected-limit", "notice", "0b", "host_storage", "fb_page", "subject", "privatestats", "invis", "groupadd", "010", "note.m4r", "uuid", "0c", "8000", "sun", "372", "1020", "stage", "1200", "720", "canonical", "fb", "011", "video_duration", "0d", "1140", "superadmin", "012", "Opening.m4r", "keystore_attestation", "dleq_proof", "013", "timestamp", "ab_key", "w:sync:app:state", "0e", "vertical", "600", "p_v_id", "6", "likes", "014", "500", "1260", "creator", "0f", "rte", "destination", "group", "group_info", "syncd_anti_tampering_fatal_exception_enabled", "015", "dl_bw", "Asia/Jakarta", "vp8/h.264", "online", "1320", "fb:multiway", "10", "timeout", "016", "nse_retry", "urn:xmpp:whatsapp:dirty", "017", "a_v_id", "web_shops_chat_header_button_enabled", "nse_call", "inactive-upgrade", "none", "web", "groups", "2250", "mms_hot_content_timespan_in_seconds", "contact_blacklist", "nse_read", "suspended_group_deletion_notification", "binary_version", "018", "https://www.whatsapp.com/otp/copy/", "reg_push", "shops_hide_catalog_attachment_entrypoint", "server_sync", ".", "ephemeral_messages_allowed_values", "019", "mms_vcache_aggregation_enabled", "iphone", "America/Argentina/Buenos_Aires", "01a", "mms_vcard_autodownload_size_kb", "nse_ver", "shops_header_dropdown_menu_item", "dhash", "catalog_status", "communities_mvp_new_iqs_serverprop", "blocklist", "default", "11", "ephemeral_messages_enabled", "01b", "original_dimensions", "8", "mms4_media_retry_notification_encryption_enabled", "mms4_server_error_receipt_encryption_enabled", "original_image_url", "sync", "multiway", "420", "companion_enc_static", "shops_profile_drawer_entrypoint", "01c", "vcard_as_document_size_kb", "status_video_max_duration", "request_image_url", "01d", "regular_high", "s_t", "abt", "share_ext_min_preliminary_image_quality", "01e", "32", "syncd_key_rotation_enabled", "data_namespace", "md_downgrade_read_receipts2", "patch", "polltype", "ephemeral_messages_setting", "userrate", "15", "partial_pjpeg_bw_threshold", "played-self", "catalog_exists", "01f", "mute_v2"], readonly ["reject", "dirty", "announcement", "020", "13", "9", "status_video_max_bitrate", "fb:thrift_iq", "offline_batch", "022", "full", "ctwa_first_business_reply_logging", "h.264", "smax_id", "group_description_length", "https://www.whatsapp.com/otp/code", "status_image_max_edge", "smb_upsell_business_profile_enabled", "021", "web_upgrade_to_md_modal", "14", "023", "s_o", "smaller_video_thumbs_status_enabled", "media_max_autodownload", "960", "blocking_status", "peer_msg", "joinable_group_call_client_version", "group_call_video_maximization_enabled", "return_snapshot", "high", "America/Mexico_City", "entry_point_block_logging_enabled", "pop", "024", "1050", "16", "1380", "one_tap_calling_in_group_chat_size", "regular_low", "inline_joinable_education_enabled", "hq_image_max_edge", "locked", "America/Bogota", "smb_biztools_deeplink_enabled", "status_image_quality", "1088", "025", "payments_upi_intent_transaction_limit", "voip", "w:g2", "027", "md_pin_chat_enabled", "026", "multi_scan_pjpeg_download_enabled", "shops_product_grid", "transaction_id", "ctwa_context_enabled", "20", "fna", "hq_image_quality", "alt_jpeg_doc_detection_quality", "group_call_max_participants", "pkey", "America/Belem", "image_max_kbytes", "web_cart_v1_1_order_message_changes_enabled", "ctwa_context_enterprise_enabled", "urn:xmpp:whatsapp:account", "840", "Asia/Kuala_Lumpur", "max_participants", "video_remux_after_repair_enabled", "stella_addressbook_restriction_type", "660", "900", "780", "context_menu_ios13_enabled", "mute-state", "ref", "payments_request_messages", "029", "frskmsg", "vcard_max_size_kb", "sample_buffer_gif_player_enabled", "match_last_seen", "510", "4983", "video_max_bitrate", "028", "w:comms:chat", "17", "frequently_forwarded_max", "groups_privacy_blacklist", "Asia/Karachi", "02a", "web_download_document_thumb_mms_enabled", "02b", "hist_sync", "biz_block_reasons_version", "1024", "18", "web_is_direct_connection_for_plm_transparent", "view_once_write", "file_max_size", "paid_convo_id", "online_privacy_setting", "video_max_edge", "view_once_read", "enhanced_storage_management", "multi_scan_pjpeg_encoding_enabled", "ctwa_context_forward_enabled", "video_transcode_downgrade_enable", "template_doc_mime_types", "hq_image_bw_threshold", "30", "body", "u_aud_limit_sil_restarts_ctrl", "other", "participating", "w:biz:directory", "1110", "vp8", "4018", "meta", "doc_detection_image_max_edge", "image_quality", "1170", "02c", "smb_upsell_chat_banner_enabled", "key_expiry_time_second", "pid", "stella_interop_enabled", "19", "linked_device_max_count", "md_device_sync_enabled", "02d", "02e", "360", "enhanced_block_enabled", "ephemeral_icon_in_forwarding", "paid_convo_status", "gif_provider", "project_name", "server-error", "canonical_url_validation_enabled", "wallpapers_v2", "syncd_clear_chat_delete_chat_enabled", "medianotify", "02f", "shops_required_tos_version", "vote", "reset_skey_on_id_change", "030", "image_max_edge", "multicast_limit_global", "ul_bw", "21", "25", "5000", "poll", "570", "22", "031", "1280", "WhatsApp", "032", "bloks_shops_enabled", "50", "upload_host_switching_enabled", "web_ctwa_context_compose_enabled", "ptt_forwarded_features_enabled", "unblocked", "partial_pjpeg_enabled", "fbid:devices", "height", "ephemeral_group_query_ts", "group_join_permissions", "order", "033", "alt_jpeg_status_quality", "migrate", "popular-bank", "win_uwp_deprecation_killswitch_enabled", "web_download_status_thumb_mms_enabled", "blocking", "url_text", "035", "web_forwarding_limit_to_groups", "1600", "val", "1000", "syncd_msg_date_enabled", "bank-ref-id", "max_subject", "payments_web_enabled", "web_upload_document_thumb_mms_enabled", "size", "request", "ephemeral", "24", "receipt_agg", "ptt_remember_play_position", "sampling_weight", "enc_rekey", "mute_always", "037", "034", "23", "036", "action", "click_to_chat_qr_enabled", "width", "disabled", "038", "md_blocklist_v2", "played_self_enabled", "web_buttons_message_enabled", "flow_id", "clear", "450", "fbid:thread", "bloks_session_state", "America/Lima", "attachment_picker_refresh", "download_host_switching_enabled", "1792", "u_aud_limit_sil_restarts_test2", "custom_urls", "device_fanout", "optimistic_upload", "2000", "key_cipher_suite", "web_smb_upsell_in_biz_profile_enabled", "e", "039", "siri_post_status_shortcut", "pair-device", "lg", "lc", "stream_attribution_url", "model", "mspjpeg_phash_gen", "catalog_send_all", "new_multi_vcards_ui", "share_biz_vcard_enabled", "-", "clean", "200", "md_blocklist_v2_server", "03b", "03a", "web_md_migration_experience", "ptt_conversation_waveform", "u_aud_limit_sil_restarts_test1"], readonly ["64", "ptt_playback_speed_enabled", "web_product_list_message_enabled", "paid_convo_ts", "27", "manufacturer", "psp-routing", "grp_uii_cleanup", "ptt_draft_enabled", "03c", "business_initiated", "web_catalog_products_onoff", "web_upload_link_thumb_mms_enabled", "03e", "mediaretry", "35", "hfm_string_changes", "28", "America/Fortaleza", "max_keys", "md_mhfs_days", "streaming_upload_chunk_size", "5541", "040", "03d", "2675", "03f", "...", "512", "mute", "48", "041", "alt_jpeg_quality", "60", "042", "md_smb_quick_reply", "5183", "c", "1343", "40", "1230", "043", "044", "mms_cat_v1_forward_hot_override_enabled", "user_notice", "ptt_waveform_send", "047", "Asia/Calcutta", "250", "md_privacy_v2", "31", "29", "128", "md_messaging_enabled", "046", "crypto", "690", "045", "enc_iv", "75", "failure", "ptt_oot_playback", "AIzaSyDR5yfaG7OG8sMTUj8kfQEb8T9pN8BM6Lk", "w", "048", "2201", "web_large_files_ui", "Asia/Makassar", "812", "status_collapse_muted", "1334", "257", "2HP4dm", "049", "patches", "1290", "43cY6T", "America/Caracas", "web_sticker_maker", "campaign", "ptt_pausable_enabled", "33", "42", "attestation", "biz", "04b", "query_linked", "s", "125", "04a", "810", "availability", "1411", "responsiveness_v2_m1", "catalog_not_created", "34", "America/Santiago", "1465", "enc_p", "04d", "status_info", "04f", "key_version", "..", "04c", "04e", "md_group_notification", "1598", "1215", "web_cart_enabled", "37", "630", "1920", "2394", "-1", "vcard", "38", "elapsed", "36", "828", "peer", "pricing_category", "1245", "invalid", "stella_ios_enabled", "2687", "45", "1528", "39", "u_is_redial_audio_1104_ctrl", "1025", "1455", "58", "2524", "2603", "054", "bsp_system_message_enabled", "web_pip_redesign", "051", "verify_apps", "1974", "1272", "1322", "1755", "052", "70", "050", "1063", "1135", "1361", "80", "1096", "1828", "1851", "1251", "1921", "key_config_id", "1254", "1566", "1252", "2525", "critical_block", "1669", "max_available", "w:auth:backup:token", "product", "2530", "870", "1022", "participant_uuid", "web_cart_on_off", "1255", "1432", "1867", "41", "1415", "1440", "240", "1204", "1608", "1690", "1846", "1483", "1687", "1749", "69", "url_number", "053", "1325", "1040", "365", "59", "Asia/Riyadh", "1177", "test_recommended", "057", "1612", "43", "1061", "1518", "1635", "055", "1034", "1375", "750", "1430", "event_code", "1682", "503", "55", "865", "78", "1309", "1365", "44", "America/Guayaquil", "535", "LIMITED", "1377", "1613", "1420", "1599", "1822", "05a", "1681", "password", "1111", "1214", "1376", "1478", "47", "1082", "4282", "Europe/Istanbul", "1307", "46", "058", "1124", "256", "rate-overlimit", "retail", "u_a_socket_err_fix_succ_test", "1292", "1370", "1388", "520", "861", "psa", "regular", "1181", "1766", "05b", "1183", "1213", "1304", "1537"], readonly ["1724", "profile_picture", "1071", "1314", "1605", "407", "990", "1710", "746", "pricing_model", "056", "059", "061", "1119", "6027", "65", "877", "1607", "05d", "917", "seen", "1516", "49", "470", "973", "1037", "1350", "1394", "1480", "1796", "keys", "794", "1536", "1594", "2378", "1333", "1524", "1825", "116", "309", "52", "808", "827", "909", "495", "1660", "361", "957", "google", "1357", "1565", "1967", "996", "1775", "586", "736", "1052", "1670", "bank", "177", "1416", "2194", "2222", "1454", "1839", "1275", "53", "997", "1629", "6028", "smba", "1378", "1410", "05c", "1849", "727", "create", "1559", "536", "1106", "1310", "1944", "670", "1297", "1316", "1762", "en", "1148", "1295", "1551", "1853", "1890", "1208", "1784", "7200", "05f", "178", "1283", "1332", "381", "643", "1056", "1238", "2024", "2387", "179", "981", "1547", "1705", "05e", "290", "903", "1069", "1285", "2436", "062", "251", "560", "582", "719", "56", "1700", "2321", "325", "448", "613", "777", "791", "51", "488", "902", "Asia/Almaty", "is_hidden", "1398", "1527", "1893", "1999", "2367", "2642", "237", "busy", "065", "067", "233", "590", "993", "1511", "54", "723", "860", "363", "487", "522", "605", "995", "1321", "1691", "1865", "2447", "2462", "NON_TRANSACTIONAL", "433", "871", "432", "1004", "1207", "2032", "2050", "2379", "2446", "279", "636", "703", "904", "248", "370", "691", "700", "1068", "1655", "2334", "060", "063", "364", "533", "534", "567", "1191", "1210", "1473", "1827", "069", "701", "2531", "514", "prev_dhash", "064", "496", "790", "1046", "1139", "1505", "1521", "1108", "207", "544", "637", "final", "1173", "1293", "1694", "1939", "1951", "1993", "2353", "2515", "504", "601", "857", "modify", "spam_request", "p_121_aa_1101_test4", "866", "1427", "1502", "1638", "1744", "2153", "068", "382", "725", "1704", "1864", "1990", "2003", "Asia/Dubai", "508", "531", "1387", "1474", "1632", "2307", "2386", "819", "2014", "066", "387", "1468", "1706", "2186", "2261", "471", "728", "1147", "1372", "1961"]];
21
- export declare const SINGLE_BYTE_TOKENS: string[];
22
- export declare const TOKEN_MAP: {
23
- [token: string]: {
24
- dict?: number;
25
- index: number;
26
- };
27
- };
@@ -1,6 +0,0 @@
1
- import type { BinaryNode, BinaryNodeCodingOptions } from './types';
2
- export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer<ArrayBufferLike>>;
3
- export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
4
- index: number;
5
- }) => BinaryNode;
6
- export declare const decodeBinaryNode: (buff: Buffer) => Promise<BinaryNode>;
@@ -1,2 +0,0 @@
1
- import type { BinaryNode, BinaryNodeCodingOptions } from './types';
2
- export declare const encodeBinaryNode: (node: BinaryNode, opts?: Pick<BinaryNodeCodingOptions, "TAGS" | "TOKEN_MAP">, buffer?: number[]) => Buffer;
@@ -1,14 +0,0 @@
1
- import { proto } from '../../WAProto';
2
- import { BinaryNode } from './types';
3
- export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
4
- export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
5
- export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
6
- export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | undefined;
7
- export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => string | undefined;
8
- export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined;
9
- export declare const assertNodeErrorFree: (node: BinaryNode) => void;
10
- export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: string) => {
11
- [_: string]: string;
12
- };
13
- export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
14
- export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any;
@@ -1,5 +0,0 @@
1
- export * from './encode';
2
- export * from './decode';
3
- export * from './generic-utils';
4
- export * from './jid-utils';
5
- export * from './types';
@@ -1,36 +0,0 @@
1
- export declare const S_WHATSAPP_NET = "@s.whatsapp.net";
2
- export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
3
- export declare const SERVER_JID = "server@c.us";
4
- export declare const PSA_WID = "0@c.us";
5
- export declare const STORIES_JID = "status@broadcast";
6
- export declare const META_AI_JID = "13135550002@c.us";
7
- export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot';
8
- export type JidWithDevice = {
9
- user: string;
10
- device?: number;
11
- };
12
- export type FullJid = JidWithDevice & {
13
- server: JidServer;
14
- domainType?: number;
15
- };
16
- export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
17
- export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
18
- /** is the jid a user */
19
- export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
20
- /** is the jid Meta IA */
21
- export declare const isJidMetaAi: (jid: string | undefined) => boolean | undefined;
22
- /** is the jid a user */
23
- export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
24
- /** is the jid a group */
25
- export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
26
- /** is the jid a broadcast */
27
- export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
28
- /** is the jid a newsletter */
29
- export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
30
- /** is the jid a group */
31
- export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
32
- /** is the jid the status broadcast */
33
- export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broadcast";
34
- export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
35
- export declare const jidNormalizedUser: (jid: string | undefined) => string;
36
- export declare const getBotJid: (jid: string) => string;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBotJid = exports.jidNormalizedUser = exports.isJidBot = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidNewsletter = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.isJidMetaAi = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.META_AI_JID = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
4
- exports.S_WHATSAPP_NET = '@s.whatsapp.net';
5
- exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
6
- exports.SERVER_JID = 'server@c.us';
7
- exports.PSA_WID = '0@c.us';
8
- exports.STORIES_JID = 'status@broadcast';
9
- exports.META_AI_JID = '13135550002@c.us';
10
- const jidEncode = (user, server, device, agent) => {
11
- return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
12
- };
13
- exports.jidEncode = jidEncode;
14
- const jidDecode = (jid) => {
15
- const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
16
- if (sepIdx < 0) {
17
- return undefined;
18
- }
19
- const server = jid.slice(sepIdx + 1);
20
- const userCombined = jid.slice(0, sepIdx);
21
- const [userAgent, device] = userCombined.split(':');
22
- const user = userAgent.split('_')[0];
23
- return {
24
- server: server,
25
- user,
26
- domainType: server === 'lid' ? 1 : 0,
27
- device: device ? +device : undefined
28
- };
29
- };
30
- exports.jidDecode = jidDecode;
31
- /** is the jid a user */
32
- const areJidsSameUser = (jid1, jid2) => {
33
- var _a, _b;
34
- return (((_a = (0, exports.jidDecode)(jid1)) === null || _a === void 0 ? void 0 : _a.user) === ((_b = (0, exports.jidDecode)(jid2)) === null || _b === void 0 ? void 0 : _b.user));
35
- };
36
- exports.areJidsSameUser = areJidsSameUser;
37
- /** is the jid Meta IA */
38
- const isJidMetaAi = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@bot'));
39
- exports.isJidMetaAi = isJidMetaAi;
40
- /** is the jid a user */
41
- const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
42
- exports.isJidUser = isJidUser;
43
- /** is the jid a group */
44
- const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
45
- exports.isLidUser = isLidUser;
46
- /** is the jid a broadcast */
47
- const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
48
- exports.isJidBroadcast = isJidBroadcast;
49
- /** is the jid a newsletter */
50
- const isJidNewsletter = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@newsletter'));
51
- exports.isJidNewsletter = isJidNewsletter;
52
- /** is the jid a group */
53
- const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'));
54
- exports.isJidGroup = isJidGroup;
55
- /** is the jid the status broadcast */
56
- const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
57
- exports.isJidStatusBroadcast = isJidStatusBroadcast;
58
- const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
59
- const isJidBot = (jid) => (jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us'));
60
- exports.isJidBot = isJidBot;
61
- const jidNormalizedUser = (jid) => {
62
- const result = (0, exports.jidDecode)(jid);
63
- if (!result) {
64
- return '';
65
- }
66
- const { user, server } = result;
67
- return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
68
- };
69
- exports.jidNormalizedUser = jidNormalizedUser;
70
- const getBotJid = (jid) => {
71
- const BOT_MAP = new Map([["867051314767696", "13135550002"], ["1061492271844689", "13135550005"], ["245886058483988", "13135550009"], ["3509905702656130", "13135550012"], ["1059680132034576", "13135550013"], ["715681030623646", "13135550014"], ["1644971366323052", "13135550015"], ["582497970646566", "13135550019"], ["645459357769306", "13135550022"], ["294997126699143", "13135550023"], ["1522631578502677", "13135550027"], ["719421926276396", "13135550030"], ["1788488635002167", "13135550031"], ["24232338603080193", "13135550033"], ["689289903143209", "13135550035"], ["871626054177096", "13135550039"], ["362351902849370", "13135550042"], ["1744617646041527", "13135550043"], ["893887762270570", "13135550046"], ["1155032702135830", "13135550047"], ["333931965993883", "13135550048"], ["853748013058752", "13135550049"], ["1559068611564819", "13135550053"], ["890487432705716", "13135550054"], ["240254602395494", "13135550055"], ["1578420349663261", "13135550062"], ["322908887140421", "13135550065"], ["3713961535514771", "13135550067"], ["997884654811738", "13135550070"], ["403157239387035", "13135550081"], ["535242369074963", "13135550082"], ["946293427247659", "13135550083"], ["3664707673802291", "13135550084"], ["1821827464894892", "13135550085"], ["1760312477828757", "13135550086"], ["439480398712216", "13135550087"], ["1876735582800984", "13135550088"], ["984025089825661", "13135550089"], ["1001336351558186", "13135550090"], ["3739346336347061", "13135550091"], ["3632749426974980", "13135550092"], ["427864203481615", "13135550093"], ["1434734570493055", "13135550094"], ["992873449225921", "13135550095"], ["813087747426445", "13135550096"], ["806369104931434", "13135550098"], ["1220982902403148", "13135550099"], ["1365893374104393", "13135550100"], ["686482033622048", "13135550200"], ["1454999838411253", "13135550201"], ["718584497008509", "13135550202"], ["743520384213443", "13135550301"], ["1147715789823789", "13135550302"], ["1173034540372201", "13135550303"], ["974785541030953", "13135550304"], ["1122200255531507", "13135550305"], ["899669714813162", "13135550306"], ["631880108970650", "13135550307"], ["435816149330026", "13135550308"], ["1368717161184556", "13135550309"], ["7849963461784891", "13135550310"], ["3609617065968984", "13135550312"], ["356273980574602", "13135550313"], ["1043447920539760", "13135550314"], ["1052764336525346", "13135550315"], ["2631118843732685", "13135550316"], ["510505411332176", "13135550317"], ["1945664239227513", "13135550318"], ["1518594378764656", "13135550319"], ["1378821579456138", "13135550320"], ["490214716896013", "13135550321"], ["1028577858870699", "13135550322"], ["308915665545959", "13135550323"], ["845884253678900", "13135550324"], ["995031308616442", "13135550325"], ["2787365464763437", "13135550326"], ["1532790990671645", "13135550327"], ["302617036180485", "13135550328"], ["723376723197227", "13135550329"], ["8393570407377966", "13135550330"], ["1931159970680725", "13135550331"], ["401073885688605", "13135550332"], ["2234478453565422", "13135550334"], ["814748673882312", "13135550335"], ["26133635056281592", "13135550336"], ["1439804456676119", "13135550337"], ["889851503172161", "13135550338"], ["1018283232836879", "13135550339"], ["1012781386779537", "13135559000"], ["823280953239532", "13135559001"], ["1597090934573334", "13135559002"], ["485965054020343", "13135559003"], ["1033381648363446", "13135559004"], ["491802010206446", "13135559005"], ["1017139033184870", "13135559006"], ["499638325922174", "13135559008"], ["468946335863664", "13135559009"], ["1570389776875816", "13135559010"], ["1004342694328995", "13135559011"], ["1012240323971229", "13135559012"], ["392171787222419", "13135559013"], ["952081212945019", "13135559016"], ["444507875070178", "13135559017"], ["1274819440594668", "13135559018"], ["1397041101147050", "13135559019"], ["425657699872640", "13135559020"], ["532292852562549", "13135559021"], ["705863241720292", "13135559022"], ["476449815183959", "13135559023"], ["488071553854222", "13135559024"], ["468693832665397", "13135559025"], ["517422564037340", "13135559026"], ["819805466613825", "13135559027"], ["1847708235641382", "13135559028"], ["716282970644228", "13135559029"], ["521655380527741", "13135559030"], ["476193631941905", "13135559031"], ["485600497445562", "13135559032"], ["440217235683910", "13135559033"], ["523342446758478", "13135559034"], ["514784864360240", "13135559035"], ["505790121814530", "13135559036"], ["420008964419580", "13135559037"], ["492141680204555", "13135559038"], ["388462787271952", "13135559039"], ["423473920752072", "13135559040"], ["489574180468229", "13135559041"], ["432360635854105", "13135559042"], ["477878201669248", "13135559043"], ["351656951234045", "13135559044"], ["430178036732582", "13135559045"], ["434537312944552", "13135559046"], ["1240614300631808", "13135559047"], ["473135945605128", "13135559048"], ["423669800729310", "13135559049"], ["3685666705015792", "13135559050"], ["504196509016638", "13135559051"], ["346844785189449", "13135559052"], ["504823088911074", "13135559053"], ["402669415797083", "13135559054"], ["490939640234431", "13135559055"], ["875124128063715", "13135559056"], ["468788962654605", "13135559057"], ["562386196354570", "13135559058"], ["372159285928791", "13135559059"], ["531017479591050", "13135559060"], ["1328873881401826", "13135559061"], ["1608363646390484", "13135559062"], ["1229628561554232", "13135559063"], ["348802211530364", "13135559064"], ["3708535859420184", "13135559065"], ["415517767742187", "13135559066"], ["479330341612638", "13135559067"], ["480785414723083", "13135559068"], ["387299107507991", "13135559069"], ["333389813188944", "13135559070"], ["391794130316996", "13135559071"], ["457893470576314", "13135559072"], ["435550496166469", "13135559073"], ["1620162702100689", "13135559074"], ["867491058616043", "13135559075"], ["816224117357759", "13135559076"], ["334065176362830", "13135559077"], ["489973170554709", "13135559078"], ["473060669049665", "13135559079"], ["1221505815643060", "13135559080"], ["889000703096359", "13135559081"], ["475235961979883", "13135559082"], ["3434445653519934", "13135559084"], ["524503026827421", "13135559085"], ["1179639046403856", "13135559086"], ["471563305859144", "13135559087"], ["533896609192881", "13135559088"], ["365443583168041", "13135559089"], ["836082305329393", "13135559090"], ["1056787705969916", "13135559091"], ["503312598958357", "13135559092"], ["3718606738453460", "13135559093"], ["826066052850902", "13135559094"], ["1033611345091888", "13135559095"], ["3868390816783240", "13135559096"], ["7462677740498860", "13135559097"], ["436288576108573", "13135559098"], ["1047559746718900", "13135559099"], ["1099299455255491", "13135559100"], ["1202037301040633", "13135559101"], ["1720619402074074", "13135559102"], ["1030422235101467", "13135559103"], ["827238979523502", "13135559104"], ["1516443722284921", "13135559105"], ["1174442747196709", "13135559106"], ["1653165225503842", "13135559107"], ["1037648777635013", "13135559108"], ["551617757299900", "13135559109"], ["1158813558718726", "13135559110"], ["2463236450542262", "13135559111"], ["1550393252501466", "13135559112"], ["2057065188042796", "13135559113"], ["506163028760735", "13135559114"], ["2065249100538481", "13135559115"], ["1041382867195858", "13135559116"], ["886500209499603", "13135559117"], ["1491615624892655", "13135559118"], ["486563697299617", "13135559119"], ["1175736513679463", "13135559120"], ["491811473512352", "13165550064"]]);
72
- const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
73
- if (sepIdx < 0) {
74
- return jid;
75
- }
76
- const server = jid.slice(sepIdx + 1);
77
- if (server !== 'bot')
78
- return jid;
79
- const user = jid.slice(0, sepIdx);
80
- const mappedNumber = BOT_MAP.get(user);
81
- return mappedNumber ? `${mappedNumber}@s.whatsapp.net` : jid;
82
- };
83
- exports.getBotJid = getBotJid;