angularsockets 1.0.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.MD +170 -0
  3. package/README.md +1 -1900
  4. package/WAProto/GenerateStatics.sh +4 -0
  5. package/WAProto/WAProto.proto +4775 -0
  6. package/WAProto/index.d.ts +4798 -124
  7. package/WAProto/index.js +14270 -302
  8. package/WAProto/index.ts.ts +53473 -0
  9. package/engine-requirements.js +10 -0
  10. package/lib/Defaults/baileys-version.json +1 -1
  11. package/lib/Defaults/index.d.ts +4 -6
  12. package/lib/Defaults/index.js +4 -6
  13. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  14. package/lib/Signal/Group/ciphertext-message.js +15 -0
  15. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  16. package/lib/Signal/Group/group-session-builder.js +64 -0
  17. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  18. package/lib/Signal/Group/group_cipher.js +96 -0
  19. package/lib/Signal/Group/index.d.ts +11 -0
  20. package/lib/Signal/Group/index.js +57 -0
  21. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  22. package/lib/Signal/Group/keyhelper.js +55 -0
  23. package/lib/Signal/Group/queue-job.d.ts +1 -0
  24. package/lib/Signal/Group/queue-job.js +57 -0
  25. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  26. package/lib/Signal/Group/sender-chain-key.js +34 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  28. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  29. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  30. package/lib/Signal/Group/sender-key-message.js +69 -0
  31. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  32. package/lib/Signal/Group/sender-key-name.js +51 -0
  33. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  34. package/lib/Signal/Group/sender-key-record.js +53 -0
  35. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  36. package/lib/Signal/Group/sender-key-state.js +99 -0
  37. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  38. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  39. package/lib/Signal/libsignal.js +51 -29
  40. package/lib/Socket/Client/index.d.ts +2 -3
  41. package/lib/Socket/Client/index.js +2 -3
  42. package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -2
  43. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +2 -1
  44. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
  45. package/lib/Socket/RHandler.d.ts +416 -0
  46. package/lib/Socket/RHandler.js +530 -0
  47. package/lib/Socket/business.d.ts +39 -37
  48. package/lib/Socket/chats.d.ts +36 -23
  49. package/lib/Socket/chats.js +74 -116
  50. package/lib/Socket/groups.d.ts +42 -33
  51. package/lib/Socket/groups.js +26 -9
  52. package/lib/Socket/index.d.ts +39 -39
  53. package/lib/Socket/index.js +2 -2
  54. package/lib/Socket/messages-recv.d.ts +37 -34
  55. package/lib/Socket/messages-recv.js +111 -29
  56. package/lib/Socket/messages-send.d.ts +50 -53
  57. package/lib/Socket/messages-send.js +213 -397
  58. package/lib/Socket/newsletter.d.ts +25 -21
  59. package/lib/Socket/newsletter.js +92 -25
  60. package/lib/Socket/socket.d.ts +10 -11
  61. package/lib/Socket/socket.js +34 -23
  62. package/lib/Socket/usync.d.ts +11 -12
  63. package/lib/Store/index.d.ts +1 -2
  64. package/lib/Store/index.js +1 -3
  65. package/lib/Store/make-in-memory-store.d.ts +22 -22
  66. package/lib/Store/make-in-memory-store.js +21 -13
  67. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  68. package/lib/Types/Auth.d.ts +0 -6
  69. package/lib/Types/Chat.d.ts +6 -4
  70. package/lib/Types/Contact.d.ts +5 -1
  71. package/lib/Types/Events.d.ts +27 -0
  72. package/lib/Types/GroupMetadata.d.ts +8 -0
  73. package/lib/Types/Label.d.ts +0 -11
  74. package/lib/Types/Message.d.ts +59 -90
  75. package/lib/Types/Message.js +0 -2
  76. package/lib/Types/Newsletter.d.ts +97 -86
  77. package/lib/Types/Newsletter.js +38 -32
  78. package/lib/Types/Socket.d.ts +10 -7
  79. package/lib/Types/index.d.ts +1 -3
  80. package/lib/Types/index.js +1 -1
  81. package/lib/Utils/audioToBuffer.js +29 -0
  82. package/lib/Utils/auth-utils.d.ts +3 -3
  83. package/lib/Utils/auth-utils.js +13 -41
  84. package/lib/Utils/business.d.ts +1 -1
  85. package/lib/Utils/chat-utils.d.ts +12 -12
  86. package/lib/Utils/chat-utils.js +4 -19
  87. package/lib/Utils/crypto.d.ts +15 -15
  88. package/lib/Utils/crypto.js +6 -12
  89. package/lib/Utils/decode-wa-message.d.ts +5 -6
  90. package/lib/Utils/decode-wa-message.js +28 -55
  91. package/lib/Utils/event-buffer.d.ts +2 -2
  92. package/lib/Utils/event-buffer.js +2 -1
  93. package/lib/Utils/generics.d.ts +12 -11
  94. package/lib/Utils/generics.js +64 -38
  95. package/lib/Utils/history.d.ts +2 -2
  96. package/lib/Utils/history.js +1 -1
  97. package/lib/Utils/index.d.ts +2 -0
  98. package/lib/Utils/index.js +3 -0
  99. package/lib/Utils/link-preview.d.ts +2 -2
  100. package/lib/Utils/link-preview.js +34 -1
  101. package/lib/Utils/logger.d.ts +10 -1
  102. package/lib/Utils/lt-hash.d.ts +2 -2
  103. package/lib/Utils/lt-hash.js +6 -6
  104. package/lib/Utils/messages-media.d.ts +40 -29
  105. package/lib/Utils/messages-media.js +276 -110
  106. package/lib/Utils/messages.d.ts +8 -10
  107. package/lib/Utils/messages.js +126 -317
  108. package/lib/Utils/noise-handler.d.ts +10 -11
  109. package/lib/Utils/noise-handler.js +3 -13
  110. package/lib/Utils/process-message.d.ts +3 -2
  111. package/lib/Utils/process-message.js +17 -5
  112. package/lib/Utils/signal.js +2 -8
  113. package/lib/Utils/streamToBuffer.js +15 -0
  114. package/lib/Utils/use-multi-file-auth-state.js +72 -242
  115. package/lib/Utils/validate-connection.d.ts +2 -3
  116. package/lib/Utils/validate-connection.js +19 -51
  117. package/lib/WABinary/constants.d.ts +4 -4
  118. package/lib/WABinary/constants.js +1276 -13
  119. package/lib/WABinary/decode.d.ts +2 -2
  120. package/lib/WABinary/decode.js +3 -2
  121. package/lib/WABinary/encode.js +5 -7
  122. package/lib/WABinary/generic-utils.d.ts +2 -2
  123. package/lib/WABinary/jid-utils.d.ts +9 -4
  124. package/lib/WABinary/jid-utils.js +26 -5
  125. package/lib/WABinary/jid-utils.js.bak +83 -0
  126. package/lib/WAM/encode.d.ts +1 -1
  127. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  128. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  129. package/lib/WAUSync/USyncUser.d.ts +2 -0
  130. package/lib/index.d.ts +16 -0
  131. package/lib/index.js +48 -4
  132. package/lib/index.js.bak +56 -0
  133. package/package.json +43 -35
  134. package/WASignalGroup/GroupProtocol.js +0 -1697
  135. package/WASignalGroup/ciphertext_message.js +0 -16
  136. package/WASignalGroup/group_cipher.js +0 -120
  137. package/WASignalGroup/group_session_builder.js +0 -46
  138. package/WASignalGroup/index.js +0 -5
  139. package/WASignalGroup/keyhelper.js +0 -21
  140. package/WASignalGroup/protobufs.js +0 -3
  141. package/WASignalGroup/queue_job.js +0 -69
  142. package/WASignalGroup/sender_chain_key.js +0 -50
  143. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  144. package/WASignalGroup/sender_key_message.js +0 -92
  145. package/WASignalGroup/sender_key_name.js +0 -70
  146. package/WASignalGroup/sender_key_record.js +0 -56
  147. package/WASignalGroup/sender_key_state.js +0 -129
  148. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  149. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  150. package/lib/Socket/registration.d.ts +0 -264
  151. package/lib/Socket/registration.js +0 -166
  152. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  153. package/lib/Store/make-cache-manager-store.js +0 -83
  154. package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
  155. package/lib/Utils/use-single-file-auth-state.js +0 -75
  156. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -1,92 +1,103 @@
