@oxidezap/baileyrs 0.3.6 → 0.3.8

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 (130) hide show
  1. package/README.md +67 -8
  2. package/lib/Bridge/history-sync-wire.d.ts +2 -2
  3. package/lib/Bridge/history-sync-wire.js +4 -4
  4. package/lib/Bridge/schema.js +7 -1
  5. package/lib/Bridge/types.d.ts +7 -1
  6. package/lib/Compatibility/auth-state.d.ts +30 -0
  7. package/lib/Compatibility/auth-state.js +96 -0
  8. package/lib/Compatibility/encode-proto-core.d.ts +31 -0
  9. package/lib/Compatibility/encode-proto-core.js +51 -0
  10. package/lib/Compatibility/encode-proto.d.ts +0 -19
  11. package/lib/Compatibility/encode-proto.js +3 -35
  12. package/lib/Compatibility/host-auth-state.d.ts +6 -0
  13. package/lib/Compatibility/host-auth-state.js +162 -0
  14. package/lib/Compatibility/internal/auth-state.d.ts +3 -7
  15. package/lib/Compatibility/internal/auth-state.js +34 -1
  16. package/lib/Compatibility/internal/host-auth-state.d.ts +4 -0
  17. package/lib/Compatibility/internal/host-auth-state.js +14 -0
  18. package/lib/Compatibility/legacy-store/device.js +5 -5
  19. package/lib/Compatibility/message-ids.d.ts +17 -0
  20. package/lib/Compatibility/message-ids.js +47 -0
  21. package/lib/Compatibility/message-relay.d.ts +2 -2
  22. package/lib/Compatibility/message-relay.js +4 -4
  23. package/lib/Compatibility/proto-runtime.d.ts +5 -0
  24. package/lib/Compatibility/proto-runtime.js +214 -32
  25. package/lib/Compatibility/socket-results.d.ts +1 -1
  26. package/lib/Compatibility/tagged-message-waiter.d.ts +5 -2
  27. package/lib/Compatibility/tagged-message-waiter.js +5 -5
  28. package/lib/Compatibility/usync/adapter.d.ts +1 -1
  29. package/lib/Compatibility/websocket-client.d.ts +11 -3
  30. package/lib/Compatibility/websocket-client.js +84 -11
  31. package/lib/Defaults/index.d.ts +8 -8
  32. package/lib/Defaults/index.js +8 -8
  33. package/lib/Media/content.d.ts +28 -0
  34. package/lib/Media/content.js +129 -0
  35. package/lib/Media/core.d.ts +34 -0
  36. package/lib/Media/core.js +120 -0
  37. package/lib/Media/mutations.d.ts +24 -0
  38. package/lib/Media/mutations.js +38 -0
  39. package/lib/Runtime/aes-gcm.d.ts +4 -0
  40. package/lib/Runtime/aes-gcm.js +11 -0
  41. package/lib/Runtime/bridge.d.ts +44 -0
  42. package/lib/Runtime/bridge.js +76 -0
  43. package/lib/Runtime/buffer.d.ts +9 -0
  44. package/lib/Runtime/buffer.js +22 -0
  45. package/lib/Runtime/bytes.d.ts +61 -0
  46. package/lib/Runtime/bytes.js +270 -0
  47. package/lib/Runtime/host.d.ts +22 -0
  48. package/lib/Runtime/host.js +43 -0
  49. package/lib/Runtime/long.d.ts +33 -0
  50. package/lib/Runtime/long.js +64 -0
  51. package/lib/Runtime/node-media-processors.d.ts +4 -0
  52. package/lib/Runtime/node-media-processors.js +29 -0
  53. package/lib/Runtime/node-media.d.ts +28 -0
  54. package/lib/Runtime/node-media.js +115 -0
  55. package/lib/Runtime/node.d.ts +14 -0
  56. package/lib/Runtime/node.js +81 -0
  57. package/lib/Runtime/paths.d.ts +4 -0
  58. package/lib/Runtime/paths.js +7 -0
  59. package/lib/Runtime/stream.d.ts +11 -0
  60. package/lib/Runtime/stream.js +25 -0
  61. package/lib/Runtime/types.d.ts +98 -0
  62. package/lib/Runtime/types.js +13 -0
  63. package/lib/Socket/core.d.ts +312 -0
  64. package/lib/Socket/core.js +1122 -0
  65. package/lib/Socket/events-core.d.ts +75 -0
  66. package/lib/Socket/events-core.js +1058 -0
  67. package/lib/Socket/events.d.ts +1 -63
  68. package/lib/Socket/events.js +4 -1047
  69. package/lib/Socket/groups.js +4 -3
  70. package/lib/Socket/index.d.ts +521 -103
  71. package/lib/Socket/index.js +10 -1007
  72. package/lib/Socket/messages-core.d.ts +41 -0
  73. package/lib/Socket/messages-core.js +270 -0
  74. package/lib/Socket/messages.d.ts +9 -36
  75. package/lib/Socket/messages.js +3 -260
  76. package/lib/Socket/newsletter.js +3 -3
  77. package/lib/Socket/profile.js +1 -1
  78. package/lib/Socket/terminal-close-reporter.d.ts +2 -0
  79. package/lib/Socket/terminal-close-reporter.js +3 -3
  80. package/lib/Socket/transport.d.ts +2 -0
  81. package/lib/Socket/transport.js +16 -1
  82. package/lib/Socket/types.d.ts +2 -0
  83. package/lib/Types/Auth.d.ts +11 -0
  84. package/lib/Types/Message.d.ts +1 -1
  85. package/lib/Types/Socket.d.ts +2 -2
  86. package/lib/Types/index.d.ts +6 -1
  87. package/lib/Utils/browser-utils.d.ts +4 -0
  88. package/lib/Utils/browser-utils.js +53 -2
  89. package/lib/Utils/crypto.d.ts +1 -0
  90. package/lib/Utils/crypto.js +1 -0
  91. package/lib/Utils/event-buffer.d.ts +6 -1
  92. package/lib/Utils/event-buffer.js +28 -27
  93. package/lib/Utils/link-preview.d.ts +4 -3
  94. package/lib/Utils/logger.d.ts +3 -0
  95. package/lib/Utils/logger.js +35 -6
  96. package/lib/Utils/messages-core.d.ts +174 -0
  97. package/lib/Utils/messages-core.js +1042 -0
  98. package/lib/Utils/messages-media-core.d.ts +73 -0
  99. package/lib/Utils/messages-media-core.js +319 -0
  100. package/lib/Utils/messages-media.d.ts +1 -72
  101. package/lib/Utils/messages-media.js +9 -358
  102. package/lib/Utils/messages.d.ts +1 -166
  103. package/lib/Utils/messages.js +7 -1040
  104. package/lib/Utils/optional-peer.js +14 -5
  105. package/lib/Utils/process-history-message-core.d.ts +36 -0
  106. package/lib/Utils/process-history-message-core.js +187 -0
  107. package/lib/Utils/process-history-message.d.ts +5 -43
  108. package/lib/Utils/process-history-message.js +11 -197
  109. package/lib/Utils/process-message-core.d.ts +29 -0
  110. package/lib/Utils/process-message-core.js +112 -0
  111. package/lib/Utils/process-message.d.ts +4 -24
  112. package/lib/Utils/process-message.js +6 -111
  113. package/lib/WABinary/generic-utils.js +7 -5
  114. package/lib/host-shared.d.ts +74 -0
  115. package/lib/host-shared.js +15 -0
  116. package/lib/host-socket-operations.d.ts +3 -0
  117. package/lib/host-socket-operations.js +2 -0
  118. package/lib/host-surface.d.ts +21 -0
  119. package/lib/host-surface.js +35 -0
  120. package/lib/host-types.d.ts +356 -0
  121. package/lib/host-types.js +2 -0
  122. package/lib/host.d.ts +33 -0
  123. package/lib/host.js +31 -0
  124. package/lib/node-surface.d.ts +9 -0
  125. package/lib/node-surface.js +15 -0
  126. package/lib/surface.d.ts +5 -0
  127. package/lib/surface.js +6 -0
  128. package/lib/wasm.d.ts +27 -0
  129. package/lib/wasm.js +27 -0
  130. package/package.json +18 -6
