@alannxd/baileys 6.0.5 → 6.0.9

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 (123) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +341 -286
  3. package/WAProto/WAProto.proto +1782 -359
  4. package/WAProto/index.d.ts +75133 -9893
  5. package/WAProto/index.js +205861 -60606
  6. package/lib/Socket/luxu.js +6 -117
  7. package/lib/Socket/messages-send.js +637 -493
  8. package/lib/Socket/newsletter.js +229 -156
  9. package/lib/Utils/browser-utils.js +26 -6
  10. package/lib/Utils/decode-wa-message.js +33 -0
  11. package/lib/Utils/generics.js +10 -0
  12. package/lib/Utils/index.js +1 -0
  13. package/lib/Utils/message-composer.js +273 -0
  14. package/lib/Utils/messages.js +361 -24
  15. package/lib/WABinary/generic-utils.js +8 -1
  16. package/lib/WABinary/jid-utils.js +2 -0
  17. package/lib/index.js +1 -2
  18. package/package.json +5 -4
  19. package/lib/Defaults/index.d.ts +0 -75
  20. package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
  21. package/lib/Signal/Group/group-session-builder.d.ts +0 -15
  22. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  23. package/lib/Signal/Group/index.d.ts +0 -12
  24. package/lib/Signal/Group/keyhelper.d.ts +0 -11
  25. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  26. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  27. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  28. package/lib/Signal/Group/sender-key-name.d.ts +0 -18
  29. package/lib/Signal/Group/sender-key-record.d.ts +0 -31
  30. package/lib/Signal/Group/sender-key-state.d.ts +0 -39
  31. package/lib/Signal/Group/sender-message-key.d.ts +0 -12
  32. package/lib/Signal/libsignal.d.ts +0 -5
  33. package/lib/Signal/lid-mapping.d.ts +0 -23
  34. package/lib/Socket/Client/index.d.ts +0 -3
  35. package/lib/Socket/Client/types.d.ts +0 -16
  36. package/lib/Socket/Client/websocket.d.ts +0 -13
  37. package/lib/Socket/business.d.ts +0 -217
  38. package/lib/Socket/chats.d.ts +0 -124
  39. package/lib/Socket/communities.d.ts +0 -273
  40. package/lib/Socket/groups.d.ts +0 -162
  41. package/lib/Socket/index.d.ts +0 -260
  42. package/lib/Socket/luxu.d.ts +0 -22
  43. package/lib/Socket/messages-recv.d.ts +0 -213
  44. package/lib/Socket/messages-send.d.ts +0 -199
  45. package/lib/Socket/mex.d.ts +0 -3
  46. package/lib/Socket/newsletter.d.ts +0 -170
  47. package/lib/Socket/socket.d.ts +0 -59
  48. package/lib/Store/index.d.ts +0 -10
  49. package/lib/Store/keyed-db.d.ts +0 -22
  50. package/lib/Store/make-cache-manager-store.d.ts +0 -19
  51. package/lib/Store/make-in-memory-store.d.ts +0 -39
  52. package/lib/Store/make-ordered-dictionary.d.ts +0 -14
  53. package/lib/Store/object-repository.d.ts +0 -11
  54. package/lib/Types/Auth.d.ts +0 -117
  55. package/lib/Types/Bussines.d.ts +0 -25
  56. package/lib/Types/Call.d.ts +0 -15
  57. package/lib/Types/Chat.d.ts +0 -124
  58. package/lib/Types/Contact.d.ts +0 -26
  59. package/lib/Types/Events.d.ts +0 -256
  60. package/lib/Types/GroupMetadata.d.ts +0 -71
  61. package/lib/Types/Label.d.ts +0 -47
  62. package/lib/Types/LabelAssociation.d.ts +0 -30
  63. package/lib/Types/Message.d.ts +0 -320
  64. package/lib/Types/Mex.d.ts +0 -141
  65. package/lib/Types/Product.d.ts +0 -79
  66. package/lib/Types/Signal.d.ts +0 -87
  67. package/lib/Types/Socket.d.ts +0 -136
  68. package/lib/Types/State.d.ts +0 -97
  69. package/lib/Types/USync.d.ts +0 -26
  70. package/lib/Types/index.d.ts +0 -65
  71. package/lib/Utils/auth-utils.d.ts +0 -24
  72. package/lib/Utils/browser-utils.d.ts +0 -4
  73. package/lib/Utils/business.d.ts +0 -23
  74. package/lib/Utils/chat-utils.d.ts +0 -100
  75. package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
  76. package/lib/Utils/crypto.d.ts +0 -37
  77. package/lib/Utils/decode-wa-message.d.ts +0 -66
  78. package/lib/Utils/event-buffer.d.ts +0 -36
  79. package/lib/Utils/generics.d.ts +0 -91
  80. package/lib/Utils/history.d.ts +0 -24
  81. package/lib/Utils/identity-change-handler.d.ts +0 -44
  82. package/lib/Utils/index.d.ts +0 -22
  83. package/lib/Utils/link-preview.d.ts +0 -21
  84. package/lib/Utils/logger.d.ts +0 -12
  85. package/lib/Utils/lt-hash.d.ts +0 -8
  86. package/lib/Utils/make-mutex.d.ts +0 -9
  87. package/lib/Utils/message-retry-manager.d.ts +0 -115
  88. package/lib/Utils/messages-media.d.ts +0 -133
  89. package/lib/Utils/messages.d.ts +0 -91
  90. package/lib/Utils/noise-handler.d.ts +0 -20
  91. package/lib/Utils/offline-node-processor.d.ts +0 -17
  92. package/lib/Utils/pre-key-manager.d.ts +0 -28
  93. package/lib/Utils/process-message.d.ts +0 -60
  94. package/lib/Utils/reporting-utils.d.ts +0 -11
  95. package/lib/Utils/signal.d.ts +0 -47
  96. package/lib/Utils/stanza-ack.d.ts +0 -11
  97. package/lib/Utils/sync-action-utils.d.ts +0 -19
  98. package/lib/Utils/tc-token-utils.d.ts +0 -37
  99. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  100. package/lib/Utils/validate-connection.d.ts +0 -11
  101. package/lib/WABinary/constants.d.ts +0 -28
  102. package/lib/WABinary/decode.d.ts +0 -7
  103. package/lib/WABinary/encode.d.ts +0 -3
  104. package/lib/WABinary/generic-utils.d.ts +0 -18
  105. package/lib/WABinary/index.d.ts +0 -6
  106. package/lib/WABinary/jid-utils.d.ts +0 -48
  107. package/lib/WABinary/types.d.ts +0 -19
  108. package/lib/WAM/BinaryInfo.d.ts +0 -9
  109. package/lib/WAM/constants.d.ts +0 -40
  110. package/lib/WAM/encode.d.ts +0 -3
  111. package/lib/WAM/index.d.ts +0 -4
  112. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  113. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
  114. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
  115. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
  116. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
  117. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
  118. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
  119. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  120. package/lib/WAUSync/USyncQuery.d.ts +0 -30
  121. package/lib/WAUSync/USyncUser.d.ts +0 -17
  122. package/lib/WAUSync/index.d.ts +0 -4
  123. package/lib/index.d.ts +0 -13
