@neelegirl/wa-api 1.6.7 → 1.6.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.
@@ -1,28 +1,44 @@
1
- /**
2
- * Send a message to a chat JID or phone number.
3
- */
4
- export declare function sendMessage(
5
- sessionId: string,
6
- jid: string,
7
- content: import("@neelegirl/baileys/lib").AnyMessageContent,
8
- options?: import("@neelegirl/baileys/lib").MiscMessageGenerationOptions
9
- ): Promise<import("@neelegirl/baileys/lib").proto.WebMessageInfo>;
1
+ 
10
2
 
11
3
  /**
12
- * Send status mentions using the current session socket.
4
+ * Send a message to target
5
+ *
6
+ * @param sessionId - Session ID
7
+ * @param jid - Target
8
+ * @param content - Message content
9
+ * @param options - Message options
10
+ */
11
+ export declare function sendMessage(
12
+ sessionId: string,
13
+ jid: string,
14
+ content: import("@neelegirl/baileys/lib").AnyMessageContent,
15
+ options?: import("@neelegirl/baileys/lib").MiscMessageGenerationOptions
16
+ ): Promise<import("@neelegirl/baileys/lib").proto.WebMessageInfo>;
17
+ /**
18
+ * Sendet einen rohen WAMessage-Stanza an WhatsApp.
19
+ *
20
+ * @param sessionId Deine Session-ID
21
+ * @param jid Ziel-JID oder Telefonnummer (z. B. '491234567890@s.whatsapp.net' oder 'status@broadcast')
22
+ * @param content Raw-Message-Node (z. B. protocolMessage, videoMessage, etc.)
23
+ * @param options Optional: Relay-Parameter wie messageId, participant, additionalNodes, statusJidList
24
+ * @returns Promise mit der gesendeten Nachricht-ID (msgId)
13
25
  */
14
- export declare function sendStatusMentions(
15
- sessionId: string,
16
- content: any,
17
- options?: import("@neelegirl/baileys/lib").MiscMessageGenerationOptions
18
- ): Promise<any>;
19
-
20
26
  /**
21
- * Low-level relayMessage wrapper.
27
+ * Low-level relayMessage-Wrapper für direkten Baileys-Stanza Dispatch.
28
+ *
29
+ * Sendet ein rohes WAMessage-Stanza (z.B. protocolMessage, disappearingMessagesInChat,
30
+ * videoMessage, etc.) direkt an WhatsApp über die interne `relayMessage`-Methode.
31
+ *
32
+ * @param sessionId Deine Multi-Session-ID
33
+ * @param jid Ziel-JID oder Telefonnummer (z.B. '491234567890@s.whatsapp.net' oder 'status@broadcast')
34
+ * @param content Raw-Message-Node (proto.WebMessageInfo oder AnyMessageContent-ähnlich)
35
+ * @param options Optional: Relay-Parameter wie `messageId`, `participant`, `additionalNodes`,
36
+ * `statusJidList`, `useCachedGroupMetadata`, usw.
37
+ * @returns Promise mit der gesendeten Nachricht-ID (`msgId`)
22
38
  */
23
39
  export declare function relayMessage(
24
40
  sessionId: string,
25
41
  jid: string,
26
42
  content: any,
27
- options?: import("@neelegirl/baileys/lib").MiscMessageGenerationOptions
28
- ): Promise<string>;
43
+ options?: import('@neelegirl/baileys/lib').MiscMessageGenerationOptions
44
+ ): Promise<string>;
@@ -1,45 +1,22 @@
1
1
  import { WASocket } from "@neelegirl/baileys/lib";
2
2
  import type { MessageReceived, MessageUpdated, StartSessionParams } from "../Types";
3
-
4
3
  export declare const startSession: (sessionId?: string, options?: StartSessionParams) => Promise<WASocket>;
5
-
6
- export declare const onimaii: (sessionId: string, connect: (config: any) => WASocket) => Promise<WASocket>;
7
-
8
- export declare const startSessionWithPairingCode: (
9
- sessionId?: string,
10
- options?: {
11
- phoneNumber: string;
12
- },
13
- pairingCode?: string
14
- ) => Promise<WASocket>;
15
-
16
4
  /**
17
- * @deprecated Use startSession method instead.
5
+ * @deprecated Use startSession method instead
18
6
  */
