@neelegirl/wa-api 1.6.6 → 1.6.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.
- package/package.json +3 -3
- package/readme.md +216 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neelegirl/wa-api",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.8",
|
|
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",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Neele",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@neelegirl/baileys": "^2.1.
|
|
28
|
+
"@neelegirl/baileys": "^2.1.8",
|
|
29
29
|
"pino": "^8.11.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"neelegirl"
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@neelegirl/baileys": "^2.1.
|
|
44
|
+
"@neelegirl/baileys": "^2.1.8"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=20.0.0"
|
package/readme.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
| Package | Version | Role |
|
|
20
20
|
|---|---:|---|
|
|
21
|
-
| `@neelegirl/wa-api` | `1.6.
|
|
21
|
+
| `@neelegirl/wa-api` | `1.6.8` | 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
|
|
|
@@ -354,11 +354,225 @@ The following exports were verified in the currently prepared package:
|
|
|
354
354
|
|
|
355
355
|
- the type surface now includes `ON_PAIRING_CODE` in `dist/Defaults/index.d.ts`
|
|
356
356
|
- `setCredentials` is now reflected in `dist/Utils/index.d.ts`
|
|
357
|
-
- the package depends on `@neelegirl/baileys@^2.1.
|
|
357
|
+
- the package depends on `@neelegirl/baileys@^2.1.8`
|
|
358
358
|
- the README image was updated to the requested wa-api image
|
|
359
359
|
|
|
360
|
+
## Wrapper design notes
|
|
361
|
+
|
|
362
|
+
This package intentionally stays small.
|
|
363
|
+
|
|
364
|
+
### Why
|
|
365
|
+
|
|
366
|
+
The more logic gets duplicated here, the easier it becomes for the wrapper to drift away from the actual Baileys runtime below it.
|
|
367
|
+
|
|
368
|
+
### Design rule
|
|
369
|
+
|
|
370
|
+
`wa-api` should:
|
|
371
|
+
|
|
372
|
+
- make common session flows easier
|
|
373
|
+
- expose clear event hooks
|
|
374
|
+
- keep message sending simple
|
|
375
|
+
- hand you the real socket when you need deeper access
|
|
376
|
+
|
|
377
|
+
It should not:
|
|
378
|
+
|
|
379
|
+
- re-implement the entire Baileys protocol surface
|
|
380
|
+
- invent a second independent event system
|
|
381
|
+
- hide every low-level concern behind an artificial abstraction
|
|
382
|
+
|
|
383
|
+
## More practical examples
|
|
384
|
+
|
|
385
|
+
### Load stored sessions automatically on boot
|
|
386
|
+
|
|
387
|
+
```js
|
|
388
|
+
const wa = require('@neelegirl/wa-api')
|
|
389
|
+
|
|
390
|
+
async function boot() {
|
|
391
|
+
const loaded = await wa.loadSessionsFromStorage()
|
|
392
|
+
console.log('loaded sessions:', loaded)
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
boot().catch(console.error)
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Start multiple sessions
|
|
399
|
+
|
|
400
|
+
```js
|
|
401
|
+
const wa = require('@neelegirl/wa-api')
|
|
402
|
+
|
|
403
|
+
async function boot() {
|
|
404
|
+
await wa.startSession('alpha', { printQR: true })
|
|
405
|
+
await wa.startSession('beta', { printQR: true })
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
boot().catch(console.error)
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Send through a looked-up socket
|
|
412
|
+
|
|
413
|
+
```js
|
|
414
|
+
const wa = require('@neelegirl/wa-api')
|
|
415
|
+
|
|
416
|
+
async function run() {
|
|
417
|
+
await wa.startSession('demo', { printQR: true })
|
|
418
|
+
|
|
419
|
+
const sock = wa.getSession('demo')
|
|
420
|
+
if (!sock) {
|
|
421
|
+
throw new Error('socket missing')
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
await sock.sendMessage('491234567890@s.whatsapp.net', {
|
|
425
|
+
text: 'sent through direct socket access'
|
|
426
|
+
})
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
run().catch(console.error)
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Use `phoneToJid`
|
|
433
|
+
|
|
434
|
+
```js
|
|
435
|
+
const wa = require('@neelegirl/wa-api')
|
|
436
|
+
|
|
437
|
+
console.log(wa.phoneToJid({ to: '491234567890' }))
|
|
438
|
+
console.log(wa.phoneToJid({ to: '12036304321-1612471065@g.us', isGroup: true }))
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Check if a target exists
|
|
442
|
+
|
|
443
|
+
```js
|
|
444
|
+
const wa = require('@neelegirl/wa-api')
|
|
445
|
+
|
|
446
|
+
async function check() {
|
|
447
|
+
const exists = await wa.isExist({
|
|
448
|
+
sessionId: 'demo',
|
|
449
|
+
to: '491234567890'
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
console.log(exists)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
check().catch(console.error)
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Delay helper
|
|
459
|
+
|
|
460
|
+
```js
|
|
461
|
+
const wa = require('@neelegirl/wa-api')
|
|
462
|
+
|
|
463
|
+
async function example() {
|
|
464
|
+
await wa.createDelay(1000)
|
|
465
|
+
console.log('one second later')
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## Event behavior notes
|
|
470
|
+
|
|
471
|
+
### `onMessageReceived`
|
|
472
|
+
|
|
473
|
+
This is the most useful hook for bot logic.
|
|
474
|
+
|
|
475
|
+
The message object carries:
|
|
476
|
+
|
|
477
|
+
- session id
|
|
478
|
+
- original Baileys message structure
|
|
479
|
+
- convenience save helpers for image, video, and document
|
|
480
|
+
|
|
481
|
+
### `onMessageUpdate`
|
|
482
|
+
|
|
483
|
+
Use this when you want delivery-state style updates such as:
|
|
484
|
+
|
|
485
|
+
- pending
|
|
486
|
+
- server
|
|
487
|
+
- delivered
|
|
488
|
+
- read
|
|
489
|
+
- played
|
|
490
|
+
- error
|
|
491
|
+
|
|
492
|
+
### `onQRUpdated`
|
|
493
|
+
|
|
494
|
+
This is useful when you want to surface QR codes in:
|
|
495
|
+
|
|
496
|
+
- a terminal
|
|
497
|
+
- a panel
|
|
498
|
+
- a web page
|
|
499
|
+
- a bot-admin dashboard
|
|
500
|
+
|
|
501
|
+
### `onPairingCode`
|
|
502
|
+
|
|
503
|
+
Use this when a pairing-code flow is preferred over terminal QR scanning.
|
|
504
|
+
|
|
505
|
+
## Realistic update notice
|
|
506
|
+
|
|
507
|
+
This package already performs an npm registry update check once per process in its current runtime.
|
|
508
|
+
|
|
509
|
+
### What that means
|
|
510
|
+
|
|
511
|
+
- it can show a hint
|
|
512
|
+
- it does not self-update
|
|
513
|
+
- it does not rewrite your files
|
|
514
|
+
- it only tells you a newer package version exists
|
|
515
|
+
|
|
516
|
+
### How to actually update
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
npm install @neelegirl/wa-api@latest
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
or:
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
yarn add @neelegirl/wa-api@latest
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### Why this is the realistic behavior
|
|
529
|
+
|
|
530
|
+
A wrapper package should not silently change itself inside a running project. A clear update notice is realistic; automatic mutation of dependencies is not.
|
|
531
|
+
|
|
532
|
+
## FAQ
|
|
533
|
+
|
|
534
|
+
### Can I use wa-api without knowing Baileys?
|
|
535
|
+
|
|
536
|
+
Yes, for common session and message flows. But for advanced control, understanding the underlying Baileys socket is still useful.
|
|
537
|
+
|
|
538
|
+
### Is wa-api a web server?
|
|
539
|
+
|
|
540
|
+
No.
|
|
541
|
+
|
|
542
|
+
### Does wa-api keep sessions between runs?
|
|
543
|
+
|
|
544
|
+
Yes, if you keep the credential directory and let it persist.
|
|
545
|
+
|
|
546
|
+
### Does wa-api expose the raw socket?
|
|
547
|
+
|
|
548
|
+
Yes, through `getSession(...)`.
|
|
549
|
+
|
|
550
|
+
### Does it auto-update itself?
|
|
551
|
+
|
|
552
|
+
No. It may show an update hint, but installation remains manual.
|
|
553
|
+
|
|
554
|
+
### Is pairing code supported?
|
|
555
|
+
|
|
556
|
+
Yes.
|
|
557
|
+
|
|
558
|
+
### Is QR supported?
|
|
559
|
+
|
|
560
|
+
Yes.
|
|
561
|
+
|
|
360
562
|
## Release notes
|
|
361
563
|
|
|
564
|
+
### 1.6.8
|
|
565
|
+
|
|
566
|
+
- patch release aligned to `@neelegirl/baileys@2.1.8`
|
|
567
|
+
- documentation refreshed so the wrapper release line matches the currently published stack
|
|
568
|
+
- no fake auto-update behavior added; runtime update hints remain informational only
|
|
569
|
+
|
|
570
|
+
### 1.6.7
|
|
571
|
+
|
|
572
|
+
- documentation expansion release
|
|
573
|
+
- realistic update behavior note added
|
|
574
|
+
- dependency metadata aligned to `@neelegirl/baileys@2.1.7`
|
|
575
|
+
|
|
362
576
|
### 1.6.6
|
|
363
577
|
|
|
364
578
|
- aligned dependency metadata with `@neelegirl/baileys@2.1.6`
|