@@ -0,0 +1,356 @@
1
+ import type { ILogger } from './Utils/logger.js';
2
+ import type { WAMessage } from './host-shared.js';
3
+ import type { HostSocketOperationName } from './host-socket-operations.js';
4
+ import type * as HostBridge from '@oxidezap/whatsapp-rust-bridge/host';
5
+ import type Long from 'long';
6
+ export type HostLoggerSink = (line: string, delivered: () => void) => void;
7
+ export type HostStoreCallbacks = {
8
+ get(store: string, key: string): Promise<Uint8Array | null>;
9
+ set(store: string, key: string, value: Uint8Array): Promise<void>;
10
+ delete(store: string, key: string): Promise<void>;
11
+ setMany?(store: string, entries: [key: string, value: Uint8Array][]): Promise<void>;
12
+ getMany?(store: string, keys: string[]): Promise<[key: string, value: Uint8Array][]>;
13
+ deleteMany?(store: string, keys: string[]): Promise<void>;
14
+ listKeys?(store: string, prefix?: string): Promise<string[]>;
15
+ listEntries?(store: string, prefix?: string): Promise<[key: string, value: Uint8Array][]>;
16
+ deletePrefix?(store: string, prefix: string): Promise<number>;
17
+ capabilities?: {
18
+ batch?: boolean;
19
+ enumerate?: boolean;
20
+ prefixDelete?: boolean;
21
+ };
22
+ flush?(): Promise<void>;
23
+ };
24
+ export type HostKeyPair = {
25
+ public: Uint8Array;
26
+ private: Uint8Array;
27
+ };
28
+ export type HostSignedKeyPair = {
29
+ keyPair: HostKeyPair;
30
+ signature: Uint8Array;
31
+ keyId: number;
32
+ timestampS?: number;
33
+ };
34
+ export type HostAuthenticationCreds = {
35
+ signedIdentityKey: HostKeyPair;
36
+ signedPreKey: HostSignedKeyPair;
37
+ noiseKey: HostKeyPair;
38
+ pairingEphemeralKeyPair: HostKeyPair;
39
+ registrationId: number;
40
+ advSecretKey: string;
41
+ me?: {
42
+ id: string;
43
+ lid?: string;
44
+ name?: string;
45
+ };
46
+ registered: boolean;
47
+ platform?: string;
48
+ firstUnuploadedPreKeyId: number;
49
+ nextPreKeyId: number;
50
+ accountSyncCounter: number;
51
+ accountSettings: {
52
+ unarchiveChats: boolean;
53
+ };
54
+ pairingCode?: string;
55
+ lastPropHash?: string;
56
+ routingInfo?: Uint8Array;
57
+ [key: string]: unknown;
58
+ };
59
+ /** Host auth is store-owned; legacy SignalKeyStore is intentionally absent. */
60
+ export type HostAuthenticationState = {
61
+ creds: HostAuthenticationCreds;
62
+ store: HostStoreCallbacks;
63
+ };
64
+ export type HostBridgeRuntime = Pick<typeof HostBridge, 'createWhatsAppClient' | 'initWasmEngine' | 'encodeProto' | 'decodeProto' | 'inflateZlib' | 'BinaryReader' | 'decodeMessageWireBatch' | 'decodeReceiptWireBatch' | 'decodeServerAckWireBatch' | 'decryptPollVotePayload' | 'decryptEventResponsePayload' | 'hkdf' | 'sha256' | 'aesGcm256Encrypt' | 'aesGcm256Decrypt'>;
65
+ export type HostMediaCryptoRuntime = Pick<HostBridgeRuntime, 'hkdf' | 'sha256' | 'aesGcm256Encrypt' | 'aesGcm256Decrypt'> & {
66
+ randomBytes(length: number): Uint8Array;
67
+ };
68
+ export type HostLongValue = {
69
+ low: number;
70
+ high: number;
71
+ unsigned: boolean;
72
+ toNumber(): number;
73
+ toString(radix?: number): string;
74
+ };
75
+ export type HostLongConstructor = {
76
+ new (low: number, high?: number, unsigned?: boolean): HostLongValue;
77
+ fromValue: typeof Long.fromValue;
78
+ };
79
+ export type HostRuntime = {
80
+ bridge: HostBridgeRuntime;
81
+ randomBytes: (length: number) => Uint8Array;
82
+ setTimeout: (callback: () => void, ms: number) => unknown;
83
+ clearTimeout: (handle: unknown) => void;
84
+ setImmediate?: (callback: () => void) => unknown;
85
+ queueMicrotask: (callback: () => void) => void;
86
+ events: {
87
+ createEmitter(): HostEventEmitter;
88
+ };
89
+ platformInfo?: () => {
90
+ os: string;
91
+ release: string;
92
+ };
93
+ nativeCrypto?: unknown;
94
+ defaultLogger?: ILogger;
95
+ loggerSink: (line: string, delivered?: () => void) => void;
96
+ logLevel: () => string | undefined;
97
+ Long: HostLongConstructor;
98
+ };
99
+ export type HostCacheStore = {
100
+ get<T>(key: string): Promise<T | undefined> | T | undefined;
101
+ set<T>(key: string, value: T): Promise<void> | void | number | boolean;
102
+ del(key: string): Promise<void> | void | number | boolean;
103
+ flushAll(): Promise<void> | void;
104
+ close?(): void;
105
+ };
106
+ type HostNativeCacheStore = {
107
+ get(namespace: string, key: string): Promise<Uint8Array | null>;
108
+ set(namespace: string, key: string, value: Uint8Array, ttlSecs?: number): Promise<void>;
109
+ delete(namespace: string, key: string): Promise<void>;
110
+ clear(namespace: string): Promise<void>;
111
+ };
112
+ type HostCacheEntryConfig = {
113
+ ttlSecs?: number;
114
+ capacity?: number;
115
+ store?: HostNativeCacheStore;
116
+ };
117
+ type HostSocketCacheConfig = {
118
+ store?: HostNativeCacheStore;
119
+ group?: HostCacheEntryConfig;
120
+ device?: HostCacheEntryConfig;
121
+ deviceRegistry?: HostCacheEntryConfig;
122
+ lidPn?: HostCacheEntryConfig;
123
+ retriedGroupMessages?: HostCacheEntryConfig;
124
+ recentMessages?: HostCacheEntryConfig;
125
+ messageRetry?: HostCacheEntryConfig;
126
+ };
127
+ export type HostSocketConfig = {
128
+ auth: HostAuthenticationState;
129
+ logger?: ILogger;
130
+ waWebSocketUrl?: string | URL;
131
+ connectTimeoutMs?: number;
132
+ defaultQueryTimeoutMs?: number;
133
+ keepAliveIntervalMs?: number;
134
+ version?: [number, number, number];
135
+ browser?: [os: string, browser: string, version: string];
136
+ pushName?: string;
137
+ emitOwnEvents?: boolean;
138
+ customUploadHosts?: Array<{
139
+ hostname: string;
140
+ maxContentLengthBytes: number;
141
+ }>;
142
+ shouldIgnoreJid?: (jid: string) => boolean | undefined;
143
+ options?: RequestInit;
144
+ cache?: HostSocketCacheConfig;
145
+ deviceProps?: Record<string, unknown>;
146
+ wantedPreKeyCount?: number;
147
+ dangerSkipCertChainVerify?: boolean;
148
+ qrTimeout?: number;
149
+ maxMsgRetryCount?: number;
150
+ retryRequestDelayMs?: number;
151
+ generateHighQualityLinkPreview?: boolean;
152
+ linkPreviewImageThumbnailWidth?: number;
153
+ enableAutoSessionRecreation?: boolean;
154
+ enableRecentMessageCache?: boolean;
155
+ markOnlineOnConnect?: boolean;
156
+ transactionOpts?: {
157
+ maxCommitRetries: number;
158
+ delayBetweenTriesMs: number;
159
+ };
160
+ syncFullHistory?: boolean;
161
+ fireInitQueries?: boolean;
162
+ countryCode?: string;
163
+ downloadHistory?: boolean;
164
+ shouldSyncHistoryMessage?: (message: {
165
+ syncType?: number | null;
166
+ chunkOrder?: number | null;
167
+ progress?: number | null;
168
+ fileLength?: number | string | {
169
+ low: number;
170
+ high: number;
171
+ unsigned?: boolean;
172
+ } | null;
173
+ peerDataRequestSessionId?: string | null;
174
+ }) => boolean;
175
+ printQRInTerminal?: boolean;
176
+ ignoreOfflineMessages?: boolean;
177
+ mediaCache?: HostCacheStore;
178
+ msgRetryCounterCache?: HostCacheStore;
179
+ userDevicesCache?: HostCacheStore;
180
+ callOfferCache?: HostCacheStore;
181
+ placeholderResendCache?: HostCacheStore;
182
+ patchMessageBeforeSending?: (message: Record<string, unknown>, recipientJids?: string[]) => Promise<Record<string, unknown> | Record<string, unknown>[]> | Record<string, unknown> | Record<string, unknown>[];
183
+ appStateMacVerification?: {
184
+ patch: boolean;
185
+ snapshot: boolean;
186
+ };
187
+ getMessage?: (key: {
188
+ remoteJid?: string | null;
189
+ id?: string | null;
190
+ fromMe?: boolean | null;
191
+ }) => Promise<unknown>;
192
+ cachedGroupMetadata?: (jid: string) => Promise<Record<string, unknown> | undefined>;
193
+ makeSignalRepository?: (...args: never[]) => unknown;
194
+ };
195
+ export type HostConnectionUpdate = {
196
+ connection?: 'open' | 'connecting' | 'close';
197
+ lastDisconnect?: {
198
+ error?: Error;
199
+ date: Date;
200
+ };
201
+ isNewLogin?: boolean;
202
+ qr?: string;
203
+ receivedPendingNotifications?: boolean;
204
+ legacy?: {
205
+ phoneConnected: boolean;
206
+ user?: {
207
+ id: string;
208
+ name?: string;
209
+ };
210
+ };
211
+ isOnline?: boolean;
212
+ reachoutTimeLock?: Record<string, unknown>;
213
+ };
214
+ export type HostBaileysEventMap = {
215
+ 'connection.update': HostConnectionUpdate;
216
+ 'creds.update': Partial<HostAuthenticationCreds>;
217
+ 'messages.upsert': {
218
+ messages: WAMessage[];
219
+ type: 'append' | 'notify';
220
+ requestId?: string;
221
+ };
222
+ };
223
+ type HostEventListener = (...args: any[]) => void;
224
+ type HostMappedEventListener<K extends keyof HostBaileysEventMap> = (payload: HostBaileysEventMap[K]) => void;
225
+ export type HostEventEmitter = {
226
+ on<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): HostEventEmitter;
227
+ on(event: string | symbol, listener: HostEventListener): HostEventEmitter;
228
+ off<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): HostEventEmitter;
229
+ off(event: string | symbol, listener: HostEventListener): HostEventEmitter;
230
+ once<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): HostEventEmitter;
231
+ once(event: string | symbol, listener: HostEventListener): HostEventEmitter;
232
+ prependListener<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): HostEventEmitter;
233
+ prependListener(event: string | symbol, listener: HostEventListener): HostEventEmitter;
234
+ prependOnceListener<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): HostEventEmitter;
235
+ prependOnceListener(event: string | symbol, listener: HostEventListener): HostEventEmitter;
236
+ removeListener<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): HostEventEmitter;
237
+ removeListener(event: string | symbol, listener: HostEventListener): HostEventEmitter;
238
+ removeAllListeners(event?: string | symbol): HostEventEmitter;
239
+ eventNames(): (string | symbol)[];
240
+ rawListeners(event: string | symbol): HostEventListener[];
241
+ listeners(event: string | symbol): HostEventListener[];
242
+ listenerCount(event: string | symbol, listener?: HostEventListener): number;
243
+ setMaxListeners(count: number): HostEventEmitter;
244
+ getMaxListeners(): number;
245
+ emit<K extends keyof HostBaileysEventMap>(event: K, payload: HostBaileysEventMap[K]): boolean;
246
+ emit(event: string | symbol, ...args: unknown[]): boolean;
247
+ };
248
+ /** Host-facing operations retain callable types without importing Node Baileys declarations. */
249
+ export type HostSocketEventEmitter = {
250
+ on<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): void;
251
+ on(event: string | symbol, listener: HostEventListener): void;
252
+ off<K extends keyof HostBaileysEventMap>(event: K, listener: HostMappedEventListener<K>): void;
253
+ off(event: string | symbol, listener: HostEventListener): void;
254
+ removeAllListeners(event: string | symbol): void;
255
+ emit<K extends keyof HostBaileysEventMap>(event: K, payload: HostBaileysEventMap[K]): boolean;
256
+ emit(event: string | symbol, ...args: unknown[]): boolean;
257
+ process(handler: (events: Partial<HostBaileysEventMap> & Record<string, unknown>) => void | Promise<void>): () => void;
258
+ buffer(): void;
259
+ flush(force?: boolean): boolean;
260
+ isBuffering(): boolean;
261
+ createBufferedFunction<A extends unknown[], R>(work: (...args: A) => Promise<R>): (...args: A) => Promise<R>;
262
+ destroy(): void;
263
+ };
264
+ export type HostWebSocketClient = HostEventEmitter & {
265
+ url: URL;
266
+ config: unknown;
267
+ readonly isOpen: boolean;
268
+ readonly isClosed: boolean;
269
+ readonly isClosing: boolean;
270
+ readonly isConnecting: boolean;
271
+ connect(): void;
272
+ close(): Promise<void>;
273
+ send(data: string | Uint8Array, callback?: (error?: Error) => void): boolean;
274
+ };
275
+ type HostMutex = {
276
+ mutex<T>(work: () => Promise<T> | T): Promise<T>;
277
+ };
278
+ export type HostAnyMessageContent = string | Record<string, unknown>;
279
+ export type HostMessageGenerationOptions = {
280
+ messageId?: string;
281
+ useCachedGroupMetadata?: boolean;
282
+ timestamp?: Date;
283
+ quoted?: WAMessage;
284
+ ephemeralExpiration?: number | string;
285
+ mediaUploadTimeoutMs?: number;
286
+ statusJidList?: string[];
287
+ broadcast?: boolean;
288
+ backgroundColor?: string;
289
+ font?: number;
290
+ };
291
+ type HostWASocketBase = {
292
+ ev: HostSocketEventEmitter;
293
+ logger: ILogger;
294
+ ws: HostWebSocketClient;
295
+ type: 'md';
296
+ user: {
297
+ id: string;
298
+ lid?: string;
299
+ name?: string;
300
+ verifiedName?: string;
301
+ phoneNumber?: string;
302
+ } | undefined;
303
+ waClient: unknown | undefined;
304
+ readonly isConnected: boolean;
305
+ readonly isLoggedIn: boolean;
306
+ readonly authState: {
307
+ creds: HostAuthenticationCreds;
308
+ keys?: unknown;
309
+ };
310
+ signalRepository: unknown;
311
+ messageRetryManager: null;
312
+ devicesMutex: HostMutex;
313
+ messageMutex: HostMutex;
314
+ receiptMutex: HostMutex;
315
+ appStatePatchMutex: HostMutex;
316
+ notificationMutex: HostMutex;
317
+ [Symbol.asyncDispose](): Promise<void>;
318
+ end: (error?: unknown) => Promise<void> | void;
319
+ sendMessage(jid: string, content: HostAnyMessageContent, options?: HostMessageGenerationOptions): Promise<WAMessage>;
320
+ logout: (...args: unknown[]) => Promise<void>;
321
+ query: (...args: unknown[]) => Promise<unknown>;
322
+ sendNode: (...args: unknown[]) => Promise<unknown>;
323
+ relayMessage: (...args: unknown[]) => Promise<unknown>;
324
+ downloadMedia: (...args: unknown[]) => Promise<unknown>;
325
+ profilePictureUrl: (...args: unknown[]) => Promise<unknown>;
326
+ sendPresenceUpdate: (...args: unknown[]) => Promise<unknown>;
327
+ waUploadToServer: (...args: unknown[]) => Promise<unknown>;
328
+ groupCreate: (...args: unknown[]) => Promise<unknown>;
329
+ groupParticipantsUpdate: (...args: unknown[]) => Promise<unknown>;
330
+ groupMetadata: (...args: unknown[]) => Promise<unknown>;
331
+ fetchBlocklist: (...args: unknown[]) => Promise<unknown>;
332
+ updateBlockStatus: (...args: unknown[]) => Promise<unknown>;
333
+ updateProfileName: (...args: unknown[]) => Promise<unknown>;
334
+ updateProfileStatus: (...args: unknown[]) => Promise<unknown>;
335
+ updateProfilePicture: (...args: unknown[]) => Promise<unknown>;
336
+ removeProfilePicture: (...args: unknown[]) => Promise<unknown>;
337
+ fetchMessageHistory: (...args: unknown[]) => Promise<unknown>;
338
+ readMessages: (...args: unknown[]) => Promise<unknown>;
339
+ sendReceipt: (...args: unknown[]) => Promise<unknown>;
340
+ sendReceipts: (...args: unknown[]) => Promise<unknown>;
341
+ requestPlaceholderResend: (...args: unknown[]) => Promise<unknown>;
342
+ updateDefaultDisappearingMode: (...args: unknown[]) => Promise<unknown>;
343
+ rejectCall: (...args: unknown[]) => Promise<unknown>;
344
+ fetchReachoutTimelock: (...args: unknown[]) => Promise<unknown>;
345
+ setAutoReconnect: (...args: unknown[]) => unknown;
346
+ waitForMessage: (...args: unknown[]) => Promise<unknown>;
347
+ assertSessions: (...args: unknown[]) => Promise<unknown>;
348
+ getUSyncDevices: (...args: unknown[]) => Promise<unknown>;
349
+ };
350
+ type GenericHostSocketOperations = {
351
+ [K in Exclude<HostSocketOperationName, keyof HostWASocketBase>]: (...args: unknown[]) => unknown;
352
+ };
353
+ /** Complete callable socket surface, with richer signatures for the common operations above. */
354
+ export type HostWASocket = HostWASocketBase & GenericHostSocketOperations;
355
+ export {};
356
+ //# sourceMappingURL=host-types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=host-types.js.map
package/lib/host.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Host entrypoint: runtime-neutral `makeWASocket` for Workers/workerd/DO,
3
+ * Deno and browser-like hosts.
4
+ *
5
+ * The bridge WASM arrives host-supplied — the host imports it with whatever
6
+ * its platform provides and passes it to `initSync` before creating a
7
+ * socket:
8
+ *
9
+ * ```ts
10
+ * import { readFileSync } from 'node:fs' // Node check only; on a real host use its own import
11
+ * import { initSync } from '@oxidezap/whatsapp-rust-bridge/host'
12
+ * import { makeWASocket, createAuthenticationState, useMemoryStore } from '@oxidezap/baileyrs/host'
13
+ *
14
+ * initSync({ module: readFileSync('whatsapp_rust_bridge_bg.wasm') })
15
+ * const auth = await createAuthenticationState(useMemoryStore())
16
+ * const sock = makeWASocket({ auth, logger: myLogger })
17
+ * ```
18
+ *
19
+ * (`@oxidezap/baileyrs/wasm` re-exports the bridge WASM asset without
20
+ * duplicating it — see `src/wasm.ts`. Bundlers that cannot import `.wasm`
21
+ * pass raw bytes instead; both shapes are `SyncInitInput`.)
22
+ *
23
+ * Host defaults: global `WebSocket` transport, `fetch` HTTP client,
24
+ * WebCrypto randomness, portable emitter, stable Ubuntu platform fallback,
25
+ * Rust/WASM crypto (no OpenSSL fast path), `console` logger sink, no
26
+ * filesystem auth, no media processors, no `Buffer`/`Readable` inputs.
27
+ */
28
+ export * from './surface.js';
29
+ export { createWASocketFactory, makeHostWASocket, makeMediaCryptoRuntime, makeWASocket, setLoggerSink, setPlatformInfo, useMemoryStore } from './host-surface.js';
30
+ export type { HostSocketFactory } from './host-surface.js';
31
+ export type { HostAnyMessageContent, HostAuthenticationCreds, HostAuthenticationState, HostBaileysEventMap, HostBridgeRuntime, HostCacheStore, HostConnectionUpdate, HostEventEmitter, HostKeyPair, HostLongConstructor, HostLongValue, HostMediaCryptoRuntime, HostMessageGenerationOptions, HostRuntime, HostSignedKeyPair, HostSocketConfig, HostSocketEventEmitter, HostStoreCallbacks, HostWASocket, HostWebSocketClient } from './host-types.js';
32
+ export { default } from './host-surface.js';
33
+ //# sourceMappingURL=host.d.ts.map
package/lib/host.js ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Host entrypoint: runtime-neutral `makeWASocket` for Workers/workerd/DO,
3
+ * Deno and browser-like hosts.
4
+ *
5
+ * The bridge WASM arrives host-supplied — the host imports it with whatever
6
+ * its platform provides and passes it to `initSync` before creating a
7
+ * socket:
8
+ *
9
+ * ```ts
10
+ * import { readFileSync } from 'node:fs' // Node check only; on a real host use its own import
11
+ * import { initSync } from '@oxidezap/whatsapp-rust-bridge/host'
12
+ * import { makeWASocket, createAuthenticationState, useMemoryStore } from '@oxidezap/baileyrs/host'
13
+ *
14
+ * initSync({ module: readFileSync('whatsapp_rust_bridge_bg.wasm') })
15
+ * const auth = await createAuthenticationState(useMemoryStore())
16
+ * const sock = makeWASocket({ auth, logger: myLogger })
17
+ * ```
18
+ *
19
+ * (`@oxidezap/baileyrs/wasm` re-exports the bridge WASM asset without
20
+ * duplicating it — see `src/wasm.ts`. Bundlers that cannot import `.wasm`
21
+ * pass raw bytes instead; both shapes are `SyncInitInput`.)
22
+ *
23
+ * Host defaults: global `WebSocket` transport, `fetch` HTTP client,
24
+ * WebCrypto randomness, portable emitter, stable Ubuntu platform fallback,
25
+ * Rust/WASM crypto (no OpenSSL fast path), `console` logger sink, no
26
+ * filesystem auth, no media processors, no `Buffer`/`Readable` inputs.
27
+ */
28
+ export * from './surface.js';
29
+ export { createWASocketFactory, makeHostWASocket, makeMediaCryptoRuntime, makeWASocket, setLoggerSink, setPlatformInfo, useMemoryStore } from './host-surface.js';
30
+ export { default } from './host-surface.js';
31
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1,9 @@
1
+ export { useMultiFileAuthState } from './Utils/use-multi-file-auth-state.js';
2
+ export { useBridgeStore } from './Utils/use-bridge-store.js';
3
+ export { useLegacyMultiFileAuthState } from './Utils/wrap-legacy-store.js';
4
+ export * from './Utils/messages-media.js';
5
+ export { getUrlInfo } from './Utils/link-preview.js';
6
+ export { makeNativeCryptoProvider } from './Utils/native-crypto-provider.js';
7
+ export { nodeRuntime } from './Runtime/node.js';
8
+ export { default, makeNodeWASocket, createWASocketFactory, createWASocketFactoryFor } from './Socket/index.js';
9
+ //# sourceMappingURL=node-surface.d.ts.map
@@ -0,0 +1,15 @@
1
+ // Node-only surface: filesystem auth, legacy stores, Node streams/media,
2
+ // link previews and the default socket entrypoint.
3
+ //
4
+ // Importing this module (directly or through the package root) pulls
5
+ // `node:fs`, `node:crypto` and friends — it never loads in a host bundle.
6
+ // Hosts import `../host-surface.ts` (or `@oxidezap/baileyrs/host`) instead.
7
+ export { useMultiFileAuthState } from './Utils/use-multi-file-auth-state.js';
8
+ export { useBridgeStore } from './Utils/use-bridge-store.js';
9
+ export { useLegacyMultiFileAuthState } from './Utils/wrap-legacy-store.js';
10
+ export * from './Utils/messages-media.js';
11
+ export { getUrlInfo } from './Utils/link-preview.js';
12
+ export { makeNativeCryptoProvider } from './Utils/native-crypto-provider.js';
13
+ export { nodeRuntime } from './Runtime/node.js';
14
+ export { default, makeNodeWASocket, createWASocketFactory, createWASocketFactoryFor } from './Socket/index.js';
15
+ //# sourceMappingURL=node-surface.js.map
@@ -0,0 +1,5 @@
1
+ export * from './Runtime/bytes.js';
2
+ export { createAuthenticationState, initHostAuthCreds } from './Compatibility/host-auth-state.js';
3
+ export { generateMessageIDPortable, generateMessageIDV2Portable } from './Compatibility/message-ids.js';
4
+ export * from './host-shared.js';
5
+ //# sourceMappingURL=surface.d.ts.map
package/lib/surface.js ADDED
@@ -0,0 +1,6 @@
1
+ // Shared host-safe surface. Keep every emitted declaration free of Node built-ins.
2
+ export * from './Runtime/bytes.js';
3
+ export { createAuthenticationState, initHostAuthCreds } from './Compatibility/host-auth-state.js';
4
+ export { generateMessageIDPortable, generateMessageIDV2Portable } from './Compatibility/message-ids.js';
5
+ export * from './host-shared.js';
6
+ //# sourceMappingURL=surface.js.map
package/lib/wasm.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WASM asset entry: `@oxidezap/baileyrs/wasm`.
3
+ *
4
+ * Re-exports the bridge's compiled WASM **by reference** — the ~6MB binary
5
+ * ships once (inside `@oxidezap/whatsapp-rust-bridge`), never duplicated
6
+ * into this package. `src/host.ts` documents the `initSync({ module })`
7
+ * handshake; this module is the `module` side of it on hosts whose
8
+ * bundler resolves `.wasm` imports to `SyncInitInput`.
9
+ *
10
+ * NOTE (Node): bare-Node ESM cannot `import` a `.wasm` file — the bridge's
11
+ * own `./wasm` subpath has the same constraint (its `default` condition
12
+ * points at the raw `.wasm`). On Node, read the bytes and pass them:
13
+ *
14
+ * ```ts
15
+ * import { readFileSync } from 'node:fs'
16
+ * import { fileURLToPath } from 'node:url'
17
+ * import { initSync } from '@oxidezap/whatsapp-rust-bridge/host'
18
+ * const wasmUrl = await import.meta.resolve('@oxidezap/whatsapp-rust-bridge/wasm')
19
+ * initSync({ module: readFileSync(fileURLToPath(wasmUrl)) })
20
+ * ```
21
+ *
22
+ * The static `export ... from` below keeps the subpath working on bundlers
23
+ * and hosts that *can* resolve `.wasm`; it intentionally does no runtime
24
+ * work so importing it on Node fails only when actually evaluated.
25
+ */
26
+ export { default } from '@oxidezap/whatsapp-rust-bridge/wasm';
27
+ //# sourceMappingURL=wasm.d.ts.map
package/lib/wasm.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WASM asset entry: `@oxidezap/baileyrs/wasm`.
3
+ *
4
+ * Re-exports the bridge's compiled WASM **by reference** — the ~6MB binary
5
+ * ships once (inside `@oxidezap/whatsapp-rust-bridge`), never duplicated
6
+ * into this package. `src/host.ts` documents the `initSync({ module })`
7
+ * handshake; this module is the `module` side of it on hosts whose
8
+ * bundler resolves `.wasm` imports to `SyncInitInput`.
9
+ *
10
+ * NOTE (Node): bare-Node ESM cannot `import` a `.wasm` file — the bridge's
11
+ * own `./wasm` subpath has the same constraint (its `default` condition
12
+ * points at the raw `.wasm`). On Node, read the bytes and pass them:
13
+ *
14
+ * ```ts
15
+ * import { readFileSync } from 'node:fs'
16
+ * import { fileURLToPath } from 'node:url'
17
+ * import { initSync } from '@oxidezap/whatsapp-rust-bridge/host'
18
+ * const wasmUrl = await import.meta.resolve('@oxidezap/whatsapp-rust-bridge/wasm')
19
+ * initSync({ module: readFileSync(fileURLToPath(wasmUrl)) })
20
+ * ```
21
+ *
22
+ * The static `export ... from` below keeps the subpath working on bundlers
23
+ * and hosts that *can* resolve `.wasm`; it intentionally does no runtime
24
+ * work so importing it on Node fails only when actually evaluated.
25
+ */
26
+ export { default } from '@oxidezap/whatsapp-rust-bridge/wasm';
27
+ //# sourceMappingURL=wasm.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oxidezap/baileyrs",
3
3
  "type": "module",