19
7
  export declare const startWhatsapp: (sessionId?: string, options?: StartSessionParams) => Promise<WASocket>;
20
-
8
+ export declare const startSessionWithPairingCode: (sessionId?: string, options?: {phoneNumber}) => Promise<WASocket>;
21
9
  export declare const deleteSession: (sessionId: string) => Promise<void>;
22
-
23
10
  export declare const getAllSession: () => string[];
24
-
25
11
  export declare const getSession: (key: string) => WASocket | undefined;
26
-
27
- export declare const getAllSessionData: () => Record<string, WASocket | undefined>;
28
-
29
- export declare const loadSessionsFromStorage: () => Promise<string[]>;
30
-
31
- export declare const sock: (conn: any) => any;
32
-
12
+ export declare const loadSessionsFromStorage: () => void;
33
13
  export declare const onMessageReceived: (listener: (msg: MessageReceived) => any) => void;
34
-
35
- export declare const onQRUpdated: (listener: ({ sessionId, qr }: { sessionId: string; qr: string }) => any) => void;
36
-
14
+ export declare const onQRUpdated: (listener: ({ sessionId, qr }: {
15
+ sessionId: string;
16
+ qr: string;
17
+ }) => any) => void;
37
18
  export declare const onConnected: (listener: (sessionId: string) => any) => void;
38
-
39
19
  export declare const onDisconnected: (listener: (sessionId: string) => any) => void;
40
-
41
20
  export declare const onConnecting: (listener: (sessionId: string) => any) => void;
42
-
43
- export declare const onMessageUpdate: (listener: (sessionId: string, data: MessageUpdated) => any) => void;
44
-
45
- export declare const onPairingCode: (listener: (sessionId: string, code: string) => any) => void;
21
+ export declare const onMessageUpdate: (listener: (data: MessageUpdated) => any) => void;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -15,6 +15,7 @@ const message_status_1 = require("../Utils/message-status");
15
15
  const sessions = new Map();
16
16
  const callback = new Map();
17
17
  const retryCount = new Map();
18
+ const TERMINAL_QR_FORCE_ENV = String(process.env.ONIMAI_FORCE_TERMINAL_QR || "").trim();
18
19
 
19
20
  let CURRENT_WA_API_VERSION = "1.6.5";
20
21
  let waApiUpdateCheckDone = false;
@@ -95,6 +96,52 @@ const checkWaApiUpdate = () => {
95
96
  });
96
97
  };
97
98
 
