voice-calls-baileys 1.0.7 → 1.0.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/lib/demo.js +20 -9
- package/lib/services/transport.model.d.ts +1 -1
- package/lib/services/transport.model.js +53 -103
- package/lib/services/transport.type.d.ts +16 -9
- package/package.json +1 -1
- package/src/demo.ts +3 -2
- package/src/services/transport.model.ts +65 -168
- package/src/services/transport.type.ts +14 -9
package/lib/demo.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -34,12 +44,13 @@ async function connectToWhatsApp() {
|
|
|
34
44
|
const sock = (0, baileys_1.default)({
|
|
35
45
|
printQRInTerminal: true,
|
|
36
46
|
auth: state,
|
|
37
|
-
browser: baileys_1.Browsers.
|
|
47
|
+
browser: baileys_1.Browsers.windows("UWP"),
|
|
48
|
+
version: [2, 3000, 1031141796, 257538, 0],
|
|
38
49
|
logger: (0, pino_1.default)({ level: "error" }),
|
|
39
50
|
syncFullHistory: false,
|
|
40
51
|
markOnlineOnConnect: false
|
|
41
52
|
});
|
|
42
|
-
(0, transport_model_1.useVoiceCallsBaileys)("
|
|
53
|
+
(0, transport_model_1.useVoiceCallsBaileys)("<Your Wavoip Token>", sock, "<Your Software Name>", "close", true);
|
|
43
54
|
sock.ev.on("creds.update", saveCreds);
|
|
44
55
|
sock.ev.on('connection.update', (update) => {
|
|
45
56
|
var _a, _b;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Socket } from "socket.io-client";
|
|
2
2
|
import { ClientToServerEvents, ServerToClientEvents } from "./transport.type";
|
|
3
3
|
import { WAConnectionState, WASocket } from "baileys";
|
|
4
|
-
export declare const useVoiceCallsBaileys: (wavoip_token: string, baileys_sock: WASocket, status?: WAConnectionState, logger?: boolean) => Promise<Socket<ServerToClientEvents, ClientToServerEvents>>;
|
|
4
|
+
export declare const useVoiceCallsBaileys: (wavoip_token: string, baileys_sock: WASocket, softwareBase: string, status?: WAConnectionState, logger?: boolean) => Promise<Socket<ServerToClientEvents, ClientToServerEvents>>;
|
|
@@ -3,152 +3,102 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useVoiceCallsBaileys = void 0;
|
|
4
4
|
const socket_io_client_1 = require("socket.io-client");
|
|
5
5
|
let baileys_connection_state = "close";
|
|
6
|
-
const useVoiceCallsBaileys = async (wavoip_token, baileys_sock, status, logger) => {
|
|
7
|
-
baileys_connection_state = status !== null && status !== void 0 ? status : "close";
|
|
6
|
+
const useVoiceCallsBaileys = async (wavoip_token, baileys_sock, softwareBase, status, logger) => {
|
|
8
7
|
const socket = (0, socket_io_client_1.io)("https://devices.wavoip.com/baileys", {
|
|
9
8
|
transports: ["websocket"],
|
|
10
9
|
path: `/${wavoip_token}/websocket`
|
|
11
10
|
});
|
|
12
11
|
socket.on("connect", () => {
|
|
13
12
|
if (logger)
|
|
14
|
-
console.log("[
|
|
15
|
-
socket.emit("init", baileys_sock.authState.creds.me, baileys_sock.authState.creds.account,
|
|
13
|
+
console.log("[Wavoip] - Connected", socket.id);
|
|
14
|
+
socket.emit("init", baileys_sock.authState.creds.me, baileys_sock.authState.creds.account, status !== null && status !== void 0 ? status : "close", softwareBase);
|
|
16
15
|
});
|
|
17
16
|
socket.on("disconnect", () => {
|
|
18
17
|
if (logger)
|
|
19
|
-
console.log("[
|
|
18
|
+
console.log("[Wavoip] - Disconnected");
|
|
20
19
|
});
|
|
21
20
|
socket.on("connect_error", (error) => {
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
console.log("[*] - Wavoip connection error temporary failure, the socket will automatically try to reconnect", error);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
if (logger)
|
|
28
|
-
console.log("[*] - Wavoip connection error", error.message);
|
|
29
|
-
}
|
|
21
|
+
if (logger)
|
|
22
|
+
console.log("[Wavoip] - Connection lost");
|
|
30
23
|
});
|
|
31
|
-
socket.on("onWhatsApp",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (logger)
|
|
40
|
-
console.error("[*] Error on call onWhatsApp function", error);
|
|
41
|
-
}
|
|
24
|
+
socket.on("onWhatsApp", (jid, callback) => {
|
|
25
|
+
baileys_sock.onWhatsApp(jid)
|
|
26
|
+
.then((response) => callback(response))
|
|
27
|
+
.catch((error) => {
|
|
28
|
+
callback({ wavoipStatus: "error", result: error });
|
|
29
|
+
if (logger)
|
|
30
|
+
console.log("[Wavoip] - Failed to call onWhatsapp, error: ", error);
|
|
31
|
+
});
|
|
42
32
|
});
|
|
43
33
|
socket.on("profilePictureUrl", async (jid, type, timeoutMs, callback) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
baileys_sock.profilePictureUrl(jid, type, timeoutMs)
|
|
35
|
+
.then((response) => callback(response))
|
|
36
|
+
.catch((error) => {
|
|
37
|
+
callback({ wavoipStatus: "error", result: error });
|
|
47
38
|
if (logger)
|
|
48
|
-
console.log("[
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (logger)
|
|
52
|
-
console.error("[*] Error on call profilePictureUrl function", error);
|
|
53
|
-
}
|
|
39
|
+
console.log("[Wavoip] - Failed to call profilePictureUrl, error: ", error);
|
|
40
|
+
});
|
|
54
41
|
});
|
|
55
42
|
socket.on("assertSessions", async (jids, force, callback) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log("[*] Success on call assertSessions function", response);
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
43
|
+
baileys_sock.assertSessions(jids, force)
|
|
44
|
+
.then((response) => callback(response))
|
|
45
|
+
.catch((error) => {
|
|
46
|
+
callback({ wavoipStatus: "error", result: error });
|
|
63
47
|
if (logger)
|
|
64
|
-
console.
|
|
65
|
-
}
|
|
48
|
+
console.log("[Wavoip] - Failed to call assertSessions, error: ", error);
|
|
49
|
+
});
|
|
66
50
|
});
|
|
67
51
|
socket.on("createParticipantNodes", async (jids, message, extraAttrs, callback) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
console.log("[*] Success on call createParticipantNodes function", response);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
52
|
+
baileys_sock.createParticipantNodes(jids, message, extraAttrs)
|
|
53
|
+
.then((response) => callback(response.nodes, response.shouldIncludeDeviceIdentity))
|
|
54
|
+
.catch((error) => {
|
|
55
|
+
callback({ wavoipStatus: "error", result: error });
|
|
75
56
|
if (logger)
|
|
76
|
-
console.
|
|
77
|
-
}
|
|
57
|
+
console.log("[Wavoip] - Failed to call createParticipantNodes, error: ", error);
|
|
58
|
+
});
|
|
78
59
|
});
|
|
79
60
|
socket.on("getUSyncDevices", async (jids, useCache, ignoreZeroDevices, callback) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log("[*] Success on call getUSyncDevices function", response);
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
61
|
+
baileys_sock.getUSyncDevices(jids, useCache, ignoreZeroDevices)
|
|
62
|
+
.then((response) => callback(response))
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
callback({ wavoipStatus: "error", result: error });
|
|
87
65
|
if (logger)
|
|
88
|
-
console.
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
socket.on("generateMessageTag", async (callback) => {
|
|
92
|
-
try {
|
|
93
|
-
const response = await baileys_sock.generateMessageTag();
|
|
94
|
-
callback(response);
|
|
95
|
-
if (logger)
|
|
96
|
-
console.log("[*] Success on call generateMessageTag function", response);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
if (logger)
|
|
100
|
-
console.error("[*] Error on call generateMessageTag function", error);
|
|
101
|
-
}
|
|
66
|
+
console.log("[Wavoip] - Failed to call createParticipantNodes, error: ", error);
|
|
67
|
+
});
|
|
102
68
|
});
|
|
69
|
+
socket.on("generateMessageTag", (callback) => callback(baileys_sock.generateMessageTag()));
|
|
103
70
|
socket.on("sendNode", async (stanza, callback) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
71
|
+
baileys_sock.sendNode(stanza)
|
|
72
|
+
.then((response) => callback(true))
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
callback({ wavoipStatus: "error", result: error });
|
|
107
75
|
if (logger)
|
|
108
|
-
console.log("[
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
if (logger)
|
|
112
|
-
console.error("[*] Error on call sendNode function", error);
|
|
113
|
-
}
|
|
76
|
+
console.log("[Wavoip] - Failed to call createParticipantNodes, error: ", error);
|
|
77
|
+
});
|
|
114
78
|
});
|
|
115
79
|
socket.on("signalRepository:decryptMessage", async (jid, type, ciphertext, callback) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
ciphertext: ciphertext,
|
|
121
|
-
});
|
|
122
|
-
callback(response);
|
|
123
|
-
if (logger)
|
|
124
|
-
console.log("[*] Success on call signalRepository:decryptMessage function", response);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
80
|
+
baileys_sock.signalRepository.decryptMessage({ jid: jid, type: type, ciphertext: ciphertext })
|
|
81
|
+
.then((response) => callback(response))
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
callback({ wavoipStatus: "error", result: error });
|
|
127
84
|
if (logger)
|
|
128
|
-
console.
|
|
129
|
-
}
|
|
85
|
+
console.log("[Wavoip] - Failed to call decryptMessage, error: ", error);
|
|
86
|
+
});
|
|
130
87
|
});
|
|
131
|
-
// we only use this connection data to inform the webphone that the device is connected and creeds account to generate e2e whatsapp key for make call packets
|
|
132
88
|
baileys_sock.ev.on("connection.update", (update) => {
|
|
133
89
|
const { connection } = update;
|
|
134
90
|
if (connection) {
|
|
135
|
-
|
|
136
|
-
socket
|
|
137
|
-
.timeout(1000)
|
|
138
|
-
.emit("connection.update:status", baileys_sock.authState.creds.me, baileys_sock.authState.creds.account, connection);
|
|
91
|
+
console.log(connection);
|
|
92
|
+
socket.timeout(1000).emit("connection.update:status", baileys_sock.authState.creds.me, baileys_sock.authState.creds.account, connection);
|
|
139
93
|
}
|
|
140
94
|
if (update.qr) {
|
|
141
95
|
socket.timeout(1000).emit("connection.update:qr", update.qr);
|
|
142
96
|
}
|
|
143
97
|
});
|
|
144
98
|
baileys_sock.ws.on("CB:call", (packet) => {
|
|
145
|
-
if (logger)
|
|
146
|
-
console.log("[*] Signling received");
|
|
147
99
|
socket.volatile.timeout(1000).emit("CB:call", packet);
|
|
148
100
|
});
|
|
149
101
|
baileys_sock.ws.on("CB:ack,class:call", (packet) => {
|
|
150
|
-
if (logger)
|
|
151
|
-
console.log("[*] Signling ack received");
|
|
152
102
|
socket.volatile.timeout(1000).emit("CB:ack,class:call", packet);
|
|
153
103
|
});
|
|
154
104
|
return socket;
|
|
@@ -11,28 +11,35 @@ export interface ServerToClientEvents {
|
|
|
11
11
|
"signalRepository:decryptMessage": SignalRepositoryDecryptMessageType;
|
|
12
12
|
}
|
|
13
13
|
export interface ClientToServerEvents {
|
|
14
|
-
"init": (me: Contact | undefined, account: proto.IADVSignedDeviceIdentity | undefined, status: WAConnectionState) => void;
|
|
14
|
+
"init": (me: Contact | undefined, account: proto.IADVSignedDeviceIdentity | undefined, status: WAConnectionState, softwareBase: string) => void;
|
|
15
15
|
"CB:call": (packet: any) => void;
|
|
16
16
|
"CB:ack,class:call": (packet: any) => void;
|
|
17
17
|
"connection.update:status": (me: Contact | undefined, account: proto.IADVSignedDeviceIdentity | undefined, status: WAConnectionState) => void;
|
|
18
18
|
"connection.update:qr": (qr: string) => void;
|
|
19
19
|
}
|
|
20
|
+
export type FailedResponseType = {
|
|
21
|
+
wavoipStatus: string;
|
|
22
|
+
result: any;
|
|
23
|
+
};
|
|
20
24
|
export type onWhatsAppType = (jid: string, callback: onWhatsAppCallback) => void;
|
|
21
25
|
export type onWhatsAppCallback = (response: {
|
|
22
26
|
exists: boolean;
|
|
23
27
|
jid: string;
|
|
24
|
-
}[]) => void;
|
|
28
|
+
}[] | FailedResponseType | undefined) => void;
|
|
25
29
|
export type ProfilePictureUrlType = (jid: string, type: "image" | "preview", timeoutMs: number | undefined, callback: ProfilePictureUrlCallback) => void;
|
|
26
|
-
export type ProfilePictureUrlCallback = (response: string | undefined) => void;
|
|
30
|
+
export type ProfilePictureUrlCallback = (response: string | FailedResponseType | undefined) => void;
|
|
27
31
|
export type AssertSessionsType = (jids: string[], force: boolean, callback: AssertSessionsCallback) => void;
|
|
28
|
-
export type AssertSessionsCallback = (response: boolean) => void;
|
|
32
|
+
export type AssertSessionsCallback = (response: boolean | FailedResponseType) => void;
|
|
29
33
|
export type CreateParticipantNodesType = (jids: string[], message: any, extraAttrs: any, callback: CreateParticipantNodesCallback) => void;
|
|
30
|
-
export type CreateParticipantNodesCallback =
|
|
34
|
+
export type CreateParticipantNodesCallback = {
|
|
35
|
+
(nodes: any, shouldIncludeDeviceIdentity: boolean): void;
|
|
36
|
+
(response: FailedResponseType): void;
|
|
37
|
+
};
|
|
31
38
|
export type GetUSyncDevicesType = (jids: string[], useCache: boolean, ignoreZeroDevices: boolean, callback: GetUSyncDevicesTypeCallback) => void;
|
|
32
|
-
export type GetUSyncDevicesTypeCallback = (jids: JidWithDevice[]) => void;
|
|
39
|
+
export type GetUSyncDevicesTypeCallback = (jids: JidWithDevice[] | FailedResponseType) => void;
|
|
33
40
|
export type GenerateMessageTagType = (callback: GenerateMessageTagTypeCallback) => void;
|
|
34
|
-
export type GenerateMessageTagTypeCallback = (response: string) => void;
|
|
41
|
+
export type GenerateMessageTagTypeCallback = (response: string | FailedResponseType) => void;
|
|
35
42
|
export type SendNodeType = (stanza: BinaryNode, callback: SendNodeTypeCallback) => void;
|
|
36
|
-
export type SendNodeTypeCallback = (response: boolean) => void;
|
|
43
|
+
export type SendNodeTypeCallback = (response: boolean | FailedResponseType) => void;
|
|
37
44
|
export type SignalRepositoryDecryptMessageType = (jid: string, type: "pkmsg" | "msg", ciphertext: Buffer, callback: SignalRepositoryDecryptMessageCallback) => void;
|
|
38
|
-
export type SignalRepositoryDecryptMessageCallback = (response:
|
|
45
|
+
export type SignalRepositoryDecryptMessageCallback = (response: Uint8Array | FailedResponseType) => void;
|
package/package.json
CHANGED
package/src/demo.ts
CHANGED
|
@@ -9,13 +9,14 @@ async function connectToWhatsApp() {
|
|
|
9
9
|
const sock = makeWASocket({
|
|
10
10
|
printQRInTerminal: true,
|
|
11
11
|
auth: state,
|
|
12
|
-
browser: Browsers.
|
|
12
|
+
browser: Browsers.windows("UWP"),
|
|
13
|
+
version: [2, 3000, 1031141796, 257538, 0],
|
|
13
14
|
logger: P({ level: "error" }),
|
|
14
15
|
syncFullHistory: false,
|
|
15
16
|
markOnlineOnConnect: false
|
|
16
17
|
})
|
|
17
18
|
|
|
18
|
-
useVoiceCallsBaileys("
|
|
19
|
+
useVoiceCallsBaileys("<Your Wavoip Token>", sock, "<Your Software Name>", "close", true)
|
|
19
20
|
|
|
20
21
|
sock.ev.on("creds.update", saveCreds);
|
|
21
22
|
|
|
@@ -4,18 +4,15 @@ import { ClientToServerEvents, ServerToClientEvents } from "./transport.type";
|
|
|
4
4
|
|
|
5
5
|
import { ConnectionState, WAConnectionState, WASocket } from "baileys";
|
|
6
6
|
|
|
7
|
-
import { Logger } from "pino";
|
|
8
|
-
|
|
9
7
|
let baileys_connection_state: WAConnectionState = "close";
|
|
10
8
|
|
|
11
9
|
export const useVoiceCallsBaileys = async (
|
|
12
10
|
wavoip_token: string,
|
|
13
11
|
baileys_sock: WASocket,
|
|
12
|
+
softwareBase: string,
|
|
14
13
|
status?: WAConnectionState,
|
|
15
14
|
logger?: boolean
|
|
16
15
|
) => {
|
|
17
|
-
baileys_connection_state = status ?? "close";
|
|
18
|
-
|
|
19
16
|
const socket: Socket<ServerToClientEvents, ClientToServerEvents> = io(
|
|
20
17
|
"https://devices.wavoip.com/baileys",
|
|
21
18
|
{
|
|
@@ -25,198 +22,100 @@ export const useVoiceCallsBaileys = async (
|
|
|
25
22
|
);
|
|
26
23
|
|
|
27
24
|
socket.on("connect", () => {
|
|
28
|
-
if (logger) console.log("[
|
|
25
|
+
if (logger) console.log("[Wavoip] - Connected", socket.id);
|
|
29
26
|
|
|
30
27
|
socket.emit(
|
|
31
|
-
"init",
|
|
28
|
+
"init",
|
|
32
29
|
baileys_sock.authState.creds.me,
|
|
33
|
-
baileys_sock.authState.creds.account,
|
|
34
|
-
|
|
30
|
+
baileys_sock.authState.creds.account,
|
|
31
|
+
status ?? "close",
|
|
32
|
+
softwareBase
|
|
35
33
|
);
|
|
36
34
|
});
|
|
37
35
|
|
|
38
36
|
socket.on("disconnect", () => {
|
|
39
|
-
if (logger) console.log("[
|
|
37
|
+
if (logger) console.log("[Wavoip] - Disconnected");
|
|
40
38
|
});
|
|
41
39
|
|
|
42
40
|
socket.on("connect_error", (error) => {
|
|
43
|
-
if (
|
|
44
|
-
if (logger)
|
|
45
|
-
console.log(
|
|
46
|
-
"[*] - Wavoip connection error temporary failure, the socket will automatically try to reconnect",
|
|
47
|
-
error
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
if (logger) console.log("[*] - Wavoip connection error", error.message);
|
|
51
|
-
}
|
|
41
|
+
if (logger) console.log("[Wavoip] - Connection lost");
|
|
52
42
|
});
|
|
53
43
|
|
|
54
|
-
socket.on("onWhatsApp",
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.log("[*] Success on call onWhatsApp function", response, jid);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
if (logger) console.error("[*] Error on call onWhatsApp function", error);
|
|
64
|
-
}
|
|
44
|
+
socket.on("onWhatsApp", (jid, callback) => {
|
|
45
|
+
baileys_sock.onWhatsApp(jid)
|
|
46
|
+
.then((response) => callback(response))
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
callback({wavoipStatus: "error", result: error});
|
|
49
|
+
if (logger) console.log("[Wavoip] - Failed to call onWhatsapp, error: ", error)
|
|
50
|
+
});
|
|
65
51
|
});
|
|
66
52
|
|
|
67
53
|
socket.on("profilePictureUrl", async (jid, type, timeoutMs, callback) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
callback(response);
|
|
76
|
-
|
|
77
|
-
if (logger)
|
|
78
|
-
console.log("[*] Success on call profilePictureUrl function", response);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
if (logger)
|
|
81
|
-
console.error("[*] Error on call profilePictureUrl function", error);
|
|
82
|
-
}
|
|
54
|
+
baileys_sock.profilePictureUrl(jid, type, timeoutMs)
|
|
55
|
+
.then((response) => callback(response))
|
|
56
|
+
.catch((error) => {
|
|
57
|
+
callback({wavoipStatus: "error", result: error});
|
|
58
|
+
if (logger) console.log("[Wavoip] - Failed to call profilePictureUrl, error: ", error)
|
|
59
|
+
});
|
|
83
60
|
});
|
|
84
61
|
|
|
85
62
|
socket.on("assertSessions", async (jids, force, callback) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
console.log("[*] Success on call assertSessions function", response);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
if (logger)
|
|
95
|
-
console.error("[*] Error on call assertSessions function", error);
|
|
96
|
-
}
|
|
63
|
+
baileys_sock.assertSessions(jids, force)
|
|
64
|
+
.then((response) => callback(response))
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
callback({wavoipStatus: "error", result: error});
|
|
67
|
+
if (logger) console.log("[Wavoip] - Failed to call assertSessions, error: ", error)
|
|
68
|
+
});
|
|
97
69
|
});
|
|
98
70
|
|
|
99
|
-
socket.on(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
extraAttrs
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
callback(response, true);
|
|
110
|
-
|
|
111
|
-
if (logger)
|
|
112
|
-
console.log(
|
|
113
|
-
"[*] Success on call createParticipantNodes function",
|
|
114
|
-
response
|
|
115
|
-
);
|
|
116
|
-
} catch (error) {
|
|
117
|
-
if (logger)
|
|
118
|
-
console.error(
|
|
119
|
-
"[*] Error on call createParticipantNodes function",
|
|
120
|
-
error
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
socket.on(
|
|
127
|
-
"getUSyncDevices",
|
|
128
|
-
async (jids, useCache, ignoreZeroDevices, callback) => {
|
|
129
|
-
try {
|
|
130
|
-
const response = await baileys_sock.getUSyncDevices(
|
|
131
|
-
jids,
|
|
132
|
-
useCache,
|
|
133
|
-
ignoreZeroDevices
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
callback(response);
|
|
137
|
-
|
|
138
|
-
if (logger)
|
|
139
|
-
console.log("[*] Success on call getUSyncDevices function", response);
|
|
140
|
-
} catch (error) {
|
|
141
|
-
if (logger)
|
|
142
|
-
console.error("[*] Error on call getUSyncDevices function", error);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
socket.on("generateMessageTag", async (callback) => {
|
|
148
|
-
try {
|
|
149
|
-
const response = await baileys_sock.generateMessageTag();
|
|
150
|
-
|
|
151
|
-
callback(response);
|
|
152
|
-
|
|
153
|
-
if (logger)
|
|
154
|
-
console.log(
|
|
155
|
-
"[*] Success on call generateMessageTag function",
|
|
156
|
-
response
|
|
157
|
-
);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
if (logger)
|
|
160
|
-
console.error("[*] Error on call generateMessageTag function", error);
|
|
161
|
-
}
|
|
71
|
+
socket.on("createParticipantNodes", async (jids, message, extraAttrs, callback) => {
|
|
72
|
+
baileys_sock.createParticipantNodes(jids, message, extraAttrs)
|
|
73
|
+
.then((response) => callback(response.nodes, response.shouldIncludeDeviceIdentity))
|
|
74
|
+
.catch((error) => {
|
|
75
|
+
callback({wavoipStatus: "error", result: error});
|
|
76
|
+
if (logger) console.log("[Wavoip] - Failed to call createParticipantNodes, error: ", error)
|
|
77
|
+
});
|
|
162
78
|
});
|
|
163
79
|
|
|
164
|
-
socket.on("
|
|
165
|
-
|
|
166
|
-
|
|
80
|
+
socket.on("getUSyncDevices", async (jids, useCache, ignoreZeroDevices, callback) => {
|
|
81
|
+
baileys_sock.getUSyncDevices(jids, useCache, ignoreZeroDevices)
|
|
82
|
+
.then((response) => callback(response))
|
|
83
|
+
.catch((error) => {
|
|
84
|
+
callback({wavoipStatus: "error", result: error});
|
|
85
|
+
if (logger) console.log("[Wavoip] - Failed to call createParticipantNodes, error: ", error)
|
|
86
|
+
});
|
|
87
|
+
});
|
|
167
88
|
|
|
168
|
-
|
|
89
|
+
socket.on("generateMessageTag", (callback) => callback(baileys_sock.generateMessageTag()));
|
|
169
90
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
91
|
+
socket.on("sendNode", async (stanza, callback) => {
|
|
92
|
+
baileys_sock.sendNode(stanza)
|
|
93
|
+
.then((response) => callback(true))
|
|
94
|
+
.catch((error) => {
|
|
95
|
+
callback({wavoipStatus: "error", result: error});
|
|
96
|
+
if (logger) console.log("[Wavoip] - Failed to call createParticipantNodes, error: ", error)
|
|
97
|
+
});
|
|
175
98
|
});
|
|
176
99
|
|
|
177
|
-
socket.on(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
callback(response);
|
|
188
|
-
|
|
189
|
-
if (logger)
|
|
190
|
-
console.log(
|
|
191
|
-
"[*] Success on call signalRepository:decryptMessage function",
|
|
192
|
-
response
|
|
193
|
-
);
|
|
194
|
-
} catch (error) {
|
|
195
|
-
if (logger)
|
|
196
|
-
console.error(
|
|
197
|
-
"[*] Error on call signalRepository:decryptMessage function",
|
|
198
|
-
error
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
);
|
|
100
|
+
socket.on("signalRepository:decryptMessage", async (jid, type, ciphertext, callback) => {
|
|
101
|
+
baileys_sock.signalRepository.decryptMessage({jid: jid, type: type, ciphertext: ciphertext})
|
|
102
|
+
.then((response) => callback(response))
|
|
103
|
+
.catch((error) => {
|
|
104
|
+
callback({wavoipStatus: "error", result: error});
|
|
105
|
+
if (logger) console.log("[Wavoip] - Failed to call decryptMessage, error: ", error)
|
|
106
|
+
});
|
|
107
|
+
});
|
|
203
108
|
|
|
204
|
-
|
|
205
|
-
baileys_sock.ev.on(
|
|
206
|
-
"connection.update",
|
|
207
|
-
(update: Partial<ConnectionState>) => {
|
|
109
|
+
baileys_sock.ev.on("connection.update", (update: Partial<ConnectionState>) => {
|
|
208
110
|
const { connection } = update;
|
|
209
111
|
|
|
210
112
|
if (connection) {
|
|
211
|
-
|
|
212
|
-
socket
|
|
213
|
-
.
|
|
214
|
-
.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
baileys_sock.authState.creds.account,
|
|
218
|
-
connection
|
|
219
|
-
);
|
|
113
|
+
console.log(connection)
|
|
114
|
+
socket.timeout(1000).emit("connection.update:status",
|
|
115
|
+
baileys_sock.authState.creds.me,
|
|
116
|
+
baileys_sock.authState.creds.account,
|
|
117
|
+
connection
|
|
118
|
+
);
|
|
220
119
|
}
|
|
221
120
|
|
|
222
121
|
if (update.qr) {
|
|
@@ -226,12 +125,10 @@ export const useVoiceCallsBaileys = async (
|
|
|
226
125
|
);
|
|
227
126
|
|
|
228
127
|
baileys_sock.ws.on("CB:call", (packet) => {
|
|
229
|
-
if (logger) console.log("[*] Signling received");
|
|
230
128
|
socket.volatile.timeout(1000).emit("CB:call", packet);
|
|
231
129
|
});
|
|
232
130
|
|
|
233
131
|
baileys_sock.ws.on("CB:ack,class:call", (packet) => {
|
|
234
|
-
if (logger) console.log("[*] Signling ack received");
|
|
235
132
|
socket.volatile.timeout(1000).emit("CB:ack,class:call", packet);
|
|
236
133
|
});
|
|
237
134
|
|
|
@@ -13,36 +13,41 @@ export interface ServerToClientEvents {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface ClientToServerEvents {
|
|
16
|
-
"init": (me: Contact | undefined, account: proto.IADVSignedDeviceIdentity | undefined, status: WAConnectionState) => void;
|
|
16
|
+
"init": (me: Contact | undefined, account: proto.IADVSignedDeviceIdentity | undefined, status: WAConnectionState, softwareBase: string) => void;
|
|
17
17
|
"CB:call": (packet: any) => void;
|
|
18
18
|
"CB:ack,class:call": (packet: any) => void;
|
|
19
19
|
"connection.update:status": (me: Contact | undefined, account: proto.IADVSignedDeviceIdentity | undefined, status: WAConnectionState) => void;
|
|
20
20
|
"connection.update:qr": (qr: string) => void;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export type FailedResponseType = {wavoipStatus: string, result: any};
|
|
24
|
+
|
|
23
25
|
export type onWhatsAppType = (jid: string, callback: onWhatsAppCallback) => void;
|
|
24
26
|
export type onWhatsAppCallback = (response: {
|
|
25
27
|
exists: boolean;
|
|
26
28
|
jid: string;
|
|
27
|
-
}[]) => void;
|
|
29
|
+
}[] | FailedResponseType | undefined) => void;
|
|
28
30
|
|
|
29
31
|
export type ProfilePictureUrlType = (jid: string, type: "image" | "preview", timeoutMs: number | undefined, callback: ProfilePictureUrlCallback) => void;
|
|
30
|
-
export type ProfilePictureUrlCallback = (response: string | undefined) => void;
|
|
32
|
+
export type ProfilePictureUrlCallback = (response: string | FailedResponseType | undefined) => void;
|
|
31
33
|
|
|
32
34
|
export type AssertSessionsType = (jids: string[], force: boolean, callback: AssertSessionsCallback) => void;
|
|
33
|
-
export type AssertSessionsCallback = (response: boolean) => void;
|
|
35
|
+
export type AssertSessionsCallback = (response: boolean | FailedResponseType) => void;
|
|
34
36
|
|
|
35
37
|
export type CreateParticipantNodesType = (jids: string[], message: any, extraAttrs: any, callback: CreateParticipantNodesCallback) => void;
|
|
36
|
-
export type CreateParticipantNodesCallback =
|
|
38
|
+
export type CreateParticipantNodesCallback = {
|
|
39
|
+
(nodes: any, shouldIncludeDeviceIdentity: boolean): void;
|
|
40
|
+
(response: FailedResponseType): void;
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
export type GetUSyncDevicesType = (jids: string[], useCache: boolean, ignoreZeroDevices: boolean, callback: GetUSyncDevicesTypeCallback) => void
|
|
39
|
-
export type GetUSyncDevicesTypeCallback = (jids: JidWithDevice[]) => void;
|
|
44
|
+
export type GetUSyncDevicesTypeCallback = (jids: JidWithDevice[] | FailedResponseType) => void;
|
|
40
45
|
|
|
41
46
|
export type GenerateMessageTagType = (callback: GenerateMessageTagTypeCallback) => void
|
|
42
|
-
export type GenerateMessageTagTypeCallback = (response: string) => void;
|
|
47
|
+
export type GenerateMessageTagTypeCallback = (response: string | FailedResponseType) => void;
|
|
43
48
|
|
|
44
49
|
export type SendNodeType = (stanza: BinaryNode, callback: SendNodeTypeCallback) => void
|
|
45
|
-
export type SendNodeTypeCallback = (response: boolean) => void;
|
|
50
|
+
export type SendNodeTypeCallback = (response: boolean | FailedResponseType) => void;
|
|
46
51
|
|
|
47
52
|
export type SignalRepositoryDecryptMessageType = (jid: string, type: "pkmsg" | "msg", ciphertext: Buffer, callback: SignalRepositoryDecryptMessageCallback) => void
|
|
48
|
-
export type SignalRepositoryDecryptMessageCallback = (response:
|
|
53
|
+
export type SignalRepositoryDecryptMessageCallback = (response: Uint8Array | FailedResponseType) => void;
|