zaileys 4.8.3 → 4.8.4

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.
@@ -0,0 +1,33 @@
1
+ import type { Logger } from '../client/types.js';
2
+ import type { CallPayload } from '../events/types.js';
3
+ export interface CallSocketLike {
4
+ rejectCall(callId: string, callFrom: string): Promise<void>;
5
+ }
6
+ /** Callers that should NOT be auto-rejected: a jid/number list, or a predicate. */
7
+ export type CallAllowList = string[] | ((jid: string) => boolean | Promise<boolean>);
8
+ export interface AutoRejectCallOptions {
9
+ /** Turn auto-rejecting on. Default `false` — rejecting calls is opt-in. */
10
+ enabled?: boolean;
11
+ /** Callers to let ring (not rejected). Array entries match the full jid or its digits. */
12
+ allow?: CallAllowList;
13
+ /** Runs after a call was successfully rejected — e.g. reply "calls aren't supported". */
14
+ onReject?: (call: Extract<CallPayload, {
15
+ kind: 'incoming';
16
+ }>) => void | Promise<void>;
17
+ }
18
+ /** Auto-rejects incoming WhatsApp calls per policy. Web-only — the Cloud API has no calls. */
19
+ export declare class AutoRejectCallModule {
20
+ private readonly getSocket;
21
+ private readonly options;
22
+ private readonly logger;
23
+ constructor(getSocket: () => CallSocketLike | undefined, options: AutoRejectCallOptions, logger?: Logger);
24
+ get enabled(): boolean;
25
+ /** Reject a call outright, ignoring policy. Throws when not connected or the socket rejects. */
26
+ reject(callId: string, from: string): Promise<void>;
27
+ /** Apply the auto-reject policy to an incoming call. Never throws — failures are logged. */
28
+ handle(call: Extract<CallPayload, {
29
+ kind: 'incoming';
30
+ }>): Promise<void>;
31
+ /** A failing predicate must not accidentally let calls through — treat it as "not allowed". */
32
+ private isAllowed;
33
+ }
@@ -9,3 +9,5 @@ export { Scheduler, type SchedulerDeps, type SchedulerTimer, type ScheduleHandle
9
9
  export type { ScheduledJobRecord } from '../store/types.js';
10
10
  export { AutoDeleteSweeper, genericPrune } from './auto-delete.js';
11
11
  export type { AutoDeleteOptions } from './auto-delete.js';
12
+ export { AutoRejectCallModule } from './auto-reject-call.js';
13
+ export type { AutoRejectCallOptions, CallAllowList, CallSocketLike } from './auto-reject-call.js';
@@ -3,7 +3,7 @@ import { EditBuilder, MessageBuilder, type DeleteOptions, type PinOptions } from
3
3
  import { CommunityModule, GroupModule, BusinessModule, ChatModule, ContactModule, NewsletterModule, PrivacyModule, ProfileModule } from '../domain/index.js';
4
4
  import { type CommandHandler, type Middleware } from '../command/index.js';
5
5
  import { PresenceModule, type BroadcastOptions, type BroadcastResult, type ScheduleHandle } from '../automation/index.js';
6
- import type { MediaDownloadResult } from '../events/types.js';
6
+ import type { CallPayload, MediaDownloadResult } from '../events/types.js';
7
7
  import type { AuthStoreBundle } from '../auth/types.js';
8
8
  import type { MessageStore } from '../store/types.js';
9
9
  import { TypedEventEmitter } from './event-emitter.js';
@@ -63,6 +63,7 @@ export declare class Client extends TypedEventEmitter<ClientEventMap> {
63
63
  private _presence?;
64
64
  private _scheduler?;
65
65
  private readonly autoDeleteOptions;
66
+ private readonly autoRejectCall;
66
67
  private autoDeleteSweeper;
67
68
  private readonly pluginsOptions;
68
69
  private pluginRegistry;
@@ -121,6 +122,14 @@ export declare class Client extends TypedEventEmitter<ClientEventMap> {
121
122
  edit(key: WAMessageKey): EditBuilder;
122
123
  delete(key: WAMessageKey, opts?: DeleteOptions): Promise<void>;
123
124
  react(key: WAMessageKey, emoji: string): Promise<WAMessageKey>;
125
+ /**
126
+ * Reject an incoming call (🔗 unofficial only — the Cloud API has no calls). Pass the
127
+ * `call-incoming` payload directly, or the raw `callId` + caller jid.
128
+ */
129
+ rejectCall(call: Extract<CallPayload, {
130
+ kind: 'incoming';
131
+ }>): Promise<void>;
132
+ rejectCall(callId: string, from: string): Promise<void>;
124
133
  /** Cloud provider only: management surface (templates, profile, flows, blocklist, qr, analytics, phone). */
125
134
  get cloud(): CloudModule;
126
135
  /** Cloud provider only: send an approved Meta message template by name + language. */
@@ -1,6 +1,7 @@
1
1
  import type { UserFacingSocketConfig, WASocket } from 'baileys';
2
2
  import type { AuthStoreBundle } from '../auth/types.js';
3
3
  import type { AutoDeleteOptions } from '../automation/auto-delete.js';
4
+ import type { AutoRejectCallOptions } from '../automation/auto-reject-call.js';
4
5
  import type { OperationGuardOptions } from '../automation/operation-guard.js';
5
6
  import type { PresenceThrottleOptions } from '../automation/presence.js';
6
7
  import type { AuthGuardOptions } from '../connection/auth-guard.js';
@@ -58,6 +59,8 @@ export interface ClientOptions {
58
59
  presence?: PresenceThrottleOptions;
59
60
  /** Max scheduled messages dispatched per second, smoothing backlog bursts. Default `1`; `0` disables. */
60
61
  scheduleRateLimitPerSec?: number;
62
+ /** Auto-reject incoming calls (🔗 unofficial only). `true` = reject every call. Default off. */
63
+ autoRejectCall?: boolean | AutoRejectCallOptions;
61
64
  /** Periodically prune old messages from the store. Enabled by default with a 1-month `maxAgeMs`; pass `false` to disable or override any field. */
62
65
  autoDelete?: AutoDeleteOptions | false;
63
66
  /** Load and manage plugins from a directory. */