99
+ const getSessionCredsDir = (sessionId) =>
100
+ path_1.resolve(Defaults_1.CREDENTIALS.DIR_NAME, sessionId + Defaults_1.CREDENTIALS.SUFFIX);
101
+
102
+ const readStoredSessionCreds = (sessionId) => {
103
+ try {
104
+ const credsPath = path_1.join(getSessionCredsDir(sessionId), "creds.json");
105
+ if (!fs_1.existsSync(credsPath)) {
106
+ return null;
107
+ }
108
+ const raw = fs_1.readFileSync(credsPath, "utf8");
109
+ return JSON.parse(raw || "{}");
110
+ }
111
+ catch (_) {
112
+ return null;
113
+ }
114
+ };
115
+
116
+ const hasStoredLinkedSessionCreds = (sessionId) => {
117
+ try {
118
+ const dir = getSessionCredsDir(sessionId);
119
+ if (!fs_1.existsSync(dir) || !fs_1.lstatSync(dir).isDirectory()) {
120
+ return false;
121
+ }
122
+ const creds = readStoredSessionCreds(sessionId);
123
+ const me = creds?.me || {};
124
+ if (creds?.registered === true || me?.id || me?.lid) {
125
+ return true;
126
+ }
127
+ const files = fs_1.readdirSync(dir);
128
+ return files.some((file) => /^(session-|sender-key-|app-state-sync-key-|pre-key-)/i.test(String(file || "").trim()));
129
+ }
130
+ catch (_) {
131
+ return false;
132
+ }
133
+ };
134
+
135
+ const shouldPrintQrInTerminal = (sessionId, options = {}) => {
136
+ if (TERMINAL_QR_FORCE_ENV === "1") {
137
+ return true;
138
+ }
139
+ if (TERMINAL_QR_FORCE_ENV === "0") {
140
+ return false;
141
+ }
142
+ return true;
143
+ };
144
+
98
145
  const emitMessageUpsert = (sessionId, msg) => {
99
146
  msg.sessionId = sessionId;
100
147
  msg.saveImage = (path) => (0, save_media_1.saveImageHandler)(msg, path);
@@ -164,11 +211,11 @@ const createSessionSocket = async (sessionId, options = {}, retryStarter) => {
164
211
  const logger = (0, pino_1)({ level: "silent" });
165
212
  const { version } = await (0, baileys_1.fetchLatestBaileysVersion)();
166
213
  const { state, saveCreds } = await (0, baileys_1.useMultiFileAuthState)(
167
- path_1.resolve(Defaults_1.CREDENTIALS.DIR_NAME, sessionId + Defaults_1.CREDENTIALS.SUFFIX)
214
+ getSessionCredsDir(sessionId)
168
215
  );
169
216
  const sock = (0, baileys_1.default)({
170
217
  version,
171
- printQRInTerminal: !!options.printQR,
218
+ printQRInTerminal: shouldPrintQrInTerminal(sessionId, options),
172
219
  auth: state,
173
220
  logger,
174
221
  markOnlineOnConnect: false,
@@ -214,7 +261,7 @@ const startSession = async (sessionId = "mysession", options = { printQR: true }
214
261
  if (isSessionExistAndRunning(sessionId)) {
215
262
  throw new Error_1.WhatsappError(Defaults_1.Messages.sessionAlreadyExist(sessionId));
216
263
  }
217
- const starter = () => createSessionSocket(sessionId, { printQR: options?.printQR !== false }, starter);
264
+ const starter = () => createSessionSocket(sessionId, { ...options, printQR: options?.printQR !== false }, starter);
218
265
  return starter();
219
266
  };
220
267
  exports.startSession = startSession;
@@ -229,11 +276,11 @@ const onimaii = async (sessionId = "mysession", connect) => {
229
276
  const logger = (0, pino_1)({ level: "silent" });
230
277
  const { version } = await (0, baileys_1.fetchLatestBaileysVersion)();
231
278
  const { state, saveCreds } = await (0, baileys_1.useMultiFileAuthState)(
232
- path_1.resolve(Defaults_1.CREDENTIALS.DIR_NAME, sessionId + Defaults_1.CREDENTIALS.SUFFIX)
279
+ getSessionCredsDir(sessionId)
233
280
  );
234
281
  const sock = connect({
235
282
  version,
236
- printQRInTerminal: true,
283
+ printQRInTerminal: shouldPrintQrInTerminal(sessionId, { printQR: true }),
237
284
  auth: state,
238
285
  logger,
239
286
  markOnlineOnConnect: false,
@@ -319,13 +366,14 @@ const loadSessionsFromStorage = async () => {
319
366
  if (!stat.isDirectory()) {
320
367
  continue;
321
368
  }
322
- const underscoreIndex = entry.indexOf("_");
323
- const sessionId = underscoreIndex > 0 ? entry.slice(0, underscoreIndex) : entry;
369
+ const sessionId = entry.endsWith(Defaults_1.CREDENTIALS.SUFFIX)
370
+ ? entry.slice(0, -Defaults_1.CREDENTIALS.SUFFIX.length)
371
+ : entry;
324
372
  if (!shouldLoadSession(sessionId)) {
325
373
  continue;
326
374
  }
327
375
  try {
328
- await (0, exports.startSession)(sessionId);
376
+ await (0, exports.startSession)(sessionId, { printQR: false });
329
377
  loadedSessions.push(sessionId);
330
378
  }
331
379
  catch (_) {
@@ -376,4 +424,4 @@ exports.onMessageUpdate = onMessageUpdate;
376
424
  const onPairingCode = (listener) => {
377
425
  callback.set(Defaults_1.CALLBACK_KEY.ON_PAIRING_CODE, listener);
378
426
  };
379
- exports.onPairingCode = onPairingCode;
427
+ exports.onPairingCode = onPairingCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neelegirl/wa-api",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "Multi-session WhatsApp wrapper built on top of @neelegirl/baileys",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,8 +13,7 @@
13
13
  "url": "https://github.com/neelegirl/wa-api/issues"
14
14
  },
15
15
  "files": [
16
- "dist/**/*",
17
- "readme.md"
16
+ "dist/**/*"
18
17
  ],
19
18
  "scripts": {
20
19
  "build": "tsc",
@@ -25,24 +24,13 @@
25
24
  "author": "Neele",
26
25
  "license": "MIT",
27
26
  "dependencies": {
28
- "@neelegirl/baileys": "^2.1.7",
27
+ "@neelegirl/baileys": "^2.1.9",
29
28
  "pino": "^8.11.0"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@types/mime": "^3.0.1",
33
32
  "jest": "^29.0.0"
34
33
  },
35
- "keywords": [
36
- "whatsapp",
37
- "baileys",
38
- "api",
39
- "multi-session",
40
- "automation",
41
- "neelegirl"
42
- ],
43
- "peerDependencies": {
44
- "@neelegirl/baileys": "^2.1.7"
45
- },
46
34
  "engines": {
47
35
  "node": ">=20.0.0"
48
36
  }
package/readme.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  | Package | Version | Role |
20
20
  |---|---:|---|
21
- | `@neelegirl/wa-api` | `1.6.7` | Convenience wrapper for session lifecycle and event-driven bot workflows |
21
+ | `@neelegirl/wa-api` | `1.6.9` | Convenience wrapper for session lifecycle and event-driven bot workflows |
22
22
 
23
23
  [Installation](#installation) · [Quickstart](#quickstart) · [API surface](#verified-api-surface) · [Events](#event-hooks) · [Storage](#session-storage) · [Release notes](#release-notes)
24
24
 
@@ -29,6 +29,7 @@
29
29
  ## Table of Contents
30
30
 
31
31
  - [Overview](#overview)
32
+ - [Stack relationship](#stack-relationship)
32
33
  - [What this package is](#what-this-package-is)
33
34
  - [What this package is not](#what-this-package-is-not)
34
35
  - [Installation](#installation)
@@ -54,6 +55,18 @@
54
55
 
55
56
  It keeps the actual WhatsApp protocol handling inside the underlying Baileys fork.
56
57
 
58
+ ## Stack relationship
59
+
60
+ `@neelegirl/wa-api` is intentionally the thin layer at the top of the local stack:
61
+
62
+ | Package | Layer | Responsibility |
63
+ |---|---|---|
64
+ | `@neelegirl/libsignal` | crypto/session layer | session cipher state, identity keys, protocol primitives |
65
+ | `@neelegirl/baileys` | WhatsApp Web runtime | socket, QR/pairing flow, device handling, events, media and message transport |
66
+ | `@neelegirl/wa-api` | wrapper layer | multi-session lifecycle, convenience events, simplified send helpers |
67
+
68
+ The wrapper should stay small on purpose: it makes common flows easier without pretending to be a separate protocol implementation.
69
+
57
70
  ## What this package is
58
71
 
59
72
  | Area | Purpose |
@@ -352,9 +365,12 @@ The following exports were verified in the currently prepared package:
352
365
 
353
366
  ## Recent maintenance notes
354
367
 
368
+ - the README was rechecked on `2026-03-20` against the local source wrapper and the target runtime package
369
+ - descriptions were kept aligned with the actual wrapper role instead of repeating full Baileys runtime claims
355
370
  - the type surface now includes `ON_PAIRING_CODE` in `dist/Defaults/index.d.ts`
356
371
  - `setCredentials` is now reflected in `dist/Utils/index.d.ts`
357
- - the package depends on `@neelegirl/baileys@^2.1.7`
372
+ - the package now tracks `@neelegirl/baileys@^2.1.9`
373
+ - the README was kept aligned with the actual wrapper surface instead of promising Baileys internals that belong only to the lower runtime package
358
374
  - the README image was updated to the requested wa-api image
359
375
 
360
376
  ## Wrapper design notes
@@ -561,6 +577,18 @@ Yes.
561
577
 
562
578
  ## Release notes
563
579
 
580
+ ### 1.6.9
581
+
582
+ - dependency metadata aligned to `@neelegirl/baileys@2.1.9`
583
+ - documentation refreshed after the hosted LID/session migration stabilization in the underlying runtime
584
+ - public wrapper guidance rechecked against the current `dist` surface on `2026-03-20`
585
+
586
+ ### 1.6.8
587
+
588
+ - patch release aligned to `@neelegirl/baileys@2.1.8`
589
+ - documentation refreshed so the wrapper release line matches the currently published stack
590
+ - no fake auto-update behavior added; runtime update hints remain informational only
591
+
564
592
  ### 1.6.7
565
593
 
566
594
  - documentation expansion release