kevinx-baileys 1.2.1 → 1.2.2
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 +151 -10
- package/kevinx-baileys/package.json +0 -153
- package/kevinx-baileys/test/extras.test.mjs +0 -187
- package/kevinx-baileys/test/hooks.mjs +0 -10
- package/kevinx-baileys/test/register.mjs +0 -2
- package/kevinx_baileys_v1_2_1-1.2.1.tgz +0 -0
- /package/{kevinx-baileys/CHANGELOG.md → CHANGELOG.md} +0 -0
- /package/{kevinx-baileys/LICENSE → LICENSE} +0 -0
- /package/{kevinx-baileys/README.md → README.md} +0 -0
- /package/{kevinx-baileys/WAProto → WAProto}/GenerateStatics.sh +0 -0
- /package/{kevinx-baileys/WAProto → WAProto}/WAProto.proto +0 -0
- /package/{kevinx-baileys/WAProto → WAProto}/fix-imports.js +0 -0
- /package/{kevinx-baileys/WAProto → WAProto}/index.d.ts +0 -0
- /package/{kevinx-baileys/WAProto → WAProto}/index.js +0 -0
- /package/{kevinx-baileys/engine-requirements.js → engine-requirements.js} +0 -0
- /package/{kevinx-baileys/lib → lib}/Defaults/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/auth-mongo.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/auth-redis.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/auth-state-core.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/channel.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/extend.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/group-tools.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/kevinx-socket.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/pairing.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/send-queue.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/session-tools.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/shortcuts.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/update-check.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Extras/utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/ciphertext-message.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/group-session-builder.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/group_cipher.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/keyhelper.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-chain-key.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-key-distribution-message.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-key-message.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-key-name.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-key-record.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-key-state.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/Group/sender-message-key.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/libsignal.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Signal/lid-mapping.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/Client/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/Client/types.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/Client/websocket.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/MessageBuilder.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/business.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/chats.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/communities.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/graphql.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/groups.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/interop.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/luxu.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/message-builder.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/messages-recv.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/messages-send.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/mex.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/newsletter.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/privacy.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/socket.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Socket/username.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Store/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Store/keyed-db.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Store/make-cache-manager-store.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Store/make-in-memory-store.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Store/make-ordered-dictionary.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Store/object-repository.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Auth.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Bussines.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Call.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Chat.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Contact.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Events.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/GroupMetadata.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Label.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/LabelAssociation.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Message.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Mex.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Product.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Signal.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/Socket.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/State.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/USync.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Types/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/auth-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/banner.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/browser-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/business.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/chat-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/companion-reg-client-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/crypto.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/decode-wa-message.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/event-buffer.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/generics.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/history.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/identity-change-handler.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/link-preview.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/logger.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/lt-hash.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/make-mutex.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/message-composer.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/message-retry-manager.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/messages-media.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/messages.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/noise-handler.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/offline-node-processor.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/pre-key-manager.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/process-message.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/reporting-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/signal.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/stanza-ack.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/sticker.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/sync-action-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/tc-token-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/use-multi-file-auth-state.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/use-sqlite-auth-state.js +0 -0
- /package/{kevinx-baileys/lib → lib}/Utils/validate-connection.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/constants.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/decode.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/encode.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/generic-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/jid-utils.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WABinary/types.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAM/BinaryInfo.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAM/constants.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAM/encode.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAM/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncBusinessProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncContactProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncDeviceProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncFeatureProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncLIDProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncPictureProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncSidelistProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncStatusProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/USyncUsernameProtocol.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/Protocols/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/USyncQuery.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/USyncUser.js +0 -0
- /package/{kevinx-baileys/lib → lib}/WAUSync/index.js +0 -0
- /package/{kevinx-baileys/lib → lib}/index.d.ts +0 -0
- /package/{kevinx-baileys/lib → lib}/index.js +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,153 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "kevinx-baileys",
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"description": "KevinX Baileys — a WebSockets library for interacting with WhatsApp Web (multi-device, pairing code, interactive messages, newsletter, auto-reconnect, send queue, typings).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"baileys",
|
|
7
|
+
"kevinx-baileys",
|
|
8
|
+
"whatsapp",
|
|
9
|
+
"whatsapp-baileys",
|
|
10
|
+
"whatsapp-bot",
|
|
11
|
+
"multi-device",
|
|
12
|
+
"auto-reconnect",
|
|
13
|
+
"typescript",
|
|
14
|
+
"whatsapp-api"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://t.me/kevinxddd",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://t.me/kevinxddd"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://t.me/kevinxddd"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "KevinX (https://t.me/kevinxddd)",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "lib/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./lib/index.d.ts",
|
|
31
|
+
"import": "./lib/index.js",
|
|
32
|
+
"default": "./lib/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./WAProto": "./WAProto/index.js",
|
|
35
|
+
"./lib/*": "./lib/*",
|
|
36
|
+
"./WAProto/*": "./WAProto/*",
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"lib/**/*",
|
|
41
|
+
"WAProto/**/*",
|
|
42
|
+
"engine-requirements.js",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"README.md",
|
|
45
|
+
"CHANGELOG.md"
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
49
|
+
"preinstall": "node ./engine-requirements.js",
|
|
50
|
+
"test": "node --import ./test/register.mjs --test test/extras.test.mjs",
|
|
51
|
+
"prepublishOnly": "npm test"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@cacheable/node-cache": "^1.4.0",
|
|
55
|
+
"@hapi/boom": "^9.1.3",
|
|
56
|
+
"async-mutex": "^0.5.0",
|
|
57
|
+
"cache-manager": "^7.2.8",
|
|
58
|
+
"chalk": "^4.1.2",
|
|
59
|
+
"fluent-ffmpeg": "^2.1.3",
|
|
60
|
+
"libsignal": "^6.0.0",
|
|
61
|
+
"lru-cache": "^11.1.0",
|
|
62
|
+
"music-metadata": "^11.12.3",
|
|
63
|
+
"p-queue": "^9.0.0",
|
|
64
|
+
"pino": "^9.6",
|
|
65
|
+
"protobufjs": "^7.5.6",
|
|
66
|
+
"whatsapp-rust-bridge": "0.5.4",
|
|
67
|
+
"ws": "^8.13.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
71
|
+
"@eslint/js": "^9.31.0",
|
|
72
|
+
"@types/jest": "^30.0.0",
|
|
73
|
+
"@types/node": "^20.9.0",
|
|
74
|
+
"@types/ws": "^8.0.0",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8",
|
|
76
|
+
"@typescript-eslint/parser": "^8",
|
|
77
|
+
"@whiskeysockets/eslint-config": "^1.0.0",
|
|
78
|
+
"conventional-changelog": "^7.1.1",
|
|
79
|
+
"conventional-changelog-angular": "^8.0.0",
|
|
80
|
+
"esbuild-register": "^3.6.0",
|
|
81
|
+
"eslint": "^9",
|
|
82
|
+
"eslint-config-prettier": "^10.1.2",
|
|
83
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
84
|
+
"jest": "^30.0.5",
|
|
85
|
+
"jimp": "^1.6.1",
|
|
86
|
+
"jiti": "^2.4.2",
|
|
87
|
+
"json": "^11.0.0",
|
|
88
|
+
"link-preview-js": "^3.0.0",
|
|
89
|
+
"lru-cache": "^11.1.0",
|
|
90
|
+
"open": "^8.4.2",
|
|
91
|
+
"pino-pretty": "^13.1.1",
|
|
92
|
+
"prettier": "^3.5.3",
|
|
93
|
+
"protobufjs-cli": "^1.1.3",
|
|
94
|
+
"release-it": "^20.0.1",
|
|
95
|
+
"ts-jest": "^29.4.0",
|
|
96
|
+
"tsc-esm-fix": "^3.1.2",
|
|
97
|
+
"tsx": "^4.20.3",
|
|
98
|
+
"typedoc": "^0.27.9",
|
|
99
|
+
"typedoc-plugin-markdown": "4.4.2",
|
|
100
|
+
"typescript": "^5.8.2"
|
|
101
|
+
},
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"audio-decode": "^2.1.3",
|
|
104
|
+
"jimp": "^1.6.1",
|
|
105
|
+
"link-preview-js": "^3.0.0",
|
|
106
|
+
"sharp": "*"
|
|
107
|
+
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"audio-decode": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"jimp": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"link-preview-js": {
|
|
116
|
+
"optional": true
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"resolutions": {
|
|
120
|
+
"ajv@npm:^6.12.4": "^6.14.0",
|
|
121
|
+
"basic-ftp": "^5.2.4",
|
|
122
|
+
"brace-expansion@npm:^1.1.7": "^1.1.13",
|
|
123
|
+
"brace-expansion@npm:^2.0.1": "^2.0.3",
|
|
124
|
+
"flatted": "^3.4.2",
|
|
125
|
+
"glob@npm:^10.2.2": "^10.5.0",
|
|
126
|
+
"glob@npm:^10.3.10": "^10.5.0",
|
|
127
|
+
"glob@npm:^10.5.0": "^10.5.0",
|
|
128
|
+
"handlebars": "^4.7.9",
|
|
129
|
+
"ip-address": "^10.1.1",
|
|
130
|
+
"js-yaml@npm:^3.13.1": "^3.14.2",
|
|
131
|
+
"js-yaml@npm:^4.1.0": "^4.1.1",
|
|
132
|
+
"markdown-it": "^14.1.1",
|
|
133
|
+
"minimatch@npm:^3.0.4": "^3.1.5",
|
|
134
|
+
"minimatch@npm:^3.1.2": "^3.1.5",
|
|
135
|
+
"minimatch@npm:^5.0.1": "^5.1.8",
|
|
136
|
+
"minimatch@npm:^9.0.4": "^9.0.9",
|
|
137
|
+
"minimatch@npm:^9.0.5": "^9.0.9",
|
|
138
|
+
"picomatch@npm:^2.0.4": "^2.3.2",
|
|
139
|
+
"picomatch@npm:^2.3.1": "^2.3.2",
|
|
140
|
+
"picomatch@npm:^4.0.0": "^4.0.4",
|
|
141
|
+
"picomatch@npm:^4.0.2": "^4.0.4",
|
|
142
|
+
"socks": "^2.8.8",
|
|
143
|
+
"tar": "^7.5.11",
|
|
144
|
+
"tmp": "^0.2.5",
|
|
145
|
+
"underscore": "^1.13.8",
|
|
146
|
+
"yaml@npm:^2.6.1": "^2.8.4"
|
|
147
|
+
},
|
|
148
|
+
"packageManager": "yarn@4.9.2",
|
|
149
|
+
"engines": {
|
|
150
|
+
"node": ">=20.0.0"
|
|
151
|
+
},
|
|
152
|
+
"types": "lib/index.d.ts"
|
|
12
153
|
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "kevinx-baileys",
|
|
3
|
-
"version": "1.2.1",
|
|
4
|
-
"description": "KevinX Baileys — a WebSockets library for interacting with WhatsApp Web (multi-device, pairing code, interactive messages, newsletter, auto-reconnect, send queue, typings).",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"baileys",
|
|
7
|
-
"kevinx-baileys",
|
|
8
|
-
"whatsapp",
|
|
9
|
-
"whatsapp-baileys",
|
|
10
|
-
"whatsapp-bot",
|
|
11
|
-
"multi-device",
|
|
12
|
-
"auto-reconnect",
|
|
13
|
-
"typescript",
|
|
14
|
-
"whatsapp-api"
|
|
15
|
-
],
|
|
16
|
-
"homepage": "https://t.me/kevinxddd",
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "https://t.me/kevinxddd"
|
|
20
|
-
},
|
|
21
|
-
"bugs": {
|
|
22
|
-
"url": "https://t.me/kevinxddd"
|
|
23
|
-
},
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"author": "KevinX (https://t.me/kevinxddd)",
|
|
26
|
-
"type": "module",
|
|
27
|
-
"main": "lib/index.js",
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"types": "./lib/index.d.ts",
|
|
31
|
-
"import": "./lib/index.js",
|
|
32
|
-
"default": "./lib/index.js"
|
|
33
|
-
},
|
|
34
|
-
"./WAProto": "./WAProto/index.js",
|
|
35
|
-
"./lib/*": "./lib/*",
|
|
36
|
-
"./WAProto/*": "./WAProto/*",
|
|
37
|
-
"./package.json": "./package.json"
|
|
38
|
-
},
|
|
39
|
-
"files": [
|
|
40
|
-
"lib/**/*",
|
|
41
|
-
"WAProto/**/*",
|
|
42
|
-
"engine-requirements.js",
|
|
43
|
-
"LICENSE",
|
|
44
|
-
"README.md",
|
|
45
|
-
"CHANGELOG.md"
|
|
46
|
-
],
|
|
47
|
-
"scripts": {
|
|
48
|
-
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
49
|
-
"preinstall": "node ./engine-requirements.js",
|
|
50
|
-
"test": "node --import ./test/register.mjs --test test/extras.test.mjs",
|
|
51
|
-
"prepublishOnly": "npm test"
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@cacheable/node-cache": "^1.4.0",
|
|
55
|
-
"@hapi/boom": "^9.1.3",
|
|
56
|
-
"async-mutex": "^0.5.0",
|
|
57
|
-
"cache-manager": "^7.2.8",
|
|
58
|
-
"chalk": "^4.1.2",
|
|
59
|
-
"fluent-ffmpeg": "^2.1.3",
|
|
60
|
-
"libsignal": "^6.0.0",
|
|
61
|
-
"lru-cache": "^11.1.0",
|
|
62
|
-
"music-metadata": "^11.12.3",
|
|
63
|
-
"p-queue": "^9.0.0",
|
|
64
|
-
"pino": "^9.6",
|
|
65
|
-
"protobufjs": "^7.5.6",
|
|
66
|
-
"whatsapp-rust-bridge": "0.5.4",
|
|
67
|
-
"ws": "^8.13.0"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@eslint/eslintrc": "^3.3.1",
|
|
71
|
-
"@eslint/js": "^9.31.0",
|
|
72
|
-
"@types/jest": "^30.0.0",
|
|
73
|
-
"@types/node": "^20.9.0",
|
|
74
|
-
"@types/ws": "^8.0.0",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8",
|
|
76
|
-
"@typescript-eslint/parser": "^8",
|
|
77
|
-
"@whiskeysockets/eslint-config": "^1.0.0",
|
|
78
|
-
"conventional-changelog": "^7.1.1",
|
|
79
|
-
"conventional-changelog-angular": "^8.0.0",
|
|
80
|
-
"esbuild-register": "^3.6.0",
|
|
81
|
-
"eslint": "^9",
|
|
82
|
-
"eslint-config-prettier": "^10.1.2",
|
|
83
|
-
"eslint-plugin-prettier": "^5.4.0",
|
|
84
|
-
"jest": "^30.0.5",
|
|
85
|
-
"jimp": "^1.6.1",
|
|
86
|
-
"jiti": "^2.4.2",
|
|
87
|
-
"json": "^11.0.0",
|
|
88
|
-
"link-preview-js": "^3.0.0",
|
|
89
|
-
"lru-cache": "^11.1.0",
|
|
90
|
-
"open": "^8.4.2",
|
|
91
|
-
"pino-pretty": "^13.1.1",
|
|
92
|
-
"prettier": "^3.5.3",
|
|
93
|
-
"protobufjs-cli": "^1.1.3",
|
|
94
|
-
"release-it": "^20.0.1",
|
|
95
|
-
"ts-jest": "^29.4.0",
|
|
96
|
-
"tsc-esm-fix": "^3.1.2",
|
|
97
|
-
"tsx": "^4.20.3",
|
|
98
|
-
"typedoc": "^0.27.9",
|
|
99
|
-
"typedoc-plugin-markdown": "4.4.2",
|
|
100
|
-
"typescript": "^5.8.2"
|
|
101
|
-
},
|
|
102
|
-
"peerDependencies": {
|
|
103
|
-
"audio-decode": "^2.1.3",
|
|
104
|
-
"jimp": "^1.6.1",
|
|
105
|
-
"link-preview-js": "^3.0.0",
|
|
106
|
-
"sharp": "*"
|
|
107
|
-
},
|
|
108
|
-
"peerDependenciesMeta": {
|
|
109
|
-
"audio-decode": {
|
|
110
|
-
"optional": true
|
|
111
|
-
},
|
|
112
|
-
"jimp": {
|
|
113
|
-
"optional": true
|
|
114
|
-
},
|
|
115
|
-
"link-preview-js": {
|
|
116
|
-
"optional": true
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
"resolutions": {
|
|
120
|
-
"ajv@npm:^6.12.4": "^6.14.0",
|
|
121
|
-
"basic-ftp": "^5.2.4",
|
|
122
|
-
"brace-expansion@npm:^1.1.7": "^1.1.13",
|
|
123
|
-
"brace-expansion@npm:^2.0.1": "^2.0.3",
|
|
124
|
-
"flatted": "^3.4.2",
|
|
125
|
-
"glob@npm:^10.2.2": "^10.5.0",
|
|
126
|
-
"glob@npm:^10.3.10": "^10.5.0",
|
|
127
|
-
"glob@npm:^10.5.0": "^10.5.0",
|
|
128
|
-
"handlebars": "^4.7.9",
|
|
129
|
-
"ip-address": "^10.1.1",
|
|
130
|
-
"js-yaml@npm:^3.13.1": "^3.14.2",
|
|
131
|
-
"js-yaml@npm:^4.1.0": "^4.1.1",
|
|
132
|
-
"markdown-it": "^14.1.1",
|
|
133
|
-
"minimatch@npm:^3.0.4": "^3.1.5",
|
|
134
|
-
"minimatch@npm:^3.1.2": "^3.1.5",
|
|
135
|
-
"minimatch@npm:^5.0.1": "^5.1.8",
|
|
136
|
-
"minimatch@npm:^9.0.4": "^9.0.9",
|
|
137
|
-
"minimatch@npm:^9.0.5": "^9.0.9",
|
|
138
|
-
"picomatch@npm:^2.0.4": "^2.3.2",
|
|
139
|
-
"picomatch@npm:^2.3.1": "^2.3.2",
|
|
140
|
-
"picomatch@npm:^4.0.0": "^4.0.4",
|
|
141
|
-
"picomatch@npm:^4.0.2": "^4.0.4",
|
|
142
|
-
"socks": "^2.8.8",
|
|
143
|
-
"tar": "^7.5.11",
|
|
144
|
-
"tmp": "^0.2.5",
|
|
145
|
-
"underscore": "^1.13.8",
|
|
146
|
-
"yaml@npm:^2.6.1": "^2.8.4"
|
|
147
|
-
},
|
|
148
|
-
"packageManager": "yarn@4.9.2",
|
|
149
|
-
"engines": {
|
|
150
|
-
"node": ">=20.0.0"
|
|
151
|
-
},
|
|
152
|
-
"types": "lib/index.d.ts"
|
|
153
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { EventEmitter } from 'node:events'
|
|
4
|
-
import { mkdtemp, writeFile, readdir, utimes, readFile } from 'node:fs/promises'
|
|
5
|
-
import { tmpdir } from 'node:os'
|
|
6
|
-
import { join } from 'node:path'
|
|
7
|
-
import { createRequire } from 'node:module'
|
|
8
|
-
|
|
9
|
-
const X = '../lib/Extras/'
|
|
10
|
-
const { createSendQueue } = await import(X + 'send-queue.js')
|
|
11
|
-
const { attachShortcuts } = await import(X + 'shortcuts.js')
|
|
12
|
-
const { attachPairing } = await import(X + 'pairing.js')
|
|
13
|
-
const { createGroupCache, attachGroupTools } = await import(X + 'group-tools.js')
|
|
14
|
-
const { attachChannelTools, parseChannelRef } = await import(X + 'channel.js')
|
|
15
|
-
const { backupSession, restoreSession, cleanSession } = await import(X + 'session-tools.js')
|
|
16
|
-
const { checkForUpdate, isNewerVersion } = await import(X + 'update-check.js')
|
|
17
|
-
const { useMongoAuthState } = await import(X + 'auth-mongo.js')
|
|
18
|
-
const { useRedisAuthState } = await import(X + 'auth-redis.js')
|
|
19
|
-
const { extendSocket, prepareGroupCache } = await import(X + 'extend.js')
|
|
20
|
-
const { makeKevinXSocket, computeBackoff } = await import(X + 'kevinx-socket.js')
|
|
21
|
-
|
|
22
|
-
const fakeSock = (extra = {}) => {
|
|
23
|
-
const ev = new EventEmitter()
|
|
24
|
-
const sent = []
|
|
25
|
-
return {
|
|
26
|
-
ev: { on: ev.on.bind(ev), off: ev.off.bind(ev), emit: ev.emit.bind(ev) },
|
|
27
|
-
sent, user: { id: '6281111:5@s.whatsapp.net' },
|
|
28
|
-
authState: { creds: { registered: false } },
|
|
29
|
-
sendMessage: async (jid, content, opts) => { sent.push({ jid, content, opts }); return { key: { id: 'X' + sent.length } } },
|
|
30
|
-
sendPresenceUpdate: async (t) => { sent.push({ presence: t }) },
|
|
31
|
-
...extra
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
test('version compare + update check never throws', async () => {
|
|
36
|
-
assert.ok(isNewerVersion('1.2.0', '1.1.9')); assert.ok(!isNewerVersion('1.1.0', '1.1.0')); assert.ok(isNewerVersion('2.0.0', '1.99.99'))
|
|
37
|
-
const ok = await checkForUpdate({ currentVersion: '1.1.0', fetchImpl: async () => ({ ok: true, json: async () => ({ version: '1.2.0' }) }) })
|
|
38
|
-
assert.equal(ok.updateAvailable, true)
|
|
39
|
-
const bad = await checkForUpdate({ currentVersion: '1.1.0', fetchImpl: async () => { throw new Error('offline') } })
|
|
40
|
-
assert.equal(bad.updateAvailable, false); assert.equal(bad.error, 'offline')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('send queue: order, personalised content, failures do not stop it', async () => {
|
|
44
|
-
const sock = fakeSock()
|
|
45
|
-
const q = createSendQueue(sock, { minDelay: 1, maxDelay: 3, retries: 0 })
|
|
46
|
-
const res = await q.broadcast(['a@s.whatsapp.net', 'b@s.whatsapp.net', 'c@s.whatsapp.net'], (jid) => ({ text: 'hi ' + jid }))
|
|
47
|
-
assert.equal(res.length, 3); assert.ok(res.every(r => r.ok))
|
|
48
|
-
assert.deepEqual(sock.sent.map(s => s.jid), ['a@s.whatsapp.net', 'b@s.whatsapp.net', 'c@s.whatsapp.net'])
|
|
49
|
-
const failing = createSendQueue(sock, { minDelay: 1, maxDelay: 2, retries: 0, send: async (jid) => { if (jid === 'bad') throw new Error('boom'); return 'ok' } })
|
|
50
|
-
const r2 = await failing.broadcast(['good', 'bad', 'good2'], { text: 'x' })
|
|
51
|
-
assert.equal(r2.filter(r => r.ok).length, 2); assert.equal(r2.find(r => !r.ok).error, 'boom')
|
|
52
|
-
const p = createSendQueue(sock, { minDelay: 50, maxDelay: 60 }); p.add('1', { text: 'a' }); const second = p.add('2', { text: 'b' }); second.catch(() => {})
|
|
53
|
-
assert.equal(p.clear(), 1)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
test('reply quotes a message, sendWithTyping sends presence then message, status adds own jid', async () => {
|
|
57
|
-
const sock = attachShortcuts(fakeSock())
|
|
58
|
-
const m = { key: { remoteJid: '123@g.us', id: 'M1' }, message: { conversation: 'yo' } }
|
|
59
|
-
await sock.reply(m, 'pong')
|
|
60
|
-
assert.equal(sock.sent[0].jid, '123@g.us'); assert.deepEqual(sock.sent[0].content, { text: 'pong' }); assert.equal(sock.sent[0].opts.quoted, m)
|
|
61
|
-
await sock.reply('555@s.whatsapp.net', { text: 'x' }); assert.equal(sock.sent[1].opts, undefined === 1 ? 0 : sock.sent[1].opts); assert.equal(sock.sent[1].opts?.quoted, undefined)
|
|
62
|
-
sock.sent.length = 0
|
|
63
|
-
await sock.sendWithTyping('555@s.whatsapp.net', 'hello', { typingMs: 5 })
|
|
64
|
-
assert.deepEqual(sock.sent.map(s => s.presence ?? 'msg'), ['composing', 'paused', 'msg'])
|
|
65
|
-
sock.sent.length = 0
|
|
66
|
-
await sock.sendStatusText('hello status', ['0812-3456-7890'.replace(/^0/, '62'), '6285@s.whatsapp.net'])
|
|
67
|
-
const st = sock.sent[0]
|
|
68
|
-
assert.equal(st.jid, 'status@broadcast'); assert.ok(st.opts.statusJidList.includes('6281111@s.whatsapp.net')); assert.ok(st.opts.statusJidList.includes('62812-3456-7890'.replace(/\D/g, '') + '@s.whatsapp.net'))
|
|
69
|
-
assert.equal(st.content.text, 'hello status')
|
|
70
|
-
await assert.rejects(() => { const s = attachShortcuts(fakeSock({ user: undefined })); return s.sendStatus({ text: 'x' }, []) }, /empty/)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test('pair: waits for qr, retries, validates input', async () => {
|
|
74
|
-
let calls = 0
|
|
75
|
-
const sock = attachPairing(fakeSock({ requestPairingCode: async (n, c) => { if (++calls < 3) throw new Error('not ready'); return c ?? 'ABCD-EFGH' } }))
|
|
76
|
-
setTimeout(() => sock.ev.emit('connection.update', { qr: 'qr' }), 20)
|
|
77
|
-
const code = await sock.pair('+62 812-3456-7890', undefined, { retryDelay: 5 })
|
|
78
|
-
assert.equal(code, 'ABCD-EFGH'); assert.equal(calls, 3)
|
|
79
|
-
await assert.rejects(() => sock.pair('12'), /Invalid phone/)
|
|
80
|
-
await assert.rejects(() => sock.pair('628123456789', 'SHORT'), /exactly 8/)
|
|
81
|
-
sock.authState.creds.registered = true
|
|
82
|
-
await assert.rejects(() => sock.pair('628123456789'), /already registered/)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('group cache fall-through, invalidation, tagAll', async () => {
|
|
86
|
-
let fetches = 0
|
|
87
|
-
const meta = { id: 'g@g.us', subject: 'Grup', participants: [{ id: '1@s.whatsapp.net' }, { id: '2@lid', phoneNumber: '2@s.whatsapp.net' }] }
|
|
88
|
-
const cache = createGroupCache({ ttlMs: 1000 })
|
|
89
|
-
const sock = attachGroupTools(fakeSock({ groupMetadata: async () => { fetches++; return meta } }), cache)
|
|
90
|
-
await sock.getGroupMetadata('g@g.us'); await sock.getGroupMetadata('g@g.us'); assert.equal(fetches, 1)
|
|
91
|
-
sock.ev.emit('group-participants.update', { id: 'g@g.us' }); await sock.getGroupMetadata('g@g.us'); assert.equal(fetches, 2)
|
|
92
|
-
await sock.tagAll('g@g.us', 'rapat')
|
|
93
|
-
assert.deepEqual(sock.sent[0].content.mentions, ['1@s.whatsapp.net', '2@s.whatsapp.net'])
|
|
94
|
-
const short = createGroupCache({ ttlMs: 5 }); short.set('a', 1); await new Promise(r => setTimeout(r, 15)); assert.equal(short.get('a'), undefined)
|
|
95
|
-
const pre = prepareGroupCache({}); assert.equal(await pre.cachedGroupMetadata('x'), undefined); assert.equal(prepareGroupCache({ groupCache: false }), undefined)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test('channel helpers parse links and call the existing newsletter functions', async () => {
|
|
99
|
-
assert.deepEqual(parseChannelRef('https://whatsapp.com/channel/0029VaABCdef12'), { type: 'invite', key: '0029VaABCdef12' })
|
|
100
|
-
assert.deepEqual(parseChannelRef('120363@newsletter'), { type: 'jid', key: '120363@newsletter' })
|
|
101
|
-
assert.throws(() => parseChannelRef('!!'), /Cannot understand/)
|
|
102
|
-
const calls = []
|
|
103
|
-
const sock = attachChannelTools(fakeSock({
|
|
104
|
-
newsletterMetadata: async (t, k) => ({ id: '999@newsletter', t, k }), newsletterFollow: async (j) => calls.push(['follow', j]),
|
|
105
|
-
newsletterReactMessage: async (j, id, e) => calls.push(['react', j, id, e])
|
|
106
|
-
}))
|
|
107
|
-
await sock.channel.follow('https://whatsapp.com/channel/0029VaABCdef12'); await sock.channel.react('999@newsletter', 7, '🔥')
|
|
108
|
-
assert.deepEqual(calls, [['follow', '999@newsletter'], ['react', '999@newsletter', '7', '🔥']])
|
|
109
|
-
const many = await sock.channel.followMany(['bad link!!'], { delayMs: 1 }); assert.equal(many[0].ok, false)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
test('session backup / restore / clean', async () => {
|
|
113
|
-
const dir = await mkdtemp(join(tmpdir(), 'kx-')); const sess = join(dir, 'session'); const { mkdir } = await import('node:fs/promises'); await mkdir(sess)
|
|
114
|
-
await writeFile(join(sess, 'creds.json'), '{"a":1}'); await writeFile(join(sess, 'session-1.json'), '{"s":1}')
|
|
115
|
-
await writeFile(join(sess, 'sender-key-memory-old.json'), '{}'); await writeFile(join(sess, 'sender-key-memory-new.json'), '{}'); await writeFile(join(sess, 'device-list-x.json'), '{}')
|
|
116
|
-
const old = new Date(Date.now() - 10 * 86400000); await utimes(join(sess, 'sender-key-memory-old.json'), old, old); await utimes(join(sess, 'creds.json'), old, old); await utimes(join(sess, 'session-1.json'), old, old)
|
|
117
|
-
const dry = await cleanSession(sess, { dryRun: true }); assert.deepEqual(dry.removed, ['sender-key-memory-old.json']); assert.equal((await readdir(sess)).length, 5)
|
|
118
|
-
const real = await cleanSession(sess); assert.deepEqual(real.removed, ['sender-key-memory-old.json']); const left = await readdir(sess)
|
|
119
|
-
assert.ok(left.includes('creds.json') && left.includes('session-1.json') && !left.includes('sender-key-memory-old.json'))
|
|
120
|
-
const out = join(dir, 'bk', 'session-backup-1.kxsession'); const b = await backupSession(sess, out); assert.equal(b.count, 4)
|
|
121
|
-
const restored = join(dir, 'restored'); const r = await restoreSession(out, restored); assert.equal(r.restored, 4); assert.equal(await readFile(join(restored, 'creds.json'), 'utf8'), '{"a":1}')
|
|
122
|
-
await assert.rejects(() => restoreSession(join(sess, 'creds.json'), restored), /valid KevinX/)
|
|
123
|
-
await assert.rejects(() => backupSession(restored + '-none'), /ENOENT/)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
// minimal stand-ins for the library pieces that need native deps
|
|
127
|
-
const deps = {
|
|
128
|
-
BufferJSON: { replacer: (k, v) => (Buffer.isBuffer(v) || v instanceof Uint8Array || v?.type === 'Buffer' ? { type: 'Buffer', data: Buffer.from(v?.data || v).toString('base64') } : v), reviver: (k, v) => (v && v.type === 'Buffer' && typeof v.data === 'string' ? Buffer.from(v.data, 'base64') : v) },
|
|
129
|
-
initAuthCreds: () => ({ fresh: true, noise: Buffer.from('abc') }),
|
|
130
|
-
proto: { Message: { AppStateSyncKeyData: { fromObject: (o) => ({ wrapped: o }) } } }
|
|
131
|
-
}
|
|
132
|
-
const roundTrip = async (state, saveCreds) => {
|
|
133
|
-
assert.equal(state.creds.fresh, true); state.creds.extra = Buffer.from('zz'); await saveCreds()
|
|
134
|
-
await state.keys.set({ session: { 'a/b:1': { k: Buffer.from('hello') } }, 'app-state-sync-key': { K1: { keyData: 1 } } })
|
|
135
|
-
const got = await state.keys.get('session', ['a/b:1', 'nope']); assert.equal(got['a/b:1'].k.toString(), 'hello'); assert.equal(got.nope, null)
|
|
136
|
-
assert.deepEqual((await state.keys.get('app-state-sync-key', ['K1'])).K1, { wrapped: { keyData: 1 } })
|
|
137
|
-
await state.keys.set({ session: { 'a/b:1': null } }); assert.equal((await state.keys.get('session', ['a/b:1']))['a/b:1'], null)
|
|
138
|
-
}
|
|
139
|
-
test('mongo auth state (fake collection)', async () => {
|
|
140
|
-
const db = new Map()
|
|
141
|
-
const col = { findOne: async ({ _id }) => (db.has(_id) ? { _id, value: db.get(_id) } : null),
|
|
142
|
-
replaceOne: async ({ _id }, doc) => { db.set(_id, doc.value) }, deleteOne: async ({ _id }) => { db.delete(_id) },
|
|
143
|
-
bulkWrite: async (ops) => { for (const o of ops) { if (o.replaceOne) db.set(o.replaceOne.filter._id, o.replaceOne.replacement.value); else db.delete(o.deleteOne.filter._id) } },
|
|
144
|
-
deleteMany: async ({ _id: { $regex } }) => { for (const k of [...db.keys()]) if (new RegExp($regex).test(k)) db.delete(k) } }
|
|
145
|
-
const { state, saveCreds, clear } = await useMongoAuthState(col, { sessionId: 'bot1', deps }); await roundTrip(state, saveCreds)
|
|
146
|
-
const again = await useMongoAuthState(col, { sessionId: 'bot1', deps }); assert.equal(again.state.creds.extra.toString(), 'zz'); assert.equal((await useMongoAuthState(col, { sessionId: 'other', deps })).state.creds.extra, undefined)
|
|
147
|
-
await clear(); assert.equal(db.size, 0)
|
|
148
|
-
await assert.rejects(() => useMongoAuthState({}), /collection/)
|
|
149
|
-
})
|
|
150
|
-
test('redis auth state (fake client, both ttl styles)', async () => {
|
|
151
|
-
const db = new Map(); const ttl = []
|
|
152
|
-
const client = { get: async (k) => db.get(k) ?? null, set: async (k, v) => { db.set(k, v) }, setex: async (k, s, v) => { ttl.push(s); db.set(k, v) }, del: async (k) => { for (const x of [k].flat()) db.delete(x) }, keys: async (p) => [...db.keys()].filter(k => k.startsWith(p.replace('*', ''))) }
|
|
153
|
-
const { state, saveCreds, clear } = await useRedisAuthState(client, { prefix: 'wa:t', deps }); await roundTrip(state, saveCreds)
|
|
154
|
-
assert.ok([...db.keys()].every(k => k.startsWith('wa:t:'))); await clear(); assert.equal(db.size, 0)
|
|
155
|
-
const nodeRedis = { ...client, setex: undefined, setEx: async (k, s, v) => { ttl.push('E' + s); db.set(k, v) } }
|
|
156
|
-
await (await useRedisAuthState(nodeRedis, { ttlSeconds: 60, deps })).saveCreds(); assert.deepEqual(ttl, ['E60'])
|
|
157
|
-
await assert.rejects(() => useRedisAuthState({}), /client/)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
test('extendSocket adds helpers but never overwrites existing methods', () => {
|
|
161
|
-
const sock = fakeSock({ sendText: () => 'original', reply: () => 'mine' })
|
|
162
|
-
const gc = prepareGroupCache({}); extendSocket(sock, { groupCache: gc })
|
|
163
|
-
assert.equal(sock.sendText(), 'original'); assert.equal(sock.reply(), 'mine')
|
|
164
|
-
for (const k of ['pair', 'broadcast', 'queue', 'channel', 'tagAll', 'sendWithTyping', 'sendStatusText', 'getGroupMetadata']) assert.ok(sock[k], k)
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
test('backoff grows, is capped, and reconnect policy behaves', async () => {
|
|
168
|
-
assert.ok(computeBackoff(1, { jitter: 0 }) === 2000 && computeBackoff(3, { jitter: 0 }) === 8000 && computeBackoff(20, { jitter: 0 }) === 60000)
|
|
169
|
-
const made = []; const log = { closes: [], reconnecting: [], loggedOut: 0, open: 0 }
|
|
170
|
-
globalThis.__makeFake = (cfg) => { const s = fakeSock({ end: () => {}, pair: async () => 'PAIR-CODE', channel: { followMany: async () => {} } }); s.cfg = cfg; made.push(s); return s }
|
|
171
|
-
const bot = await makeKevinXSocket({ checkUpdate: false, reconnect: { minDelay: 5, maxDelay: 20, jitter: 0 }, onSocket: () => {}, onClose: (c) => log.closes.push(c.code), onReconnecting: (r) => log.reconnecting.push(r.attempt), onLoggedOut: () => log.loggedOut++, onOpen: () => log.open++ })
|
|
172
|
-
const close = (s, statusCode) => s.ev.emit('connection.update', { connection: 'close', lastDisconnect: { error: { output: { statusCode } } } })
|
|
173
|
-
assert.equal(made.length, 1); assert.deepEqual(made[0].cfg.version, [2, 3000, 1]); assert.equal(bot.sock, made[0])
|
|
174
|
-
made[0].ev.emit('connection.update', { connection: 'open' }); assert.equal(log.open, 1); assert.equal(await bot.ready(), made[0])
|
|
175
|
-
close(made[0], 428); await new Promise(r => setTimeout(r, 40)); assert.equal(made.length, 2); assert.deepEqual(log.reconnecting, [1])
|
|
176
|
-
close(made[0], 428); await new Promise(r => setTimeout(r, 40)); assert.equal(made.length, 2, 'stale socket close is ignored')
|
|
177
|
-
close(made[1], 515); await new Promise(r => setTimeout(r, 700)); assert.equal(made.length, 3, 'restartRequired reconnects fast, no backoff')
|
|
178
|
-
assert.deepEqual(log.reconnecting, [1])
|
|
179
|
-
close(made[2], 401); await new Promise(r => setTimeout(r, 40)); assert.equal(made.length, 3); assert.equal(log.loggedOut, 1)
|
|
180
|
-
const bot2 = await makeKevinXSocket({ checkUpdate: false, reconnect: { minDelay: 5 } }); const s2 = made.at(-1); close(s2, 440); await new Promise(r => setTimeout(r, 30)); assert.equal(made.at(-1), s2, '440 connectionReplaced does not loop')
|
|
181
|
-
await bot2.stop()
|
|
182
|
-
globalThis.__registered = false; let code; const before = made.length
|
|
183
|
-
await makeKevinXSocket({ checkUpdate: false, pairingNumber: '628123456789', onPairingCode: (c) => { code = c } }); await new Promise(r => setTimeout(r, 20))
|
|
184
|
-
assert.equal(code, 'PAIR-CODE'); assert.equal(made.length, before + 1)
|
|
185
|
-
const bot3 = await makeKevinXSocket({ checkUpdate: false, reconnect: { minDelay: 5, maxDelay: 5, jitter: 0, maxRetries: 2 } }); const errs = [];
|
|
186
|
-
await bot3.stop(); close(made.at(-1), 428); await new Promise(r => setTimeout(r, 30)); assert.ok(true)
|
|
187
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Replaces the heavy library imports with fakes so kevinx-socket.js can be tested without node_modules.
|
|
2
|
-
const FAKES = {
|
|
3
|
-
'../Socket/index.js': `export default (cfg) => globalThis.__makeFake(cfg)`,
|
|
4
|
-
'../Utils/use-multi-file-auth-state.js': `export const useMultiFileAuthState = async () => ({ state: { creds: { registered: globalThis.__registered ?? true } }, saveCreds: async () => {} })`,
|
|
5
|
-
'../Utils/generics.js': `export const fetchLatestBaileysVersion = async () => ({ version: [2, 3000, 1] })`
|
|
6
|
-
}
|
|
7
|
-
export async function resolve(specifier, context, next) {
|
|
8
|
-
if (FAKES[specifier] && context.parentURL?.includes('kevinx-socket.js')) return { url: 'data:text/javascript,' + encodeURIComponent(FAKES[specifier]), shortCircuit: true }
|
|
9
|
-
return next(specifier, context)
|
|
10
|
-
}
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|