@zelynskybail/baileys 2.6.30 → 2.6.34
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/BUILD_STATUS.md +14 -18
- package/CHANGELOG.md +18 -0
- package/LICENSE-JAPOFC-VOIP +21 -0
- package/README.md +46 -8
- package/THIRD_PARTY_NOTICES.md +7 -0
- package/lib/Utils/ffmpeg-path.js +20 -0
- package/lib/VoIP/audio-feeder.d.ts +20 -0
- package/lib/VoIP/audio-feeder.js +208 -0
- package/lib/VoIP/call-recorder.d.ts +13 -0
- package/lib/VoIP/call-recorder.js +77 -0
- package/lib/VoIP/group-call.d.ts +105 -0
- package/lib/VoIP/group-call.js +718 -0
- package/lib/VoIP/index.d.ts +56 -4
- package/lib/VoIP/index.js +343 -28
- package/lib/VoIP/relay-transport.d.ts +43 -0
- package/lib/VoIP/relay-transport.js +563 -0
- package/lib/VoIP/signaling.d.ts +26 -0
- package/lib/VoIP/signaling.js +662 -0
- package/lib/VoIP/types.d.ts +69 -0
- package/lib/VoIP/types.js +19 -0
- package/lib/VoIP/wasm-engine.d.ts +120 -0
- package/lib/VoIP/wasm-engine.js +1386 -0
- package/lib/VoIP/worker-bootstrap.d.ts +4 -0
- package/lib/VoIP/worker-bootstrap.js +1046 -0
- package/package.json +16 -6
- package/scripts/check-publish-eligibility.mjs +13 -0
- package/scripts/fetch-wasm-resources.mjs +339 -0
- package/scripts/verify.mjs +31 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for the @japofc/baileys VoIP stack.
|
|
3
|
+
*
|
|
4
|
+
* @author J.AP
|
|
5
|
+
*/
|
|
6
|
+
/** Audio stream configuration reported by the WASM. */
|
|
7
|
+
export type AudioConfig = {
|
|
8
|
+
sampleRate: number;
|
|
9
|
+
channels: number;
|
|
10
|
+
bitsPerSample: number;
|
|
11
|
+
framesPerChunk: number;
|
|
12
|
+
};
|
|
13
|
+
/** Options for placing a call. */
|
|
14
|
+
export type CallOptions = {
|
|
15
|
+
/** Phone number, digits only (e.g. `"12345678901"`). */
|
|
16
|
+
to: string;
|
|
17
|
+
/** Audio source: file path to MP3/WAV, or `"silence"` for an empty uplink. */
|
|
18
|
+
audioSource?: string;
|
|
19
|
+
/** Auto-hangup after N ms (default: 120000). */
|
|
20
|
+
durationMs?: number;
|
|
21
|
+
};
|
|
22
|
+
/** Events emitted by an `ActiveCall`. */
|
|
23
|
+
export type CallEvents = {
|
|
24
|
+
ringing: () => void;
|
|
25
|
+
connected: () => void;
|
|
26
|
+
/** 16 kHz mono Float32 PCM frame from the remote peer. */
|
|
27
|
+
audio: (pcm: Float32Array) => void;
|
|
28
|
+
/** Reason: `"hangup"` | `"timeout"` | `"rejected"` | `"remote_end"` | `"disconnect"` | etc. */
|
|
29
|
+
ended: (reason: string) => void;
|
|
30
|
+
error: (err: Error) => void;
|
|
31
|
+
};
|
|
32
|
+
/** Top-level SDK configuration. */
|
|
33
|
+
export type VoipSdkConfig = {
|
|
34
|
+
/** Path to a Baileys multi-file auth state directory. */
|
|
35
|
+
authDir: string;
|
|
36
|
+
};
|
|
37
|
+
/** Mirrors the WhatsApp WASM `CallState` enum. */
|
|
38
|
+
export declare const CallState: {
|
|
39
|
+
readonly Idle: 0;
|
|
40
|
+
readonly Calling: 1;
|
|
41
|
+
readonly PreacceptReceived: 2;
|
|
42
|
+
readonly ReceivedCall: 3;
|
|
43
|
+
readonly AcceptSent: 4;
|
|
44
|
+
readonly AcceptReceived: 5;
|
|
45
|
+
readonly Active: 6;
|
|
46
|
+
readonly ActiveElsewhere: 7;
|
|
47
|
+
readonly Ending: 13;
|
|
48
|
+
};
|
|
49
|
+
export type CallState = (typeof CallState)[keyof typeof CallState];
|
|
50
|
+
/** Relay list update payload from WASM call event 156. */
|
|
51
|
+
export type RelayListUpdate = {
|
|
52
|
+
relay_key: string;
|
|
53
|
+
relay_tokens: string[];
|
|
54
|
+
auth_tokens?: string[];
|
|
55
|
+
enable_edgeray_dtls_active_mode?: boolean;
|
|
56
|
+
relays: ReadonlyArray<{
|
|
57
|
+
relay_id: number;
|
|
58
|
+
relay_name: string;
|
|
59
|
+
token_id: number;
|
|
60
|
+
auth_token_id?: number;
|
|
61
|
+
addresses: ReadonlyArray<{
|
|
62
|
+
protocol: number;
|
|
63
|
+
ipv4?: string;
|
|
64
|
+
ipv6?: string;
|
|
65
|
+
port?: number;
|
|
66
|
+
port_v6?: number;
|
|
67
|
+
}>;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/VoIP/types.js
|
|
3
|
+
* Author: J.AP (@japofc/baileys)
|
|
4
|
+
*
|
|
5
|
+
* Shared constants for the VoIP stack.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Call lifecycle states (values mirror WhatsApp's WASM `CallState`). */
|
|
9
|
+
export const CallState = Object.freeze({
|
|
10
|
+
Idle: 0,
|
|
11
|
+
Calling: 1,
|
|
12
|
+
PreacceptReceived: 2,
|
|
13
|
+
ReceivedCall: 3,
|
|
14
|
+
AcceptSent: 4,
|
|
15
|
+
AcceptReceived: 5,
|
|
16
|
+
Active: 6,
|
|
17
|
+
ActiveElsewhere: 7,
|
|
18
|
+
Ending: 13
|
|
19
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export type WasmAudioConfig = {
|
|
2
|
+
sampleRate: number;
|
|
3
|
+
channels: number;
|
|
4
|
+
bitsPerSample: number;
|
|
5
|
+
framesPerChunk: number;
|
|
6
|
+
};
|
|
7
|
+
export type WasmEngineCallbacks = {
|
|
8
|
+
onSignalingXmpp?: (peerJid: string, callId: string, xmlPayload: Uint8Array) => void;
|
|
9
|
+
onCallEvent?: (eventType: number, eventData?: string) => void;
|
|
10
|
+
onVoipReady?: () => void;
|
|
11
|
+
sendDataToRelay?: (data: Uint8Array, ip: string, port: number) => number;
|
|
12
|
+
onLog?: (level: string, message: string) => void;
|
|
13
|
+
onAudioCaptureInit?: (config: WasmAudioConfig) => void;
|
|
14
|
+
onAudioCaptureStart?: () => void;
|
|
15
|
+
onAudioCaptureStop?: () => void;
|
|
16
|
+
onAudioPlaybackInit?: (config: WasmAudioConfig) => void;
|
|
17
|
+
onAudioPlaybackStart?: () => void;
|
|
18
|
+
onAudioPlaybackStop?: () => void;
|
|
19
|
+
onAudioPlaybackData?: (audioData: Float32Array) => void;
|
|
20
|
+
cryptoHkdf?: (key: Uint8Array, salt: Uint8Array | null, info: Uint8Array, length: number) => Uint8Array;
|
|
21
|
+
hmacSha256?: (data: Uint8Array, key: Uint8Array) => Uint8Array;
|
|
22
|
+
};
|
|
23
|
+
export type WasmEngineConfig = {
|
|
24
|
+
resourcesPath?: string;
|
|
25
|
+
wasmPath?: string;
|
|
26
|
+
wasmBinary?: Uint8Array;
|
|
27
|
+
loaderCode?: string;
|
|
28
|
+
workerModulesCode?: string;
|
|
29
|
+
loaderModuleName?: string;
|
|
30
|
+
callbacks?: WasmEngineCallbacks;
|
|
31
|
+
enableLogs?: boolean;
|
|
32
|
+
options?: {
|
|
33
|
+
heartbeatInterval?: number;
|
|
34
|
+
lobbyTimeout?: number;
|
|
35
|
+
maxParticipantsScreenShare?: number;
|
|
36
|
+
maxGroupSizeLongRingtone?: number;
|
|
37
|
+
logLevel?: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare class WasmEngine {
|
|
41
|
+
#private;
|
|
42
|
+
static registerGlobalCallbackListener: (callbackName: string, handler: (data: any) => void) => void;
|
|
43
|
+
static notifyGlobalCallbackListeners: (callbackName: string, data: any) => void;
|
|
44
|
+
constructor(config?: WasmEngineConfig);
|
|
45
|
+
initialize: () => Promise<void>;
|
|
46
|
+
isInitialized: () => boolean;
|
|
47
|
+
destroy: () => void;
|
|
48
|
+
initVoipStack: (selfJid: string, meUserJid: string, selfLid: string) => void;
|
|
49
|
+
waitForVoipStackReady: () => Promise<void>;
|
|
50
|
+
isVoipStackReady: () => boolean;
|
|
51
|
+
startCall: (options: {
|
|
52
|
+
peerJid: string;
|
|
53
|
+
peerPn: string;
|
|
54
|
+
peerList?: string[];
|
|
55
|
+
callId: string;
|
|
56
|
+
isVideo: boolean;
|
|
57
|
+
isLidCall?: boolean;
|
|
58
|
+
isFromDialer?: boolean;
|
|
59
|
+
extraData?: Uint8Array;
|
|
60
|
+
}) => unknown;
|
|
61
|
+
endCall: (reason?: number, sendTerminate?: boolean) => void;
|
|
62
|
+
setMute: (muted: boolean) => number;
|
|
63
|
+
acceptCall: (opts?: { isMicEnabled?: boolean; isCameraEnabled?: boolean }) => void;
|
|
64
|
+
rejectCall: () => void;
|
|
65
|
+
rejectCallWithoutCallContext: (opts?: any) => void;
|
|
66
|
+
startGroupCall: (opts?: any) => any;
|
|
67
|
+
joinOngoingCall: (opts?: any) => any;
|
|
68
|
+
inviteToCall: (opts?: any) => any;
|
|
69
|
+
removeCallParticipant: (peerJid: string) => any;
|
|
70
|
+
requestPeerMute: (peerJid: string) => any;
|
|
71
|
+
previewCallLink: (opts?: any) => any;
|
|
72
|
+
joinCallLink: () => any;
|
|
73
|
+
resendOfferOnDecryptionFailure: (peerJid: string, callId: string) => void;
|
|
74
|
+
resendEncRekeyRetry: (peerJid: string, retryCount?: number) => void;
|
|
75
|
+
checkOngoingCalls: (callIds?: string[], callCreatorJids?: string[]) => void;
|
|
76
|
+
getCallInfo: () => any;
|
|
77
|
+
getCallStats: (debug?: boolean) => string;
|
|
78
|
+
sendReaction: (reaction: string) => boolean;
|
|
79
|
+
raiseHand: (raised: boolean) => boolean;
|
|
80
|
+
updateNetworkMedium: (networkMedium: number, networkMtu?: number) => void;
|
|
81
|
+
handleSignalingOffer: (msg: {
|
|
82
|
+
payload: string;
|
|
83
|
+
peerPlatform?: number;
|
|
84
|
+
peerAppVersion?: string;
|
|
85
|
+
epochId?: string;
|
|
86
|
+
timestamp?: string;
|
|
87
|
+
isOffline?: boolean;
|
|
88
|
+
isOfferNotContact?: boolean;
|
|
89
|
+
peerJid: string;
|
|
90
|
+
tcToken?: Uint8Array;
|
|
91
|
+
}) => void;
|
|
92
|
+
handleSignalingMessage: (msg: {
|
|
93
|
+
payload: string;
|
|
94
|
+
peerPlatform?: string | number;
|
|
95
|
+
peerAppVersion?: string;
|
|
96
|
+
epochId?: string;
|
|
97
|
+
timestamp?: string;
|
|
98
|
+
isOffline?: boolean;
|
|
99
|
+
peerJid: string;
|
|
100
|
+
tcToken?: Uint8Array;
|
|
101
|
+
}) => void;
|
|
102
|
+
handleSignalingAck: (msg: {
|
|
103
|
+
payload: string;
|
|
104
|
+
ackError?: string;
|
|
105
|
+
msgType?: string;
|
|
106
|
+
peerJid?: string;
|
|
107
|
+
extraData?: Uint8Array;
|
|
108
|
+
}) => void;
|
|
109
|
+
handleSignalingReceipt: (msg: {
|
|
110
|
+
payload: string;
|
|
111
|
+
peerJid: string;
|
|
112
|
+
tcToken?: Uint8Array;
|
|
113
|
+
}) => void;
|
|
114
|
+
handleOnTransportMessage: (data: Uint8Array, ip: string, port: number) => void;
|
|
115
|
+
updateIceRtt: (rttMs: number, relayIp: string, relayPort: number) => void;
|
|
116
|
+
sendAudioData: (data: Float32Array, ptr: number) => void;
|
|
117
|
+
malloc: (size: number) => number;
|
|
118
|
+
free: (ptr: number) => void;
|
|
119
|
+
}
|
|
120
|
+
export default WasmEngine;
|