1
- import { proto } from '../../WAProto';
2
- export type NewsletterReactionMode = 'ALL' | 'BASIC' | 'NONE';
3
- export type NewsletterState = 'ACTIVE' | 'GEOSUSPENDED' | 'SUSPENDED';
4
- export type NewsletterVerification = 'VERIFIED' | 'UNVERIFIED';
5
- export type NewsletterMute = 'ON' | 'OFF' | 'UNDEFINED';
6
- export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
1
+ import { proto } from "../../WAProto"
2
+
3
+ export type NewsletterReactionMode = "ALL" | "BASIC" | "NONE"
4
+ export type NewsletterState = "ACTIVE" | "GEOSUSPENDED" | "SUSPENDED"
5
+ export type NewsletterVerification = "VERIFIED" | "UNVERIFIED"
6
+ export type NewsletterMute = "ON" | "OFF" | "UNDEFINED"
7
+ export type NewsletterViewRole = "ADMIN" | "GUEST" | "OWNER" | "SUBSCRIBER"
8
+
7
9
  export type NewsletterViewerMetadata = {
8
- mute: NewsletterMute;
9
- view_role: NewsletterViewRole;
10
- };
10
+ mute: NewsletterMute
11
+ view_role: NewsletterViewRole
12
+ }
13
+
11
14
  export type NewsletterMetadata = {
12
- /**jid of newsletter */
13
- id: string;
14
- /**state of newsletter */
15
- state: NewsletterState;
16
- /**creation timestamp of newsletter */
17
- creation_time: number;
18
- /**name of newsletter */
19
- name: string;
20
- /**timestamp of last name modification of newsletter */
21
- nameTime: number;
22
- /**description of newsletter */
23
- description: string;
24
- /**timestamp of last description modification of newsletter */
25
- descriptionTime: number;
26
- /**invite code of newsletter */
27
- invite: string;
28
- /**i dont know */
29
- handle: null;
30
- /**direct path of picture */
31
- picture: string | null;
32
- /**direct path of picture preview (lower quality) */
33
- preview: string | null;
34
- /**reaction mode of newsletter */
35
- reaction_codes?: NewsletterReactionMode;
36
- /**subscribers count of newsletter */
37
- subscribers: number;
38
- /**verification state of newsletter */
39
- verification: NewsletterVerification;
40
- /**viewer metadata */
41
- viewer_metadata: NewsletterViewerMetadata;
42
- };
43
- export type SubscriberAction = 'promote' | 'demote';
15
+ /** jid of newsletter */
16
+ id: string
17
+ /** state of newsletter */
18
+ state: NewsletterState
19
+ /** creation timestamp of newsletter */
20
+ creation_time: number
21
+ /** name of newsletter */
22
+ name: string
23
+ /** timestamp of last name modification of newsletter */
24
+ nameTime: number
25
+ /** description of newsletter */
26
+ description: string
27
+ /** timestamp of last description modification of newsletter */
28
+ descriptionTime: number
29
+ /** invite code of newsletter */
30
+ invite: string
31
+ /** direct path of picture */
32
+ picture: string | null
33
+ /** direct path of picture preview (lower quality) */
34
+ preview: string | null
35
+ /** reaction mode of newsletter */
36
+ reaction_codes?: NewsletterReactionMode
37
+ /** subscribers count of newsletter */
38
+ subscribers: number
39
+ /** verification state of newsletter */
40
+ verification: NewsletterVerification
41
+ /** viewer metadata */
42
+ viewer_metadata: NewsletterViewerMetadata
43
+ }
44
+
45
+ export type SubscriberAction = "promote" | "demote"
46
+
44
47
  export type ReactionModeUpdate = {
45
- reaction_codes: {
46
- blocked_codes: null;
47
- enabled_ts_sec: null;
48
- value: NewsletterReactionMode;
49
- };
50
- };
51
- /**only exists reaction mode update */
52
- export type NewsletterSettingsUpdate = ReactionModeUpdate;
53
- export type NewsletterReaction = {
54
- count: number;
55
- code: string;
56
- };
57
- export type NewsletterFetchedUpdate = {
58
- /**id of message in newsletter, starts from 100 */
59
- server_id: string;
60
- /**count of views in this message */
61
- views?: number;
62
- /**reactions in this message */
63
- reactions: NewsletterReaction[];
64
- /**the message, if you requested only updates, you will not receive message */
65
- message?: proto.IWebMessageInfo;
66
- };
67
- export declare enum MexOperations {
68
- PROMOTE = "NotificationNewsletterAdminPromote",
69
- DEMOTE = "NotificationNewsletterAdminDemote",
70
- UPDATE = "NotificationNewsletterUpdate"
48
+ reaction_codes: {
49
+ blocked_codes: null
50
+ enabled_ts_sec: null
51
+ value: NewsletterReactionMode
52
+ }
71
53
  }