4
- "version": "0.3.6",
4
+ "version": "0.3.8",
5
5
  "description": "A Rust-powered WhatsApp Web library for JavaScript, with a Baileys-compatible API",
6
6
  "keywords": [
7
7
  "whatsapp",
@@ -34,6 +34,14 @@
34
34
  "types": "./lib/Utils/logger.d.ts",
35
35
  "default": "./lib/Utils/logger.js"
36
36
  },
37
+ "./host": {
38
+ "types": "./lib/host.d.ts",
39
+ "default": "./lib/host.js"
40
+ },
41
+ "./wasm": {
42
+ "types": "./lib/wasm.d.ts",
43
+ "default": "./lib/wasm.js"
44
+ },
37
45
  "./lib/*": {
38
46
  "types": "./lib/*.d.ts",
39
47
  "default": "./lib/*.js"
@@ -64,6 +72,7 @@
64
72
  "compat:sync-waproto": "node scripts/compatibility/waproto-facade.ts --sync",
65
73
  "compat:check-waproto": "node scripts/compatibility/waproto-facade.ts --check",
66
74
  "compat:layers": "node scripts/compatibility/check-layer-boundaries.ts",
75
+ "check:host-boundaries": "node scripts/check-host-boundaries.ts",
67
76
  "example": "node ./Example/example.ts",
68
77
  "format": "oxfmt src Example",
69
78
  "format:check": "oxfmt --check src Example",
@@ -78,11 +87,13 @@
78
87
  "fuzz:record": "FUZZ_RECORD=1 node --test --test-timeout=600000 ./src/__fuzz__/**/*.test.ts",
79
88
  "fuzz:report": "node scripts/fuzz/report.ts",
80
89
  "test:compat-auditor": "node --test scripts/compatibility/__tests__/audit.test.ts",
90
+ "test:packaged": "node scripts/packaged-upstream-alias.mjs",
81
91
  "typecheck:compat-auditor": "npm run build --silent && npm run compat:check-waproto --silent && npm run compat:layers --silent && tsc -p scripts/compatibility/tsconfig.json",
82
92
  "test:e2e": "NODE_TLS_REJECT_UNAUTHORIZED=0 ADV_SECRET_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= node --expose-gc --test --test-concurrency=1 ./src/__tests__/e2e/*.test-e2e.ts ./scripts/compatibility/__tests__/*.test-e2e.ts"
83
93
  },
