@oxidezap/baileyrs 0.3.9 → 0.3.10
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/README.md +29 -0
- package/lib/Bridge/schema.js +15 -0
- package/lib/Bridge/types.d.ts +14 -4
- package/lib/Compatibility/group-metadata.js +2 -2
- package/lib/Compatibility/newsletter-results.d.ts +2 -3
- package/lib/Compatibility/newsletter-results.js +3 -3
- package/lib/Compatibility/reachout.d.ts +17 -0
- package/lib/Compatibility/reachout.js +47 -0
- package/lib/Socket/communities.js +10 -5
- package/lib/Socket/core.js +10 -3
- package/lib/Socket/events-core.js +10 -9
- package/lib/Socket/groups.js +10 -5
- package/lib/Socket/newsletter.d.ts +3 -3
- package/lib/Socket/newsletter.js +5 -5
- package/lib/Socket/reachout.d.ts +1 -21
- package/lib/Socket/reachout.js +1 -49
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -60,6 +60,35 @@ both directions, for fields nested at any depth. An own public property wins ove
|
|
|
60
60
|
bridge name, including an explicit `null` or `undefined`, and inputs are never
|
|
61
61
|
mutated. The bridge keeps its own names.
|
|
62
62
|
|
|
63
|
+
### Bridge 0.25 compatibility
|
|
64
|
+
|
|
65
|
+
The runtime dependency is pinned to `@oxidezap/whatsapp-rust-bridge@0.25.0`.
|
|
66
|
+
The public API still targets `baileys@7.0.0-rc14`.
|
|
67
|
+
|
|
68
|
+
- `groupFetchAllParticipating()` and `communityFetchAllParticipating()` fetch full
|
|
69
|
+
metadata for each slim bridge listing entry. This adds one metadata request per
|
|
70
|
+
group, preserves participants and settings, and rejects on any failed fetch
|
|
71
|
+
before emitting `groups.update`.
|
|
72
|
+
- Reachout pushes use the typed bridge event once, ignoring its raw MEX twin.
|
|
73
|
+
`connection.update.reachoutTimeLock` preserves unknown enforcement names at
|
|
74
|
+
runtime; a missing `isActive` means unknown, not a lifted restriction. This
|
|
75
|
+
reports server state and does not prevent device removal or impose send policy.
|
|
76
|
+
- A terminal `device_removed` or unknown conflict reports `loggedOut` rather than
|
|
77
|
+
`connectionReplaced`, including when run completion arrives before the event.
|
|
78
|
+
- `newsletterMute()` and `newsletterUnmute()` change channel-update notifications.
|
|
79
|
+
Metadata exposes that setting as `mute_state`, independently of admin-facing
|
|
80
|
+
follower-activity notifications. Reactions still resolve to `undefined`.
|
|
81
|
+
History results may omit `messageId`; `serverId` and large counters remain
|
|
82
|
+
strings. The bridge's packed live-message format does not carry the new
|
|
83
|
+
newsletter server ID; only object events and history results expose it.
|
|
84
|
+
- A failed community configuration can reject after creation succeeded. Preserve
|
|
85
|
+
the error's `createdJid`, `step`, `kind` and `cause`, then resume configuration on
|
|
86
|
+
that JID instead of repeating `communityCreate()`.
|
|
87
|
+
- Synced status privacy reaches `settings.update`; the unarchive setting reaches
|
|
88
|
+
`creds.update`. Historical calls, favorite chats and sticker-list updates have
|
|
89
|
+
no corresponding event in the pinned Baileys API and are acknowledged without
|
|
90
|
+
emitting unrelated live-call or message events.
|
|
91
|
+
|
|
63
92
|
## Documentation
|
|
64
93
|
|
|
65
94
|
The full API reference and guides live in the
|
package/lib/Bridge/schema.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* `asNumber`, `asString`) at those leak points only — not boilerplate
|
|
23
23
|
* everywhere.
|
|
24
24
|
*/
|
|
25
|
+
import { mapReachoutTimelock } from '../Compatibility/reachout.js';
|
|
25
26
|
import { processHistoryMessage } from '../Utils/process-history-message-core.js';
|
|
26
27
|
import { isJidGroup } from '../WABinary/jid-utils.js';
|
|
27
28
|
import { absoluteFromDuration, asBool, asBoolOr, asStringArray, asDurationSeconds, asInt64, asJidAddressString, asJidString, asNumber, asString, asUnixSeconds, isObject, normalizeDiscriminator } from './primitives.js';
|
|
@@ -407,6 +408,19 @@ const ADAPTERS = {
|
|
|
407
408
|
contact_removed: () => ({ type: 'noop', bridgeType: 'contact_removed' }),
|
|
408
409
|
quick_reply_update: () => ({ type: 'noop', bridgeType: 'quick_reply_update' }),
|
|
409
410
|
call_log_sync: () => ({ type: 'noop', bridgeType: 'call_log_sync' }),
|
|
411
|
+
// Baileys rc14 has no events for historical calls, favorites or stickers.
|
|
412
|
+
call_log_history: () => ({ type: 'noop', bridgeType: 'call_log_history' }),
|
|
413
|
+
favorite_sticker_update: () => ({ type: 'noop', bridgeType: 'favorite_sticker_update' }),
|
|
414
|
+
remove_recent_sticker_update: () => ({ type: 'noop', bridgeType: 'remove_recent_sticker_update' }),
|
|
415
|
+
favorites_update: () => ({ type: 'noop', bridgeType: 'favorites_update' }),
|
|
416
|
+
status_privacy_update: data => isObject(data?.action) ? { type: 'settingUpdate', setting: 'statusPrivacy', value: data.action } : null,
|
|
417
|
+
unarchive_chats_setting_update: data => typeof data?.unarchive_chats === 'boolean'
|
|
418
|
+
? { type: 'unarchiveChatsSetting', unarchiveChats: data.unarchive_chats }
|
|
419
|
+
: null,
|
|
420
|
+
reachout_timelock_update: data => {
|
|
421
|
+
const state = mapReachoutTimelock(data?.state);
|
|
422
|
+
return state ? { type: 'reachoutTimelock', state } : null;
|
|
423
|
+
},
|
|
410
424
|
// ── Calls ──
|
|
411
425
|
incoming_call: (data, logger) => adaptIncomingCall(data, logger),
|
|
412
426
|
missed_call: (data, logger) => {
|
|
@@ -767,6 +781,7 @@ const adaptMessageParts = (info, messageProto, logger) => {
|
|
|
767
781
|
isFromMe,
|
|
768
782
|
id,
|
|
769
783
|
timestamp,
|
|
784
|
+
serverId: asString(info.newsletter_server_id) ?? asNumber(info.newsletter_server_id)?.toString(),
|
|
770
785
|
pushName: asString(info.push_name),
|
|
771
786
|
participantAlt: resolveParticipantAlt(senderAlt, isGroup),
|
|
772
787
|
remoteJidAlt: resolveRemoteJidAlt(senderAlt, recipientAlt, isGroup, isFromMe),
|
package/lib/Bridge/types.d.ts
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* - Optional fields use `?` (omitted) rather than `null`.
|
|
15
15
|
*/
|
|
16
16
|
import type { proto } from '@oxidezap/whatsapp-rust-bridge/proto-types';
|
|
17
|
+
import type { ReachoutTimelockState } from '../Types/Reachout.js';
|
|
18
|
+
import type { BaileysEventMap } from '../Types/Events.js';
|
|
17
19
|
import type { Chat, Contact, LIDMapping, WAMessage } from '../Types/index.js';
|
|
18
20
|
import type { BinaryNode, WAProto } from '../Types/index.js';
|
|
19
21
|
export interface CanonicalConnected {
|
|
@@ -116,6 +118,8 @@ export interface CanonicalQrScannedWithoutMultidevice {
|
|
|
116
118
|
*/
|
|
117
119
|
export interface CanonicalMessage {
|
|
118
120
|
type: 'message';
|
|
121
|
+
/** Exact newsletter server ID when the bridge object envelope carries it. */
|
|
122
|
+
serverId?: string;
|
|
119
123
|
chatJid: string;
|
|
120
124
|
senderJid?: string;
|
|
121
125
|
isGroup: boolean;
|
|
@@ -514,10 +518,16 @@ export interface CanonicalAppStateSyncFailed {
|
|
|
514
518
|
* new contract. The shape is the event's rather than one setting's: another
|
|
515
519
|
* setting the bridge starts reporting is a new arm here, not a new event.
|
|
516
520
|
*/
|
|
517
|
-
export
|
|
521
|
+
export type CanonicalSettingUpdate = {
|
|
518
522
|
type: 'settingUpdate';
|
|
519
|
-
|
|
520
|
-
|
|
523
|
+
} & BaileysEventMap['settings.update'];
|
|
524
|
+
export interface CanonicalReachoutTimelock {
|
|
525
|
+
type: 'reachoutTimelock';
|
|
526
|
+
state: ReachoutTimelockState;
|
|
527
|
+
}
|
|
528
|
+
export interface CanonicalUnarchiveChatsSetting {
|
|
529
|
+
type: 'unarchiveChatsSetting';
|
|
530
|
+
unarchiveChats: boolean;
|
|
521
531
|
}
|
|
522
532
|
export type CanonicalCallActionType = 'offer' | 'preaccept' | 'transport' | 'relaylatency' | 'accept' | 'reject' | 'terminate' | 'timeout';
|
|
523
533
|
export interface CanonicalCallAction {
|
|
@@ -732,5 +742,5 @@ export interface CanonicalServerAck {
|
|
|
732
742
|
timestamp?: number;
|
|
733
743
|
error?: string;
|
|
734
744
|
}
|
|
735
|
-
export type CanonicalEvent = CanonicalConnected | CanonicalDisconnected | CanonicalQR | CanonicalPairSuccess | CanonicalPairError | CanonicalLoggedOut | CanonicalConnectFailure | CanonicalStreamError | CanonicalStreamReplaced | CanonicalClientOutdated | CanonicalTemporaryBan | CanonicalQrScannedWithoutMultidevice | CanonicalMessage | CanonicalReceipt | CanonicalContactUpdate | CanonicalPictureUpdate | CanonicalPresence | CanonicalChatPresence | CanonicalGroupUpdate | CanonicalArchiveUpdate | CanonicalPinUpdate | CanonicalMuteUpdate | CanonicalStarUpdate | CanonicalMarkChatAsReadUpdate | CanonicalLockChatUpdate | CanonicalLabelEdit | CanonicalLabelAssociation | CanonicalAppStateSyncFailed | CanonicalQrCodesExhausted | CanonicalSettingUpdate | CanonicalIncomingCall | CanonicalUndecryptableMessage | CanonicalLidMappingUpdate | CanonicalNewsletterLiveUpdate | CanonicalChatDelete | CanonicalChatClear | CanonicalMessageDelete | CanonicalDisappearingModeChanged | CanonicalHistorySync | CanonicalOfflineSyncCompleted | CanonicalDirtyState | CanonicalRawNode | CanonicalNotification | CanonicalMexNotification | CanonicalServerAck | CanonicalNoop;
|
|
745
|
+
export type CanonicalEvent = CanonicalConnected | CanonicalDisconnected | CanonicalQR | CanonicalPairSuccess | CanonicalPairError | CanonicalLoggedOut | CanonicalConnectFailure | CanonicalStreamError | CanonicalStreamReplaced | CanonicalClientOutdated | CanonicalTemporaryBan | CanonicalQrScannedWithoutMultidevice | CanonicalMessage | CanonicalReceipt | CanonicalContactUpdate | CanonicalPictureUpdate | CanonicalPresence | CanonicalChatPresence | CanonicalGroupUpdate | CanonicalArchiveUpdate | CanonicalPinUpdate | CanonicalMuteUpdate | CanonicalStarUpdate | CanonicalMarkChatAsReadUpdate | CanonicalLockChatUpdate | CanonicalLabelEdit | CanonicalLabelAssociation | CanonicalAppStateSyncFailed | CanonicalQrCodesExhausted | CanonicalSettingUpdate | CanonicalReachoutTimelock | CanonicalUnarchiveChatsSetting | CanonicalIncomingCall | CanonicalUndecryptableMessage | CanonicalLidMappingUpdate | CanonicalNewsletterLiveUpdate | CanonicalChatDelete | CanonicalChatClear | CanonicalMessageDelete | CanonicalDisappearingModeChanged | CanonicalHistorySync | CanonicalOfflineSyncCompleted | CanonicalDirtyState | CanonicalRawNode | CanonicalNotification | CanonicalMexNotification | CanonicalServerAck | CanonicalNoop;
|
|
736
746
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -39,12 +39,12 @@ export const bridgeGroupMetadataToBaileys = (group) => {
|
|
|
39
39
|
id: group.id.includes('@') ? group.id : jidEncode(group.id, 'g.us'),
|
|
40
40
|
notify: group.notify,
|
|
41
41
|
addressingMode: group.addressingMode === WAMessageAddressingMode.LID ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
|
42
|
-
subject: group.subject,
|
|
42
|
+
subject: group.subject ?? '',
|
|
43
43
|
subjectOwner: group.subjectOwner,
|
|
44
44
|
subjectOwnerPn: group.subjectOwnerPn,
|
|
45
45
|
subjectOwnerUsername: group.subjectOwnerUsername,
|
|
46
46
|
subjectTime: group.subjectTime ?? Number.NaN,
|
|
47
|
-
size: group.
|
|
47
|
+
size: group.participantCount ?? participants.length,
|
|
48
48
|
creation: group.creationTime ?? Number.NaN,
|
|
49
49
|
owner: normalizeOptionalUserJid(group.creator),
|
|
50
50
|
ownerPn: normalizeOptionalUserJid(group.creatorPn),
|
|
@@ -5,10 +5,9 @@ export declare const bridgeNewsletterRoleToBaileys: (role: string | undefined) =
|
|
|
5
5
|
/**
|
|
6
6
|
* Neutral newsletter metadata in upstream's shape.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Three upstream fields have no source in the bridge result and stay absent
|
|
9
9
|
* rather than being invented: `owner` (the result carries the viewer's role,
|
|
10
|
-
* not the owner's jid), `
|
|
11
|
-
* lifecycle, Active/Suspended, not a mute), `reaction_codes`, and
|
|
10
|
+
* not the owner's jid), `reaction_codes`, and
|
|
12
11
|
* `thread_metadata`.
|
|
13
12
|
*/
|
|
14
13
|
export declare const bridgeNewsletterMetadataToBaileys: (result: NewsletterMetadataResult) => NewsletterMetadata;
|
|
@@ -19,14 +19,14 @@ export const bridgeNewsletterRoleToBaileys = (role) => role === undefined ? unde
|
|
|
19
19
|
/**
|
|
20
20
|
* Neutral newsletter metadata in upstream's shape.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Three upstream fields have no source in the bridge result and stay absent
|
|
23
23
|
* rather than being invented: `owner` (the result carries the viewer's role,
|
|
24
|
-
* not the owner's jid), `
|
|
25
|
-
* lifecycle, Active/Suspended, not a mute), `reaction_codes`, and
|
|
24
|
+
* not the owner's jid), `reaction_codes`, and
|
|
26
25
|
* `thread_metadata`.
|
|
27
26
|
*/
|
|
28
27
|
export const bridgeNewsletterMetadataToBaileys = (result) => ({
|
|
29
28
|
id: result.jid,
|
|
29
|
+
...(result.muted !== undefined ? { mute_state: result.muted ? 'ON' : 'OFF' } : {}),
|
|
30
30
|
name: result.name,
|
|
31
31
|
...(result.description !== undefined ? { description: result.description } : {}),
|
|
32
32
|
...(result.inviteCode !== undefined ? { invite: result.inviteCode } : {}),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Shared mapping for typed reachout pushes and on-demand query responses. */
|
|
2
|
+
import { type ReachoutTimelockState } from '../Types/Reachout.js';
|
|
3
|
+
/** Wire shape from `xwa2_fetch_account_reachout_timelock`. */
|
|
4
|
+
export interface ReachoutTimelockWire {
|
|
5
|
+
is_active?: boolean;
|
|
6
|
+
/** Unix seconds as string. `"0"` or absent → cooldown not set. */
|
|
7
|
+
time_enforcement_ends?: string;
|
|
8
|
+
enforcement_type?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Locate the timelock object inside an arbitrary payload — the bridge
|
|
11
|
+
* hands us either the raw `xwa2_…` body (from `fetchReachoutTimelock`)
|
|
12
|
+
* or a wrapping MEX response (from the push notification). */
|
|
13
|
+
export declare function extractReachoutPayload(value: unknown): ReachoutTimelockWire | null;
|
|
14
|
+
/** Map wire payload → public state. Returns `null` when the payload is
|
|
15
|
+
* empty or unparseable so callers can skip the emit. */
|
|
16
|
+
export declare function mapReachoutTimelock(value: unknown): ReachoutTimelockState | null;
|
|
17
|
+
//# sourceMappingURL=reachout.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Shared mapping for typed reachout pushes and on-demand query responses. */
|
|
2
|
+
import {} from '../Types/Reachout.js';
|
|
3
|
+
/** Locate the timelock object inside an arbitrary payload — the bridge
|
|
4
|
+
* hands us either the raw `xwa2_…` body (from `fetchReachoutTimelock`)
|
|
5
|
+
* or a wrapping MEX response (from the push notification). */
|
|
6
|
+
export function extractReachoutPayload(value) {
|
|
7
|
+
if (!value || typeof value !== 'object')
|
|
8
|
+
return null;
|
|
9
|
+
const v = value;
|
|
10
|
+
for (const key of ['xwa2_fetch_account_reachout_timelock', 'xwa2_notify_account_reachout_timelock']) {
|
|
11
|
+
const nested = v[key];
|
|
12
|
+
if (nested && typeof nested === 'object')
|
|
13
|
+
return nested;
|
|
14
|
+
const data = v['data'];
|
|
15
|
+
if (data && typeof data === 'object') {
|
|
16
|
+
const inner = data[key];
|
|
17
|
+
if (inner && typeof inner === 'object')
|
|
18
|
+
return inner;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Caller already extracted — treat the value itself as the payload.
|
|
22
|
+
if ('is_active' in v || 'time_enforcement_ends' in v || 'enforcement_type' in v) {
|
|
23
|
+
return v;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** Map wire payload → public state. Returns `null` when the payload is
|
|
28
|
+
* empty or unparseable so callers can skip the emit. */
|
|
29
|
+
export function mapReachoutTimelock(value) {
|
|
30
|
+
const wire = extractReachoutPayload(value);
|
|
31
|
+
if (!wire)
|
|
32
|
+
return null;
|
|
33
|
+
const state = {};
|
|
34
|
+
if (typeof wire.is_active === 'boolean')
|
|
35
|
+
state.isActive = wire.is_active;
|
|
36
|
+
if (typeof wire.time_enforcement_ends === 'string' && /^\d+$/.test(wire.time_enforcement_ends)) {
|
|
37
|
+
const seconds = Number(wire.time_enforcement_ends);
|
|
38
|
+
const date = new Date(seconds * 1000);
|
|
39
|
+
if (seconds > 0 && Number.isFinite(date.getTime()))
|
|
40
|
+
state.timeEnforcementEnds = date;
|
|
41
|
+
}
|
|
42
|
+
if (typeof wire.enforcement_type === 'string' && wire.enforcement_type) {
|
|
43
|
+
state.enforcementType = wire.enforcement_type;
|
|
44
|
+
}
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=reachout.js.map
|
|
@@ -6,11 +6,16 @@ import { GROUP_REQUEST_ACTIONS, GROUP_SETTINGS, JOIN_APPROVAL_MODES, makeGroupMe
|
|
|
6
6
|
export const makeCommunityMethods = (ctx, groups = makeGroupMethods(ctx)) => {
|
|
7
7
|
const communityMetadata = async (jid) => groups.groupMetadata(jid);
|
|
8
8
|
const communityFetchAllParticipating = async () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
// The bridge listing contains only overviews. Fetch the full records
|
|
10
|
+
// while holding one client lease; never publish a partial roster.
|
|
11
|
+
const result = await ctx.withClient(async (client) => {
|
|
12
|
+
const overviews = await client.communityFetchAllParticipating();
|
|
13
|
+
const metadata = {};
|
|
14
|
+
for (const jid of Object.keys(overviews)) {
|
|
15
|
+
metadata[jid] = bridgeGroupMetadataToBaileys(await client.getGroupMetadata(jid));
|
|
16
|
+
}
|
|
17
|
+
return metadata;
|
|
18
|
+
});
|
|
14
19
|
ctx.ev.emit('groups.update', Object.values(result));
|
|
15
20
|
return result;
|
|
16
21
|
};
|
package/lib/Socket/core.js
CHANGED
|
@@ -139,7 +139,14 @@ const createWASocketFactoryInner = (runtime, config, claimEngineInitialization,
|
|
|
139
139
|
// Upstream mutates authState.creds before notifying user listeners. Register
|
|
140
140
|
// this first so `ev.on('creds.update', saveCreds)` persists the merged state
|
|
141
141
|
// rather than the pre-pair placeholder.
|
|
142
|
-
ev.on('creds.update', update =>
|
|
142
|
+
ev.on('creds.update', update => {
|
|
143
|
+
// App-state emits partial account settings. Preserve sibling settings
|
|
144
|
+
// before saveCreds listeners read the updated credentials.
|
|
145
|
+
const merged = update.accountSettings
|
|
146
|
+
? { ...update, accountSettings: { ...auth.creds.accountSettings, ...update.accountSettings } }
|
|
147
|
+
: update;
|
|
148
|
+
Object.assign(auth.creds, merged);
|
|
149
|
+
});
|
|
143
150
|
let user;
|
|
144
151
|
/** True once `init()` has finished wiring the client and started its read loop. */
|
|
145
152
|
let initialized = false;
|
|
@@ -355,8 +362,8 @@ const createWASocketFactoryInner = (runtime, config, claimEngineInitialization,
|
|
|
355
362
|
else if (completion.reason === 'auto-reconnect-disabled') {
|
|
356
363
|
const protocol = completion.protocolError;
|
|
357
364
|
if (protocol?.kind === 'conflict') {
|
|
358
|
-
statusCode = DisconnectReason.connectionReplaced;
|
|
359
|
-
message = 'Connection replaced'
|
|
365
|
+
statusCode = protocol.cause === 'replaced' ? DisconnectReason.connectionReplaced : DisconnectReason.loggedOut;
|
|
366
|
+
message = protocol.cause === 'replaced' ? 'Connection replaced' : `Logged out: ${protocol.cause}`;
|
|
360
367
|
}
|
|
361
368
|
else if (protocol?.kind === 'stream-error') {
|
|
362
369
|
statusCode = mapConnectFailureToDisconnect(protocol.code);
|
|
@@ -21,7 +21,6 @@ import { isJidBroadcast, isJidGroup } from '../WABinary/jid-utils.js';
|
|
|
21
21
|
import { buildGroupCreateStubMessage, buildGroupJoinRequestEvents, buildGroupNotificationChatUpdates, buildGroupNotificationDomainEvent, buildGroupNotificationStubMessages } from '../Compatibility/group-notifications.js';
|
|
22
22
|
import { emitMessageUpsert } from '../Compatibility/message-upsert.js';
|
|
23
23
|
import { extractMessageCappingPayload } from './message-capping.js';
|
|
24
|
-
import { mapReachoutTimelock } from './reachout.js';
|
|
25
24
|
import { isReconnectableConnectFailure, mapConnectFailureToDisconnect } from './terminal-close.js';
|
|
26
25
|
const CANONICAL_MESSAGE_EVENT = 'message';
|
|
27
26
|
const MESSAGE_UPSERT_APPEND = 'append';
|
|
@@ -77,6 +76,8 @@ const canonicalMessageToWAMessage = (m, Long) => {
|
|
|
77
76
|
key.remoteJid = m.chatJid;
|
|
78
77
|
key.fromMe = m.isFromMe;
|
|
79
78
|
key.id = m.id;
|
|
79
|
+
if (m.serverId !== undefined)
|
|
80
|
+
key.server_id = m.serverId;
|
|
80
81
|
if (m.senderJid !== undefined)
|
|
81
82
|
key.participant = m.senderJid;
|
|
82
83
|
const wm = new WAProto.WebMessageInfo();
|
|
@@ -674,7 +675,12 @@ const DISPATCHERS = {
|
|
|
674
675
|
// Straight onto upstream's own channel for this: `settings.update` already
|
|
675
676
|
// declares the `disableLinkPreviews` arm, and a consumer that reads it is
|
|
676
677
|
// reading the account-wide setting whichever device changed it.
|
|
677
|
-
settingUpdate: (evt, { ctx }) =>
|
|
678
|
+
settingUpdate: (evt, { ctx }) => {
|
|
679
|
+
const { type: _type, ...update } = evt;
|
|
680
|
+
ctx.ev.emit('settings.update', update);
|
|
681
|
+
},
|
|
682
|
+
unarchiveChatsSetting: (evt, { ctx }) => ctx.ev.emit('creds.update', { accountSettings: { unarchiveChats: evt.unarchiveChats } }),
|
|
683
|
+
reachoutTimelock: (evt, { ctx }) => emitConnectionUpdate(ctx, { reachoutTimeLock: evt.state }),
|
|
678
684
|
// ── Calls ──
|
|
679
685
|
incomingCall: (evt, { ctx, callbacks }) => {
|
|
680
686
|
callbacks?.onIncomingCall?.(evt);
|
|
@@ -719,14 +725,9 @@ const DISPATCHERS = {
|
|
|
719
725
|
mexNotification: (evt, { ctx }) => {
|
|
720
726
|
// Route by op_name. Adding a new MEX-driven event means a new entry
|
|
721
727
|
// here — no per-op_name plumbing in the Bridge layer.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
if (state)
|
|
725
|
-
emitConnectionUpdate(ctx, { reachoutTimeLock: state });
|
|
726
|
-
else
|
|
727
|
-
ctx.logger.warn({ payload: evt.payload }, 'reachout-timelock push: payload missing expected fields');
|
|
728
|
+
// Bridge 0.25 emits the typed update before this raw twin.
|
|
729
|
+
if (evt.opName === 'NotificationUserReachoutTimelockUpdate')
|
|
728
730
|
return;
|
|
729
|
-
}
|
|
730
731
|
if (evt.opName === 'MessageCappingInfoNotification') {
|
|
731
732
|
const payload = extractMessageCappingPayload(evt.payload);
|
|
732
733
|
if (payload)
|
package/lib/Socket/groups.js
CHANGED
|
@@ -124,11 +124,16 @@ export const makeGroupMethods = (ctx) => {
|
|
|
124
124
|
await ctx.withClient(client => client.groupSettingUpdate(jid, 'membership_approval', mode === 'on'));
|
|
125
125
|
},
|
|
126
126
|
groupFetchAllParticipating: async () => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
// The bridge listing contains only overviews. Fetch the full records
|
|
128
|
+
// while holding one client lease; never publish a partial roster.
|
|
129
|
+
const result = await ctx.withClient(async (client) => {
|
|
130
|
+
const overviews = await client.groupFetchAllParticipating();
|
|
131
|
+
const metadata = {};
|
|
132
|
+
for (const jid of Object.keys(overviews)) {
|
|
133
|
+
metadata[jid] = bridgeGroupMetadataToBaileys(await client.getGroupMetadata(jid));
|
|
134
|
+
}
|
|
135
|
+
return metadata;
|
|
136
|
+
});
|
|
132
137
|
ctx.ev.emit('groups.update', Object.values(result));
|
|
133
138
|
return result;
|
|
134
139
|
},
|
|
@@ -34,9 +34,9 @@ export declare const makeNewsletterMethods: (ctx: SocketContext) => {
|
|
|
34
34
|
newsletterSubscribe: (jid: string) => Promise<NewsletterMetadataResult>;
|
|
35
35
|
newsletterUnsubscribe: (jid: string) => Promise<void>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Channel updates are admin activity. The Web client's
|
|
38
|
+
* WAWebNewsletterUpdateUserSettingJob writes MUTE_ADMIN_ACTIVITY to
|
|
39
|
+
* the chat mute state; follower activity is a separate admin setting.
|
|
40
40
|
*/
|
|
41
41
|
newsletterMute: (jid: string) => Promise<void>;
|
|
42
42
|
newsletterUnmute: (jid: string) => Promise<void>;
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -77,15 +77,15 @@ export const makeNewsletterMethods = (ctx) => {
|
|
|
77
77
|
await ctx.withClient(client => client.newsletterUnsubscribe(jid));
|
|
78
78
|
},
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* Channel updates are admin activity. The Web client's
|
|
81
|
+
* WAWebNewsletterUpdateUserSettingJob writes MUTE_ADMIN_ACTIVITY to
|
|
82
|
+
* the chat mute state; follower activity is a separate admin setting.
|
|
83
83
|
*/
|
|
84
84
|
newsletterMute: async (jid) => {
|
|
85
|
-
await ctx.withClient(client => client.
|
|
85
|
+
await ctx.withClient(client => client.newsletterAdminMute(jid, true));
|
|
86
86
|
},
|
|
87
87
|
newsletterUnmute: async (jid) => {
|
|
88
|
-
await ctx.withClient(client => client.
|
|
88
|
+
await ctx.withClient(client => client.newsletterAdminMute(jid, false));
|
|
89
89
|
},
|
|
90
90
|
newsletterSubscribers: async (jid) => {
|
|
91
91
|
const metadata = await ctx.withClient(client => client.newsletterMetadata(jid));
|
package/lib/Socket/reachout.d.ts
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Reachout-timelock mapping: server payload → public `ReachoutTimelockState`.
|
|
3
|
-
* Shared between the push-notification path (`Event::MexNotification` with
|
|
4
|
-
* op_name `NotificationUserReachoutTimelockUpdate`) and the on-demand
|
|
5
|
-
* `fetchReachoutTimelock()` IQ. Both deliver the same field shape.
|
|
6
|
-
*/
|
|
7
|
-
import { type ReachoutTimelockState } from '../Types/Reachout.js';
|
|
8
|
-
/** Wire shape from `xwa2_fetch_account_reachout_timelock`. */
|
|
9
|
-
export interface ReachoutTimelockWire {
|
|
10
|
-
is_active?: boolean;
|
|
11
|
-
/** Unix seconds as string. `"0"` or absent → cooldown not set. */
|
|
12
|
-
time_enforcement_ends?: string;
|
|
13
|
-
enforcement_type?: string;
|
|
14
|
-
}
|
|
15
|
-
/** Locate the timelock object inside an arbitrary payload — the bridge
|
|
16
|
-
* hands us either the raw `xwa2_…` body (from `fetchReachoutTimelock`)
|
|
17
|
-
* or a wrapping MEX response (from the push notification). */
|
|
18
|
-
export declare function extractReachoutPayload(value: unknown): ReachoutTimelockWire | null;
|
|
19
|
-
/** Map wire payload → public state. Returns `null` when the payload is
|
|
20
|
-
* empty or unparseable so callers can skip the emit. */
|
|
21
|
-
export declare function mapReachoutTimelock(value: unknown): ReachoutTimelockState | null;
|
|
1
|
+
export { extractReachoutPayload, mapReachoutTimelock, type ReachoutTimelockWire } from '../Compatibility/reachout.js';
|
|
22
2
|
//# sourceMappingURL=reachout.d.ts.map
|
package/lib/Socket/reachout.js
CHANGED
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Reachout-timelock mapping: server payload → public `ReachoutTimelockState`.
|
|
3
|
-
* Shared between the push-notification path (`Event::MexNotification` with
|
|
4
|
-
* op_name `NotificationUserReachoutTimelockUpdate`) and the on-demand
|
|
5
|
-
* `fetchReachoutTimelock()` IQ. Both deliver the same field shape.
|
|
6
|
-
*/
|
|
7
|
-
import {} from '../Types/Reachout.js';
|
|
8
|
-
/** Locate the timelock object inside an arbitrary payload — the bridge
|
|
9
|
-
* hands us either the raw `xwa2_…` body (from `fetchReachoutTimelock`)
|
|
10
|
-
* or a wrapping MEX response (from the push notification). */
|
|
11
|
-
export function extractReachoutPayload(value) {
|
|
12
|
-
if (!value || typeof value !== 'object')
|
|
13
|
-
return null;
|
|
14
|
-
const v = value;
|
|
15
|
-
const nested = v['xwa2_fetch_account_reachout_timelock'];
|
|
16
|
-
if (nested && typeof nested === 'object')
|
|
17
|
-
return nested;
|
|
18
|
-
const data = v['data'];
|
|
19
|
-
if (data && typeof data === 'object') {
|
|
20
|
-
const inner = data['xwa2_fetch_account_reachout_timelock'];
|
|
21
|
-
if (inner && typeof inner === 'object')
|
|
22
|
-
return inner;
|
|
23
|
-
}
|
|
24
|
-
// Caller already extracted — treat the value itself as the payload.
|
|
25
|
-
if ('is_active' in v || 'time_enforcement_ends' in v || 'enforcement_type' in v) {
|
|
26
|
-
return v;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
/** Map wire payload → public state. Returns `null` when the payload is
|
|
31
|
-
* empty or unparseable so callers can skip the emit. */
|
|
32
|
-
export function mapReachoutTimelock(value) {
|
|
33
|
-
const wire = extractReachoutPayload(value);
|
|
34
|
-
if (!wire)
|
|
35
|
-
return null;
|
|
36
|
-
const state = {
|
|
37
|
-
isActive: !!wire.is_active
|
|
38
|
-
};
|
|
39
|
-
if (wire.time_enforcement_ends && wire.time_enforcement_ends !== '0') {
|
|
40
|
-
const seconds = parseInt(wire.time_enforcement_ends, 10);
|
|
41
|
-
if (Number.isFinite(seconds) && seconds > 0) {
|
|
42
|
-
state.timeEnforcementEnds = new Date(seconds * 1000);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (wire.enforcement_type) {
|
|
46
|
-
state.enforcementType = wire.enforcement_type;
|
|
47
|
-
}
|
|
48
|
-
return state;
|
|
49
|
-
}
|
|
1
|
+
export { extractReachoutPayload, mapReachoutTimelock } from '../Compatibility/reachout.js';
|
|
50
2
|
//# sourceMappingURL=reachout.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxidezap/baileyrs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.10",
|
|
5
5
|
"description": "A Rust-powered WhatsApp Web library for JavaScript, with a Baileys-compatible API",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"test:e2e": "NODE_TLS_REJECT_UNAUTHORIZED=0 ADV_SECRET_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= node --expose-gc --test --test-concurrency=1 ./src/__tests__/e2e/*.test-e2e.ts ./scripts/compatibility/__tests__/*.test-e2e.ts"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@oxidezap/whatsapp-rust-bridge": "0.
|
|
95
|
+
"@oxidezap/whatsapp-rust-bridge": "0.25.0",
|
|
96
96
|
"events": "^3.3.0",
|
|
97
97
|
"long": "^5.3.2"
|
|
98
98
|
},
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"jimp": "^1.6.0",
|
|
105
105
|
"link-preview-js": "^5.0.0",
|
|
106
106
|
"music-metadata": "^11.14.0",
|
|
107
|
-
"oxfmt": "^0.
|
|
108
|
-
"oxlint": "1.
|
|
107
|
+
"oxfmt": "^0.70.0",
|
|
108
|
+
"oxlint": "1.85.0",
|
|
109
109
|
"pino": "^10.3.1",
|
|
110
110
|
"pino-pretty": "^13.1.3",
|
|
111
111
|
"pkg-pr-new": "^0.0.88",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"tsc-esm-fix": "^3.1.2",
|
|
114
114
|
"typescript": "^7.0.2",
|
|
115
115
|
"typescript-compat-auditor": "npm:typescript@6.0.3",
|
|
116
|
-
"wrangler": "4.
|
|
116
|
+
"wrangler": "4.141.0"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
119
|
"@hapi/boom": "^9.1.0 || ^10.0.0",
|