72
- export declare enum XWAPaths {
73
- PROMOTE = "xwa2_notify_newsletter_admin_promote",
74
- DEMOTE = "xwa2_notify_newsletter_admin_demote",
75
- ADMIN_COUNT = "xwa2_newsletter_admin",
76
- CREATE = "xwa2_newsletter_create",
77
- NEWSLETTER = "xwa2_newsletter",
78
- METADATA_UPDATE = "xwa2_notify_newsletter_on_metadata_update"
54
+
55
+ /** only exists reaction mode update */
56
+ export type NewsletterSettingsUpdate = ReactionModeUpdate
57
+
58
+ export type NewsletterReaction = {
59
+ count: number
60
+ code: string
79
61
  }
80
- export declare enum QueryIds {
81
- JOB_MUTATION = "7150902998257522",
82
- METADATA = "6620195908089573",
83
- UNFOLLOW = "7238632346214362",
84
- FOLLOW = "7871414976211147",
85
- UNMUTE = "7337137176362961",
86
- MUTE = "25151904754424642",
87
- CREATE = "6996806640408138",
88
- ADMIN_COUNT = "7130823597031706",
89
- CHANGE_OWNER = "7341777602580933",
90
- DELETE = "8316537688363079",
91
- DEMOTE = "6551828931592903"
62
+
63
+ export type NewsletterFetchedUpdate = {
64
+ /** id of message in newsletter, starts from 100 */
65
+ server_id: string
66
+ /** count of views in this message */
67
+ views?: number
68
+ /** reactions in this message */
69
+ reactions: NewsletterReaction[]
70
+ /** the message, if you requested only updates, you will not receive message */
71
+ message?: proto.IWebMessageInfo
92
72
  }
73
+
74
+ export const MexOperations = {
75
+ PROMOTE: "NotificationNewsletterAdminPromote",
76
+ DEMOTE: "NotificationNewsletterAdminDemote",
77
+ UPDATE: "NotificationNewsletterUpdate"
78
+ } as const
79
+
80
+ export const XWAPaths = {
81
+ PROMOTE: "xwa2_notify_newsletter_admin_promote",
82
+ DEMOTE: "xwa2_notify_newsletter_admin_demote",
83
+ ADMIN_COUNT: "xwa2_newsletter_admin",
84
+ CREATE: "xwa2_newsletter_create",
85
+ NEWSLETTER: "xwa2_newsletter",
86
+ SUBSCRIBED: "xwa2_newsletter_subscribed",
87
+ METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
88
+ } as const
89
+
90
+ export const QueryIds = {
91
+ JOB_MUTATION: "7150902998257522",
92
+ METADATA: "6620195908089573",
93
+ UNFOLLOW: "7238632346214362",
94
+ FOLLOW: "7871414976211147",
95
+ UNMUTE: "7337137176362961",
96
+ MUTE: "25151904754424642",
97
+ CREATE: "6996806640408138",
98
+ ADMIN_COUNT: "7130823597031706",
99
+ CHANGE_OWNER: "7341777602580933",
100
+ DELETE: "8316537688363079",
101
+ DEMOTE: "6551828931592903",
102
+ SUBSCRIBED: "6388546374527196"
103
+ } as const
@@ -1,32 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryIds = exports.XWAPaths = exports.MexOperations = void 0;
4
- var MexOperations;
5
- (function (MexOperations) {
6
- MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
- MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
- MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
- })(MexOperations || (exports.MexOperations = MexOperations = {}));
10
- var XWAPaths;
11
- (function (XWAPaths) {
12
- XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
13
- XWAPaths["DEMOTE"] = "xwa2_notify_newsletter_admin_demote";
14
- XWAPaths["ADMIN_COUNT"] = "xwa2_newsletter_admin";
15
- XWAPaths["CREATE"] = "xwa2_newsletter_create";
16
- XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
17
- XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
18
- })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
19
- var QueryIds;
20
- (function (QueryIds) {
21
- QueryIds["JOB_MUTATION"] = "7150902998257522";
22
- QueryIds["METADATA"] = "6620195908089573";
23
- QueryIds["UNFOLLOW"] = "7238632346214362";
24
- QueryIds["FOLLOW"] = "7871414976211147";
25
- QueryIds["UNMUTE"] = "7337137176362961";
26
- QueryIds["MUTE"] = "25151904754424642";
27
- QueryIds["CREATE"] = "6996806640408138";
28
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
29
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
- QueryIds["DELETE"] = "8316537688363079";
31
- QueryIds["DEMOTE"] = "6551828931592903";
32
- })(QueryIds || (exports.QueryIds = QueryIds = {}));
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const MexOperations = {
6
+ PROMOTE: "NotificationNewsletterAdminPromote",
7
+ DEMOTE: "NotificationNewsletterAdminDemote",
8
+ UPDATE: "NotificationNewsletterUpdate"
9
+ }
10
+
11
+ const XWAPaths = {
12
+ PROMOTE: "xwa2_notify_newsletter_admin_promote",
13
+ DEMOTE: "xwa2_notify_newsletter_admin_demote",
14
+ ADMIN_COUNT: "xwa2_newsletter_admin",
15
+ CREATE: "xwa2_newsletter_create",
16
+ NEWSLETTER: "xwa2_newsletter",
17
+ SUBSCRIBED: "xwa2_newsletter_subscribed",
18
+ METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
19
+ }
20
+
21
+ const QueryIds = {
22
+ JOB_MUTATION: "7150902998257522",
23
+ METADATA: "6620195908089573",
24
+ UNFOLLOW: "7238632346214362",
25
+ FOLLOW: "7871414976211147",
26
+ UNMUTE: "7337137176362961",
27
+ MUTE: "25151904754424642",
28
+ CREATE: "6996806640408138",
29
+ ADMIN_COUNT: "7130823597031706",
30
+ CHANGE_OWNER: "7341777602580933",
31
+ DELETE: "8316537688363079",
32
+ DEMOTE: "6551828931592903",
33
+ SUBSCRIBED: "6388546374527196"
34
+ }
35
+
36
+ exports.MexOperations = MexOperations
37
+ exports.XWAPaths = XWAPaths
38
+ exports.QueryIds = QueryIds
@@ -1,12 +1,12 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import type { Agent } from 'https';
3
- import type { Logger } from 'pino';
4
3
  import type { URL } from 'url';
5
4
  import { proto } from '../../WAProto';
6
5
  import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
7
6
  import { GroupMetadata } from './GroupMetadata';
8
7
  import { MediaConnInfo } from './Message';
9
8
  import { SignalRepository } from './Signal';
9
+ import { ILogger } from '../Utils/logger';
10
10
  export type WAVersion = [number, number, number];
11
11
  export type WABrowserDescription = [string, string, string];
12
12
  export type CacheStore = {
@@ -19,6 +19,9 @@ export type CacheStore = {
19
19
  /** flush all data */
20
20
  flushAll(): void;
21
21
  };
22
+ export type PatchedMessageWithRecipientJID = proto.IMessage & {
23
+ recipientJid?: string;
24
+ };
22
25
  export type SocketConfig = {
23
26
  /** the WS url to connect to WA */
24
27
  waWebSocketUrl: string | URL;
@@ -28,12 +31,14 @@ export type SocketConfig = {
28
31
  defaultQueryTimeoutMs: number | undefined;
29
32
  /** ping-pong interval for WS connection */
30
33
  keepAliveIntervalMs: number;
31
- /** should baileys use the mobile api instead of the multi device api */
34
+ /** should baileys use the mobile api instead of the multi device api
35
+ * @deprecated This feature has been removed
36
+ */
32
37
  mobile?: boolean;
33
38
  /** proxy agent */
34
39
  agent?: Agent;
35
- /** pino logger */
36
- logger: Logger;
40
+ /** logger */
41
+ logger: ILogger;
37
42
  /** version to connect with */
38
43
  version: WAVersion;
39
44
  /** override browser config */
@@ -94,7 +99,7 @@ export type SocketConfig = {
94
99
  /**
95
100
  * Optionally patch the message before sending out
96
101
  * */
97
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
102
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
98
103
  /** verify app state MACs */
99
104
  appStateMacVerification: {
100
105
  patch: boolean;
@@ -111,6 +116,4 @@ export type SocketConfig = {
111
116
  /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
112
117
  cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
113
118
  makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
114
- /** Socket passthrough */
115
- socket?: any;
116
119
  };
@@ -1,10 +1,10 @@
1
1
  export * from './Auth';
2
2
  export * from './GroupMetadata';
3
+ export * from './Newsletter';
3
4
  export * from './Chat';
4
5
  export * from './Contact';
5
6
  export * from './State';
6
7
  export * from './Message';
7
- export * from './Newsletter';
8
8
  export * from './Socket';
9
9
  export * from './Events';
10
10
  export * from './Product';
@@ -20,8 +20,6 @@ export type BrowsersMap = {
20
20
  macOS(browser: string): [string, string, string];
21
21
  baileys(browser: string): [string, string, string];
22
22
  windows(browser: string): [string, string, string];
23
- iOS(browser: string): [string, string, string];
24
- linux(browser: string): [string, string, string];
25
23
  appropriate(browser: string): [string, string, string];
26
24
  };
27
25
  export declare enum DisconnectReason {
@@ -17,11 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.DisconnectReason = void 0;
18
18
  __exportStar(require("./Auth"), exports);
19
19
  __exportStar(require("./GroupMetadata"), exports);
20
+ __exportStar(require("./Newsletter"), exports);
20
21
  __exportStar(require("./Chat"), exports);
21
22
  __exportStar(require("./Contact"), exports);
22
23
  __exportStar(require("./State"), exports);
23
24
  __exportStar(require("./Message"), exports);
24
- __exportStar(require("./Newsletter"), exports);
25
25
  __exportStar(require("./Socket"), exports);
26
26
  __exportStar(require("./Events"), exports);
27
27
  __exportStar(require("./Product"), exports);
@@ -0,0 +1,29 @@
1
+ const { Buffer } = require("buffer")
2
+ const fs = require("fs/promises")
3
+ const { Readable } = require("stream")
4
+ const streamToBuffer = require("./streamToBuffer")
5
+
6
+ /**
7
+ * Mengonversi berbagai input audio (Buffer, URL, path file, atau Readable stream) menjadi Buffer.
8
+ * @param {Buffer|string|Readable} audio Input audio.
9
+ * @returns {Promise<Buffer>} Buffer hasil konversi.
10
+ */
11
+ async function audioToBuffer(audio) {
12
+ if (Buffer.isBuffer(audio)) {
13
+ return audio
14
+ }
15
+
16
+ if (typeof audio === "string") {
17
+ if (/^https?:\/\//.test(audio)) {
18
+ const res = await fetch(audio) // native fetch bawaan Node 20
19
+ return Buffer.from(await res.arrayBuffer())
20
+ }
21
+ return fs.readFile(audio)
22
+ }
23
+
24
+ if (audio instanceof Readable) {
25
+ return streamToBuffer(audio)
26
+ }
27
+
28
+ throw new TypeError("Unsupported audio input type")
29
+ }
@@ -1,12 +1,12 @@
1
- import type { Logger } from 'pino';
2
1
  import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
2
+ import { ILogger } from './logger';
3
3
  /**
4
4
  * Adds caching capability to a SignalKeyStore
5
5
  * @param store the store to add caching to
6
6
  * @param logger to log trace events
7
7
  * @param _cache cache store to use
8
8
  */
9
- export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger: Logger, _cache?: CacheStore): SignalKeyStore;
9
+ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger?: ILogger, _cache?: CacheStore): SignalKeyStore;
10
10
  /**
11
11
  * Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
12
12
  * this allows batch read & write operations & improves the performance of the lib
@@ -14,5 +14,5 @@ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logge
14
14
  * @param logger logger to log events
15
15
  * @returns SignalKeyStore with transaction capability
16
16
  */
17
- export declare const addTransactionCapability: (state: SignalKeyStore, logger: Logger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
17
+ export declare const addTransactionCapability: (state: SignalKeyStore, logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
18
18
  export declare const initAuthCreds: () => AuthenticationCreds;
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.initAuthCreds = exports.addTransactionCapability = void 0;
7
7
  exports.makeCacheableSignalKeyStore = makeCacheableSignalKeyStore;
8
8
  const crypto_1 = require("crypto");
9
- const node_cache_1 = __importDefault(require("node-cache"));
10
- const uuid_1 = require("uuid");
9
+ const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
11
10
  const Defaults_1 = require("../Defaults");
12
11
  const crypto_2 = require("./crypto");
13
12
  const generics_1 = require("./generics");
@@ -19,30 +18,9 @@ const generics_1 = require("./generics");
19
18
  */
20
19
  function makeCacheableSignalKeyStore(store, logger, _cache) {
21
20
  const cache = _cache || new node_cache_1.default({
22
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
23
- useClones: false,
24
- deleteOnExpire: true,
25
- checkperiod: 120
26
- });
27
-
28
- cache.on('expired', async (key) => {
29
- const [type, id] = key.split('.');
30
- const item = cache.get(key, { noUpdate: true });
31
- if (item) {
32
- try {
33
- await store.set({
34
- [type]: {
35
- [id]: item
36
- }
37
- });
38
- cache.del(key);
39
- } catch (error) {
40
- logger?.error({
41
- key
42
- }, 'Failed to persist expired cache item');
43
- cache.ttl(key, 60);
44
- }
45
- }
21
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
22
+ useClones: false,
23
+ deleteOnExpire: true,
46
24
  });
47
25
  function getUniqueId(type, id) {
48
26
  return `${type}.${id}`;
@@ -52,7 +30,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
52
30
  const data = {};
53
31
  const idsToFetch = [];
54
32
  for (const id of ids) {
55
- const item = cache.get(getUniqueId(type, id), { noUpdate: true });
33
+ const item = cache.get(getUniqueId(type, id));
56
34
  if (typeof item !== 'undefined') {
57
35
  data[id] = item;
58
36
  }
@@ -61,7 +39,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
61
39
  }
62
40
  }
63
41
  if (idsToFetch.length) {
64
- logger?.trace({ items: idsToFetch.length }, 'loading from store');
42
+ logger === null || logger === void 0 ? void 0 : logger.trace({ items: idsToFetch.length }, 'loading from store');
65
43
  const fetched = await store.get(type, idsToFetch);
66
44
  for (const id of idsToFetch) {
67
45
  const item = fetched[id];
@@ -81,7 +59,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
81
59
  keys += 1;
82
60
  }
83
61
  }
84
- logger?.trace({ keys }, 'updated cache');
62
+ logger === null || logger === void 0 ? void 0 : logger.trace({ keys }, 'updated cache');
85
63
  await store.set(data);
86
64
  },
87
65
  async clear() {
@@ -134,7 +112,7 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
134
112
  },
135
113
  set: data => {
136
114
  if (isInTransaction()) {
137
- logger?.trace({ types: Object.keys(data) }, 'caching in transaction');
115
+ logger.trace({ types: Object.keys(data) }, 'caching in transaction');
138
116
  for (const key in data) {
139
117
  transactionCache[key] = transactionCache[key] || {};
140
118
  Object.assign(transactionCache[key], data[key]);
@@ -151,14 +129,14 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
151
129
  let result;
152
130
  transactionsInProgress += 1;
153
131
  if (transactionsInProgress === 1) {
154
- logger?.trace('entering transaction');
132
+ logger.trace('entering transaction');
155
133
  }
156
134
  try {
157
135
  result = await work();
158
136
  // commit if this is the outermost transaction
159
137
  if (transactionsInProgress === 1) {
160
138
  if (Object.keys(mutations).length) {
161
- logger?.trace('committing transaction');
139
+ logger.trace('committing transaction');
162
140
  // retry mechanism to ensure we've some recovery
163
141
  // in case a transaction fails in the first attempt
164
142
  let tries = maxCommitRetries;
@@ -166,17 +144,17 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
166
144
  tries -= 1;
167
145
  try {
168
146
  await state.set(mutations);
169
- logger?.trace({ dbQueriesInTransaction }, 'committed transaction');
147
+ logger.trace({ dbQueriesInTransaction }, 'committed transaction');
170
148
  break;
171
149
  }
172
150
  catch (error) {
173
- logger?.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`);
151
+ logger.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`);
174
152
  await (0, generics_1.delay)(delayBetweenTriesMs);
175
153
  }
176
154
  }
177
155
  }
178
156
  else {
179
- logger?.trace('no mutations in transaction');
157
+ logger.trace('no mutations in transaction');
180
158
  }
181
159
  }
182
160
  }
@@ -212,13 +190,7 @@ const initAuthCreds = () => {
212
190
  accountSettings: {
213
191
  unarchiveChats: false
214
192
  },
215
- // mobile creds
216
- deviceId: Buffer.from((0, uuid_1.v4)().replace(/-/g, ''), 'hex').toString('base64url'),
217
- phoneId: (0, uuid_1.v4)(),
218
- identityId: (0, crypto_1.randomBytes)(20),
219
193
  registered: false,
220
- backupToken: (0, crypto_1.randomBytes)(20),
221
- registration: {},
222
194
  pairingCode: undefined,
223
195
  lastPropHash: undefined,
224
196
  routingInfo: undefined,
@@ -2,7 +2,7 @@ import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate,
2
2
  import { BinaryNode } from '../WABinary';
3
3
  export declare const parseCatalogNode: (node: BinaryNode) => {
4
4
  products: Product[];
5
- nextPageCursor: any;
5
+ nextPageCursor: string | undefined;
6
6
  };
7
7
  export declare const parseCollectionsNode: (node: BinaryNode) => {
8
8
  collections: CatalogCollection[];
@@ -1,8 +1,8 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import type { Logger } from 'pino';
3
2
  import { proto } from '../../WAProto';
4
3
  import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
5
4
  import { BinaryNode } from '../WABinary';
5
+ import { ILogger } from './logger';
6
6
  type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
7
7
  export type ChatMutationMap = {
8
8
  [index: string]: ChatMutation;
@@ -13,7 +13,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
13
13
  state: LTHashState;
14
14
  }>;
15
15
  export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
16
- hash: any;
16
+ hash: Buffer<any>;
17
17
  indexValueMap: {
18
18
  [indexMacBase64: string]: {
19
19
  valueMac: Uint8Array | Buffer;
@@ -21,30 +21,30 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
21
21
  };
22
22
  }>;
23
23
  export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
24
- hash: any;
24
+ hash: Buffer<any>;
25
25
  indexValueMap: {
26
26
  [indexMacBase64: string]: {
27
27
  valueMac: Uint8Array | Buffer;
28
28
  };
29
29
  };
30
30
  }>;
31
- export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
32
- critical_block: {
31
+ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
32
+ critical_unblock_low: {
33
33
  patches: proto.ISyncdPatch[];
34
34
  hasMorePatches: boolean;
35
35
  snapshot?: proto.ISyncdSnapshot;
36
36
  };
37
- critical_unblock_low: {
37
+ regular_high: {
38
38
  patches: proto.ISyncdPatch[];
39
39
  hasMorePatches: boolean;
40
40
  snapshot?: proto.ISyncdSnapshot;
41
41
  };
42
- regular_high: {
42
+ regular_low: {
43
43
  patches: proto.ISyncdPatch[];
44
44
  hasMorePatches: boolean;
45
45
  snapshot?: proto.ISyncdSnapshot;
46
46
  };
47
- regular_low: {
47
+ critical_block: {
48
48
  patches: proto.ISyncdPatch[];
49
49
  hasMorePatches: boolean;
50
50
  snapshot?: proto.ISyncdSnapshot;
@@ -55,16 +55,16 @@ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosReq
55
55
  snapshot?: proto.ISyncdSnapshot;
56
56
  };
57
57
  }>;
58
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<any>;
59
- export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>;
58
+ export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer<ArrayBuffer>>;
59
+ export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
60
60
  export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
61
61
  state: LTHashState;
62
62
  mutationMap: ChatMutationMap;
63
63
  }>;
64
- export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
64
+ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: ILogger, validateMacs?: boolean) => Promise<{
65
65
  state: LTHashState;
66
66
  mutationMap: ChatMutationMap;
67
67
  }>;
68
68
  export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
69
- export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
69
+ export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void;
70
70
  export {};