84
94
  "dependencies": {
85
- "@oxidezap/whatsapp-rust-bridge": "0.22.0",
95
+ "@oxidezap/whatsapp-rust-bridge": "0.24.0",
96
+ "events": "^3.3.0",
86
97
  "long": "^5.3.2"
87
98
  },
88
99
  "devDependencies": {
@@ -93,15 +104,16 @@
93
104
  "jimp": "^1.6.0",
94
105
  "link-preview-js": "^5.0.0",
95
106
  "music-metadata": "^11.14.0",
96
- "oxfmt": "^0.66.0",
97
- "oxlint": "1.81.0",
107
+ "oxfmt": "^0.68.0",
108
+ "oxlint": "1.83.0",
98
109
  "pino": "^10.3.1",
99
110
  "pino-pretty": "^13.1.3",
100
111
  "pkg-pr-new": "^0.0.88",
101
112
  "protobufjs": "^8.8.0",
102
113
  "tsc-esm-fix": "^3.1.2",
103
114
  "typescript": "^7.0.2",
104
- "typescript-compat-auditor": "npm:typescript@6.0.3"
115
+ "typescript-compat-auditor": "npm:typescript@6.0.3",
116
+ "wrangler": "4.136.3"
105
117
  },
106
118
  "peerDependencies": {
107
119
  "@hapi/boom": "^9.1.0 || ^10.0.0",
@@ -139,6 +151,6 @@
139
151
  "access": "public"
140
152
  },
141
153
  "engines": {
142
- "node": ">=22.0.0"
154
+ "node": ">=22.3.0"
143
155
  }
144
156
  }