@@ -1,136 +0,0 @@
1
- import type { Agent } from 'https';
2
- import type { URL } from 'url';
3
- import { proto } from '../../WAProto/index.js';
4
- import type { ILogger } from '../Utils/logger.js';
5
- import type { AuthenticationState, LIDMapping, SignalAuthState, TransactionCapabilityOptions } from './Auth.js';
6
- import type { GroupMetadata } from './GroupMetadata.js';
7
- import { type MediaConnInfo, type WAMessageKey } from './Message.js';
8
- import type { SignalRepositoryWithLIDStore } from './Signal.js';
9
- export type WAVersion = [number, number, number];
10
- export type WABrowserDescription = [string, string, string];
11
- export type CacheStore = {
12
- /** get a cached key and change the stats */
13
- get<T>(key: string): Promise<T> | T | undefined;
14
- /** set a key in the cache */
15
- set<T>(key: string, value: T): Promise<void> | void | number | boolean;
16
- /** delete a key from the cache */
17
- del(key: string): void | Promise<void> | number | boolean;
18
- /** flush all data */
19
- flushAll(): void | Promise<void>;
20
- close?: () => void;
21
- };
22
- export type PossiblyExtendedCacheStore = CacheStore & {
23
- mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>;
24
- mset?: <T>(entries: {
25
- key: string;
26
- value: T;
27
- }[]) => Promise<void> | void | number | boolean;
28
- mdel?: (keys: string[]) => void | Promise<void> | number | boolean;
29
- };
30
- export type PatchedMessageWithRecipientJID = proto.IMessage & {
31
- recipientJid?: string;
32
- };
33
- export type SocketConfig = {
34
- /** the WS url to connect to WA */
35
- waWebSocketUrl: string | URL;
36
- /** Fails the connection if the socket times out in this interval */
37
- connectTimeoutMs: number;
38
- /** Default timeout for queries, undefined for no timeout */
39
- defaultQueryTimeoutMs: number | undefined;
40
- /** ping-pong interval for WS connection */
41
- keepAliveIntervalMs: number;
42
- /** should baileys use the mobile api instead of the multi device api
43
- * @deprecated This feature has been removed
44
- */
45
- mobile?: boolean;
46
- /** proxy agent */
47
- agent?: Agent;
48
- /** logger */
49
- logger: ILogger;
50
- /** version to connect with */
51
- version: WAVersion;
52
- /** override browser config */
53
- browser: WABrowserDescription;
54
- /** Initial pushName carried in the registration ClientPayload (used by mock servers for deterministic phone assignment). */
55
- pushName?: string;
56
- /** agent used for fetch requests -- uploading/downloading media */
57
- fetchAgent?: Agent;
58
- /** should the QR be printed in the terminal
59
- * @deprecated This feature has been removed
60
- */
61
- printQRInTerminal?: boolean;
62
- /** should events be emitted for actions done by this socket connection */
63
- emitOwnEvents: boolean;
64
- /** custom upload hosts to upload media to */
65
- customUploadHosts: MediaConnInfo['hosts'];
66
- /** time to wait between sending new retry requests */
67
- retryRequestDelayMs: number;
68
- /** max retry count */
69
- maxMsgRetryCount: number;
70
- /** time to wait for the generation of the next QR in ms */
71
- qrTimeout?: number;
72
- /** provide an auth state object to maintain the auth state */
73
- auth: AuthenticationState;
74
- /** manage history processing with this control; by default will sync up everything */
75
- shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
76
- /** transaction capability options for SignalKeyStore */
77
- transactionOpts: TransactionCapabilityOptions;
78
- /** marks the client as online whenever the socket successfully connects */
79
- markOnlineOnConnect: boolean;
80
- /** alphanumeric country code (USA -> US) for the number used */
81
- countryCode: string;
82
- /** provide a cache to store media, so does not have to be re-uploaded */
83
- mediaCache?: CacheStore;
84
- /**
85
- * map to store the retry counts for failed messages;
86
- * used to determine whether to retry a message or not */
87
- msgRetryCounterCache?: CacheStore;
88
- /** provide a cache to store a user's device list */
89
- userDevicesCache?: PossiblyExtendedCacheStore;
90
- /** cache to store call offers */
91
- callOfferCache?: CacheStore;
92
- /** cache to track placeholder resends */
93
- placeholderResendCache?: CacheStore;
94
- /** width for link preview images */
95
- linkPreviewImageThumbnailWidth: number;
96
- /** Should Baileys ask the phone for full history, will be received async */
97
- syncFullHistory: boolean;
98
- /** Should baileys fire init queries automatically, default true */
99
- fireInitQueries: boolean;
100
- /**
101
- * generate a high quality link preview,
102
- * entails uploading the jpegThumbnail to WA
103
- * */
104
- generateHighQualityLinkPreview: boolean;
105
- /** Enable automatic session recreation for failed messages */
106
- enableAutoSessionRecreation: boolean;
107
- /** Enable recent message caching for retry handling */
108
- enableRecentMessageCache: boolean;
109
- /**
110
- * Returns if a jid should be ignored,
111
- * no event for that jid will be triggered.
112
- * Messages from that jid will also not be decrypted
113
- * */
114
- shouldIgnoreJid: (jid: string) => boolean | undefined;
115
- /**
116
- * Optionally patch the message before sending out
117
- * */
118
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
119
- /** verify app state MACs */
120
- appStateMacVerification: {
121
- patch: boolean;
122
- snapshot: boolean;
123
- };
124
- /** options for HTTP fetch requests */
125
- options: RequestInit;
126
- /**
127
- * fetch a message from your store
128
- * implement this so that messages failed to send
129
- * (solves the "this message can take a while" issue) can be retried
130
- * */
131
- getMessage: (key: WAMessageKey) => Promise<proto.IMessage | undefined>;
132
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
133
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
134
- makeSignalRepository: (auth: SignalAuthState, logger: ILogger, pnToLIDFunc?: (jids: string[]) => Promise<LIDMapping[] | undefined>) => SignalRepositoryWithLIDStore;
135
- };
136
- //# sourceMappingURL=Socket.d.ts.map
@@ -1,97 +0,0 @@
1
- import { Boom } from '@hapi/boom';
2
- import type { Contact } from './Contact.js';
3
- export declare enum SyncState {
4
- /** The socket is connecting, but we haven't received pending notifications yet. */
5
- Connecting = 0,
6
- /** Pending notifications received. Buffering events until we decide whether to sync or not. */
7
- AwaitingInitialSync = 1,
8
- /** The initial app state sync (history, etc.) is in progress. Buffering continues. */
9
- Syncing = 2,
10
- /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
11
- Online = 3
12
- }
13
- export type WAConnectionState = 'open' | 'connecting' | 'close';
14
- export type ConnectionState = {
15
- /** connection is now open, connecting or closed */
16
- connection: WAConnectionState;
17
- /** the error that caused the connection to close */
18
- lastDisconnect?: {
19
- error: Boom | Error | undefined;
20
- date: Date;
21
- };
22
- /** is this a new login */
23
- isNewLogin?: boolean;
24
- /** the current QR code */
25
- qr?: string;
26
- /** has the device received all pending notifications while it was offline */
27
- receivedPendingNotifications?: boolean;
28
- /** legacy connection options */
29
- legacy?: {
30
- phoneConnected: boolean;
31
- user?: Contact;
32
- };
33
- /**
34
- * if the client is shown as an active, online client.
35
- * If this is false, the primary phone and other devices will receive notifs
36
- * */
37
- isOnline?: boolean;
38
- /**
39
- * When you are in this state, WhatsApp prevents outgoing messages and calls.
40
- */
41
- reachoutTimeLock?: ReachoutTimelockState;
42
- };
43
- export type ReachoutTimelockState = {
44
- isActive?: boolean;
45
- timeEnforcementEnds?: Date;
46
- enforcementType?: ReachoutTimelockEnforcementType;
47
- };
48
- export declare enum ReachoutTimelockEnforcementType {
49
- BIZ_COMMERCE_VIOLATION_ALCOHOL = "BIZ_COMMERCE_VIOLATION_ALCOHOL",
50
- BIZ_COMMERCE_VIOLATION_ADULT = "BIZ_COMMERCE_VIOLATION_ADULT",
51
- BIZ_COMMERCE_VIOLATION_ANIMALS = "BIZ_COMMERCE_VIOLATION_ANIMALS",
52
- BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS = "BIZ_COMMERCE_VIOLATION_BODY_PARTS_FLUIDS",
53
- BIZ_COMMERCE_VIOLATION_DATING = "BIZ_COMMERCE_VIOLATION_DATING",
54
- BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS = "BIZ_COMMERCE_VIOLATION_DIGITAL_SERVICES_PRODUCTS",
55
- BIZ_COMMERCE_VIOLATION_DRUGS = "BIZ_COMMERCE_VIOLATION_DRUGS",
56
- BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC = "BIZ_COMMERCE_VIOLATION_DRUGS_ONLY_OTC",
57
- BIZ_COMMERCE_VIOLATION_GAMBLING = "BIZ_COMMERCE_VIOLATION_GAMBLING",
58
- BIZ_COMMERCE_VIOLATION_HEALTHCARE = "BIZ_COMMERCE_VIOLATION_HEALTHCARE",
59
- BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY = "BIZ_COMMERCE_VIOLATION_REAL_FAKE_CURRENCY",
60
- BIZ_COMMERCE_VIOLATION_SUPPLEMENTS = "BIZ_COMMERCE_VIOLATION_SUPPLEMENTS",
61
- BIZ_COMMERCE_VIOLATION_TOBACCO = "BIZ_COMMERCE_VIOLATION_TOBACCO",
62
- BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT = "BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT",
63
- BIZ_COMMERCE_VIOLATION_WEAPONS = "BIZ_COMMERCE_VIOLATION_WEAPONS",
64
- BIZ_QUALITY = "BIZ_QUALITY",
65
- /** This means there is no restriction */
66
- DEFAULT = "DEFAULT",
67
- WEB_COMPANION_ONLY = "WEB_COMPANION_ONLY"
68
- }
69
- export declare enum NewChatMessageCappingStatusType {
70
- NONE = "NONE",
71
- FIRST_WARNING = "FIRST_WARNING",
72
- SECOND_WARNING = "SECOND_WARNING",
73
- CAPPED = "CAPPED"
74
- }
75
- export declare enum NewChatMessageCappingMVStatusType {
76
- NOT_ELIGIBLE = "NOT_ELIGIBLE",
77
- NOT_ACTIVE = "NOT_ACTIVE",
78
- ACTIVE = "ACTIVE",
79
- ACTIVE_UPGRADE_AVAILABLE = "ACTIVE_UPGRADE_AVAILABLE"
80
- }
81
- export declare enum NewChatMessageCappingOTEStatusType {
82
- NOT_ELIGIBLE = "NOT_ELIGIBLE",
83
- ELIGIBLE = "ELIGIBLE",
84
- ACTIVE_IN_CURRENT_CYCLE = "ACTIVE_IN_CURRENT_CYCLE",
85
- EXHAUSTED = "EXHAUSTED"
86
- }
87
- export type NewChatMessageCapInfo = {
88
- total_quota?: number;
89
- used_quota?: number;
90
- cycle_start_timestamp?: string;
91
- cycle_end_timestamp?: string;
92
- server_sent_timestamp?: string;
93
- ote_status?: NewChatMessageCappingOTEStatusType;
94
- mv_status?: NewChatMessageCappingMVStatusType;
95
- capping_status?: NewChatMessageCappingStatusType;
96
- };
97
- //# sourceMappingURL=State.d.ts.map
@@ -1,26 +0,0 @@
1
- import type { BinaryNode } from '../WABinary/index.js';
2
- import { USyncUser } from '../WAUSync/index.js';
3
- /**
4
- * Defines the interface for a USyncQuery protocol
5
- */
6
- export interface USyncQueryProtocol {
7
- /**
8
- * The name of the protocol
9
- */
10
- name: string;
11
- /**
12
- * Defines what goes inside the query part of a USyncQuery
13
- */
14
- getQueryElement: () => BinaryNode;
15
- /**
16
- * Defines what goes inside the user part of a USyncQuery
17
- */
18
- getUserElement: (user: USyncUser) => BinaryNode | null;
19
- /**
20
- * Parse the result of the query
21
- * @param data Data from the result
22
- * @returns Whatever the protocol is supposed to return
23
- */
24
- parser: (data: BinaryNode) => unknown;
25
- }
26
- //# sourceMappingURL=USync.d.ts.map
@@ -1,65 +0,0 @@
1
- export * from './Auth.js';
2
- export * from './GroupMetadata.js';
3
- export * from './Chat.js';
4
- export * from './Contact.js';
5
- export * from './State.js';
6
- export * from './Message.js';
7
- export * from './Socket.js';
8
- export * from './Events.js';
9
- export * from './Product.js';
10
- export * from './Call.js';
11
- export * from './Signal.js';
12
- export * from './Mex.js';
13
- import type { AuthenticationState } from './Auth.js';
14
- import type { SocketConfig } from './Socket.js';
15
- export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
- auth: AuthenticationState;
17
- };
18
- export type BrowsersMap = {
19
- ubuntu(browser: string): [string, string, string];
20
- macOS(browser: string): [string, string, string];
21
- baileys(browser: string): [string, string, string];
22
- windows(browser: string): [string, string, string];
23
- appropriate(browser: string): [string, string, string];
24
- };
25
- export declare enum DisconnectReason {
26
- connectionClosed = 428,
27
- connectionLost = 408,
28
- connectionReplaced = 440,
29
- timedOut = 408,
30
- loggedOut = 401,
31
- badSession = 500,
32
- restartRequired = 515,
33
- multideviceMismatch = 411,
34
- forbidden = 403,
35
- unavailableService = 503
36
- }
37
- export type WAInitResponse = {
38
- ref: string;
39
- ttl: number;
40
- status: 200;
41
- };
42
- export type WABusinessHoursConfig = {
43
- day_of_week: string;
44
- mode: string;
45
- open_time?: number;
46
- close_time?: number;
47
- };
48
- export type WABusinessProfile = {
49
- description: string;
50
- email: string | undefined;
51
- business_hours: {
52
- timezone?: string;
53
- config?: WABusinessHoursConfig[];
54
- business_config?: WABusinessHoursConfig[];
55
- };
56
- website: string[];
57
- category?: string;
58
- wid?: string;
59
- address?: string;
60
- };
61
- export type CurveKeyPair = {
62
- private: Uint8Array;
63
- public: Uint8Array;
64
- };
65
- //# sourceMappingURL=index.d.ts.map
@@ -1,24 +0,0 @@
1
- import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types/index.js';
2
- import type { ILogger } from './logger.js';
3
- /**
4
- * Adds caching capability to a SignalKeyStore
5
- * @param store the store to add caching to
6
- * @param logger to log trace events
7
- * @param _cache cache store to use
8
- */
9
- export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger?: ILogger, _cache?: CacheStore): SignalKeyStore;
10
- /**
11
- * Adds DB-like transaction capability to the SignalKeyStore
12
- * Uses AsyncLocalStorage for automatic context management
13
- * @param state the key store to apply this capability to
14
- * @param logger logger to log events
15
- * @returns SignalKeyStore with transaction capability
16
- */
17
- export declare const addTransactionCapability: (state: SignalKeyStore, logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
18
- /**
19
- * Returns the authenticated user's JID, or throws a Boom-401 if creds are not yet authenticated.
20
- * Use this anywhere we'd otherwise reach for `creds.me!.id` to fail fast with a descriptive error.
21
- */
22
- export declare const assertMeId: (creds: AuthenticationCreds) => string;
23
- export declare const initAuthCreds: () => AuthenticationCreds;
24
- //# sourceMappingURL=auth-utils.d.ts.map
@@ -1,4 +0,0 @@
1
- import type { BrowsersMap } from '../Types/index.js';
2
- export declare const Browsers: BrowsersMap;
3
- export declare const getPlatformId: (browser: string) => string;
4
- //# sourceMappingURL=browser-utils.d.ts.map
@@ -1,23 +0,0 @@
1
- import type { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types/index.js';
2
- import { type BinaryNode } from '../WABinary/index.js';
3
- export declare const parseCatalogNode: (node: BinaryNode) => {
4
- products: Product[];
5
- nextPageCursor: string | undefined;
6
- };
7
- export declare const parseCollectionsNode: (node: BinaryNode) => {
8
- collections: CatalogCollection[];
9
- };
10
- export declare const parseOrderDetailsNode: (node: BinaryNode) => OrderDetails;
11
- export declare const toProductNode: (productId: string | undefined, product: ProductCreate | ProductUpdate) => BinaryNode;
12
- export declare const parseProductNode: (productNode: BinaryNode) => Product;
13
- /**
14
- * Uploads images not already uploaded to WA's servers
15
- */
16
- export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T>;
17
- /**
18
- * Uploads images not already uploaded to WA's servers
19
- */
20
- export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
21
- url: string;
22
- }[]>;
23
- //# sourceMappingURL=business.d.ts.map
@@ -1,100 +0,0 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import type { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types/index.js';
3
- import { type BinaryNode } from '../WABinary/index.js';
4
- import type { ILogger } from './logger.js';
5
- type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
6
- export type ChatMutationMap = {
7
- [index: string]: ChatMutation;
8
- };
9
- type Mac = {
10
- indexMac: Uint8Array;
11
- valueMac: Uint8Array;
12
- operation: proto.SyncdMutation.SyncdOperation;
13
- };
14
- export declare const makeLtHashGenerator: ({ indexValueMap, hash }: Pick<LTHashState, "hash" | "indexValueMap">) => {
15
- mix: ({ indexMac, valueMac, operation }: Mac) => void;
16
- finish: () => {
17
- hash: Buffer<ArrayBuffer>;
18
- indexValueMap: {
19
- [indexMacBase64: string]: {
20
- valueMac: Uint8Array | Buffer;
21
- };
22
- };
23
- };
24
- };
25
- export declare const newLTHashState: () => LTHashState;
26
- export declare const ensureLTHashStateVersion: (state: LTHashState) => LTHashState;
27
- export declare const MAX_SYNC_ATTEMPTS = 2;
28
- /**
29
- * Check if an error is a missing app state sync key.
30
- * WA Web treats these as "Blocked" (waits for key arrival), not fatal.
31
- * In Baileys we retry with a snapshot which may use a different key.
32
- */
33
- export declare const isMissingKeyError: (error: any) => boolean;
34
- /**
35
- * Determines if an app state sync error is unrecoverable.
36
- * TypeError indicates a WASM crash; otherwise we give up after MAX_SYNC_ATTEMPTS.
37
- * Missing keys are NOT checked here — they are handled separately as "Blocked".
38
- */
39
- export declare const isAppStateSyncIrrecoverable: (error: any, attempts: number) => boolean;
40
- export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, operation }: WAPatchCreate, myAppStateKeyId: string, state: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey) => Promise<{
41
- patch: proto.ISyncdPatch;
42
- state: LTHashState;
43
- }>;
44
- export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
45
- hash: Buffer<ArrayBuffer>;
46
- indexValueMap: {
47
- [indexMacBase64: string]: {
48
- valueMac: Uint8Array | Buffer;
49
- };
50
- };
51
- }>;
52
- export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
53
- hash: Buffer<ArrayBuffer>;
54
- indexValueMap: {
55
- [indexMacBase64: string]: {
56
- valueMac: Uint8Array | Buffer;
57
- };
58
- };
59
- }>;
60
- export declare const extractSyncdPatches: (result: BinaryNode, options: RequestInit) => Promise<{
61
- critical_unblock_low: {
62
- patches: proto.ISyncdPatch[];
63
- hasMorePatches: boolean;
64
- snapshot?: proto.ISyncdSnapshot;
65
- };
66
- regular_high: {
67
- patches: proto.ISyncdPatch[];
68
- hasMorePatches: boolean;
69
- snapshot?: proto.ISyncdSnapshot;
70
- };
71
- regular_low: {
72
- patches: proto.ISyncdPatch[];
73
- hasMorePatches: boolean;
74
- snapshot?: proto.ISyncdSnapshot;
75
- };
76
- critical_block: {
77
- patches: proto.ISyncdPatch[];
78
- hasMorePatches: boolean;
79
- snapshot?: proto.ISyncdSnapshot;
80
- };
81
- regular: {
82
- patches: proto.ISyncdPatch[];
83
- hasMorePatches: boolean;
84
- snapshot?: proto.ISyncdSnapshot;
85
- };
86
- }>;
87
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: RequestInit) => Promise<Buffer<ArrayBuffer>>;
88
- export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: RequestInit) => Promise<proto.SyncdMutations>;
89
- export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean, logger?: ILogger) => Promise<{
90
- state: LTHashState;
91
- mutationMap: ChatMutationMap;
92
- }>;
93
- export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: RequestInit, minimumVersionNumber?: number, logger?: ILogger, validateMacs?: boolean) => Promise<{
94
- state: LTHashState;
95
- mutationMap: ChatMutationMap;
96
- }>;
97
- export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
98
- export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void;
99
- export {};
100
- //# sourceMappingURL=chat-utils.d.ts.map
@@ -1,17 +0,0 @@
1
- import type { WABrowserDescription } from '../Types/index.js';
2
- export declare enum CompanionWebClientType {
3
- UNKNOWN = 0,
4
- CHROME = 1,
5
- EDGE = 2,
6
- FIREFOX = 3,
7
- IE = 4,
8
- OPERA = 5,
9
- SAFARI = 6,
10
- ELECTRON = 7,
11
- UWP = 8,
12
- OTHER_WEB_CLIENT = 9
13
- }
14
- export declare const getCompanionWebClientType: ([os, browserName]: WABrowserDescription) => CompanionWebClientType;
15
- export declare const getCompanionPlatformId: (browser: WABrowserDescription) => string;
16
- export declare const buildPairingQRData: (ref: string, noiseKeyB64: string, identityKeyB64: string, advB64: string, browser: WABrowserDescription) => string;
17
- //# sourceMappingURL=companion-reg-client-utils.d.ts.map
@@ -1,37 +0,0 @@
1
- import type { KeyPair } from '../Types/index.js';
2
- export { md5, hkdf } from 'whatsapp-rust-bridge';
3
- /** prefix version byte to the pub keys, required for some curve crypto functions */
4
- export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
5
- export declare const Curve: {
6
- generateKeyPair: () => KeyPair;
7
- sharedKey: (privateKey: Uint8Array, publicKey: Uint8Array) => Buffer<ArrayBuffer>;
8
- sign: (privateKey: Uint8Array, buf: Uint8Array) => Uint8Array<ArrayBufferLike>;
9
- verify: (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => boolean;
10
- };
11
- export declare const signedKeyPair: (identityKeyPair: KeyPair, keyId: number) => {
12
- keyPair: KeyPair;
13
- signature: Uint8Array<ArrayBufferLike>;
14
- keyId: number;
15
- };
16
- /**
17
- * encrypt AES 256 GCM;
18
- * where the tag tag is suffixed to the ciphertext
19
- * */
20
- export declare function aesEncryptGCM(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer<ArrayBuffer>;
21
- /**
22
- * decrypt AES 256 GCM;
23
- * where the auth tag is suffixed to the ciphertext
24
- * */
25
- export declare function aesDecryptGCM(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, additionalData: Uint8Array): Buffer<ArrayBuffer>;
26
- export declare function aesEncryptCTR(plaintext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer<ArrayBuffer>;
27
- export declare function aesDecryptCTR(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array): Buffer<ArrayBuffer>;
28
- /** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
29
- export declare function aesDecrypt(buffer: Uint8Array, key: Uint8Array): Buffer<ArrayBuffer>;
30
- /** decrypt AES 256 CBC */
31
- export declare function aesDecryptWithIV(buffer: Uint8Array, key: Uint8Array, IV: Uint8Array): Buffer<ArrayBuffer>;
32
- export declare function aesEncrypt(buffer: Uint8Array, key: Uint8Array): Buffer<ArrayBuffer>;
33
- export declare function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer): Buffer<ArrayBuffer>;
34
- export declare function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant?: 'sha256' | 'sha512'): Buffer<ArrayBufferLike>;
35
- export declare function sha256(buffer: Buffer): Buffer<ArrayBufferLike>;
36
- export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Promise<Buffer>;
37
- //# sourceMappingURL=crypto.d.ts.map
@@ -1,66 +0,0 @@
1
- import type { WAMessage } from '../Types/index.js';
2
- import type { SignalRepositoryWithLIDStore } from '../Types/Signal.js';
3
- import { type BinaryNode } from '../WABinary/index.js';
4
- import type { ILogger } from './logger.js';
5
- export declare const getDecryptionJid: (sender: string, repository: SignalRepositoryWithLIDStore) => Promise<string>;
6
- export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
7
- export declare const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled";
8
- export declare const ACCOUNT_RESTRICTED_TEXT = "Your account has been restricted";
9
- export declare const DECRYPTION_RETRY_CONFIG: {
10
- maxRetries: number;
11
- baseDelayMs: number;
12
- sessionRecordErrors: string[];
13
- };
14
- /** NACK reason codes we send to the server (client → server) */
15
- export declare const NACK_REASONS: {
16
- SenderReachoutTimelocked: number;
17
- ParsingError: number;
18
- UnrecognizedStanza: number;
19
- UnrecognizedStanzaClass: number;
20
- UnrecognizedStanzaType: number;
21
- InvalidProtobuf: number;
22
- InvalidHostedCompanionStanza: number;
23
- MissingMessageSecret: number;
24
- SignalErrorOldCounter: number;
25
- MessageDeletedOnPeer: number;
26
- UnhandledError: number;
27
- UnsupportedAdminRevoke: number;
28
- UnsupportedLIDGroup: number;
29
- DBOperationFailed: number;
30
- };
31
- /**
32
- * Server-side error codes returned in ack stanzas (server → client) that we
33
- * currently have dedicated handlers for. Extend as more handlers are added.
34
- * Distinct from the client-side NackReason enum (WAWebCreateNackFromStanza).
35
- */
36
- export declare const SERVER_ERROR_CODES: {
37
- /**
38
- * 1:1 message missing privacy token (tctoken). Usually means the account is
39
- * restricted: WhatsApp blocks starting new chats but preserves existing ones,
40
- * since established chats already carry a tctoken.
41
- */
42
- readonly MessageAccountRestriction: "463";
43
- /** Stanza validation failure (SMAX_INVALID) — likely stale device session */
44
- readonly SmaxInvalid: "479";
45
- };
46
- export declare const extractAddressingContext: (stanza: BinaryNode) => {
47
- addressingMode: string;
48
- senderAlt: string | undefined;
49
- recipientAlt: string | undefined;
50
- };
51
- /**
52
- * Decode the received node as a message.
53
- * @note this will only parse the message, not decrypt it
54
- */
55
- export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
56
- fullMessage: WAMessage;
57
- author: string;
58
- sender: string;
59
- };
60
- export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepositoryWithLIDStore, logger: ILogger) => {
61
- fullMessage: WAMessage;
62
- category: string | undefined;
63
- author: string;
64
- decrypt(): Promise<void>;
65
- };
66
- //# sourceMappingURL=decode-wa-message.d.ts.map
@@ -1,36 +0,0 @@
1
- import type { BaileysEventEmitter, BaileysEventMap } from '../Types/index.js';
2
- import type { ILogger } from './logger.js';
3
- /**
4
- * A map that contains a list of all events that have been triggered
5
- *
6
- * Note, this can contain different type of events
7
- * this can make processing events extremely efficient -- since everything
8
- * can be done in a single transaction
9
- */
10
- type BaileysEventData = Partial<BaileysEventMap>;
11
- type BaileysBufferableEventEmitter = BaileysEventEmitter & {
12
- /** Use to process events in a batch */
13
- process(handler: (events: BaileysEventData) => void | Promise<void>): () => void;
14
- /**
15
- * starts buffering events, call flush() to release them
16
- * */
17
- buffer(): void;
18
- /** buffers all events till the promise completes */
19
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
20
- /**
21
- * flushes all buffered events
22
- * @returns returns true if the flush actually happened, otherwise false
23
- */
24
- flush(): boolean;
25
- /** is there an ongoing buffer */
26
- isBuffering(): boolean;
27
- /** destroy the event buffer, clearing all resources */
28
- destroy(): void;
29
- };
30
- /**
31
- * The event buffer logically consolidates different events into a single event
32
- * making the data processing more efficient.
33
- */
34
- export declare const makeEventBuffer: (logger: ILogger) => BaileysBufferableEventEmitter;
35
- export {};
36
- //# sourceMappingURL=event-buffer.d.ts.map