@qadeer-xtech/stablebail 1.0.4 → 1.0.6

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/WAProto/index.js CHANGED
@@ -30984,6 +30984,7 @@ export const proto = $root.proto = (() => {
30984
30984
  HistorySync.prototype.companionMetaNonce = null;
30985
30985
  HistorySync.prototype.shareableChatIdentifierEncryptionKey = null;
30986
30986
  HistorySync.prototype.accounts = $util.emptyArray;
30987
+ HistorySync.prototype.nctSalt = null;
30987
30988
 
30988
30989
  let $oneOfFields;
30989
30990
 
@@ -31035,6 +31036,12 @@ export const proto = $root.proto = (() => {
31035
31036
  set: $util.oneOfSetter($oneOfFields)
31036
31037
  });
31037
31038
 
31039
+ // Virtual OneOf for proto3 optional field
31040
+ Object.defineProperty(HistorySync.prototype, "_nctSalt", {
31041
+ get: $util.oneOfGetter($oneOfFields = ["nctSalt"]),
31042
+ set: $util.oneOfSetter($oneOfFields)
31043
+ });
31044
+
31038
31045
  HistorySync.create = function create(properties) {
31039
31046
  return new HistorySync(properties);
31040
31047
  };
@@ -31092,6 +31099,8 @@ export const proto = $root.proto = (() => {
31092
31099
  for (var i = 0; i < m.accounts.length; ++i)
31093
31100
  $root.proto.Account.encode(m.accounts[i], w.uint32(146).fork()).ldelim();
31094
31101
  }
31102
+ if (m.nctSalt != null && Object.hasOwnProperty.call(m, "nctSalt"))
31103
+ w.uint32(154).bytes(m.nctSalt);
31095
31104
  return w;
31096
31105
  };
31097
31106
 
@@ -31188,6 +31197,10 @@ export const proto = $root.proto = (() => {
31188
31197
  m.accounts.push($root.proto.Account.decode(r, r.uint32()));
31189
31198
  break;
31190
31199
  }
31200
+ case 19: {
31201
+ m.nctSalt = r.bytes();
31202
+ break;
31203
+ }
31191
31204
  default:
31192
31205
  r.skipType(t & 7);
31193
31206
  break;
@@ -31361,6 +31374,12 @@ export const proto = $root.proto = (() => {
31361
31374
  m.accounts[i] = $root.proto.Account.fromObject(d.accounts[i]);
31362
31375
  }
31363
31376
  }
31377
+ if (d.nctSalt != null) {
31378
+ if (typeof d.nctSalt === "string")
31379
+ $util.base64.decode(d.nctSalt, m.nctSalt = $util.newBuffer($util.base64.length(d.nctSalt)), 0);
31380
+ else if (d.nctSalt.length >= 0)
31381
+ m.nctSalt = d.nctSalt;
31382
+ }
31364
31383
  return m;
31365
31384
  };
31366
31385
 
@@ -31472,6 +31491,11 @@ export const proto = $root.proto = (() => {
31472
31491
  d.accounts[j] = $root.proto.Account.toObject(m.accounts[j], o);
31473
31492
  }
31474
31493
  }
31494
+ if (m.nctSalt != null && m.hasOwnProperty("nctSalt")) {
31495
+ d.nctSalt = o.bytes === String ? $util.base64.encode(m.nctSalt, 0, m.nctSalt.length) : o.bytes === Array ? Array.prototype.slice.call(m.nctSalt) : m.nctSalt;
31496
+ if (o.oneofs)
31497
+ d._nctSalt = "nctSalt";
31498
+ }
31475
31499
  return d;
31476
31500
  };
31477
31501
 
@@ -79685,6 +79709,7 @@ export const proto = $root.proto = (() => {
79685
79709
  SyncActionValue.prototype.newsletterSavedInterestsAction = null;
79686
79710
  SyncActionValue.prototype.aiThreadRenameAction = null;
79687
79711
  SyncActionValue.prototype.interactiveMessageAction = null;
79712
+ SyncActionValue.prototype.nctSaltSyncAction = null;
79688
79713
 
79689
79714
  let $oneOfFields;
79690
79715
 
@@ -80102,6 +80127,12 @@ export const proto = $root.proto = (() => {
80102
80127
  set: $util.oneOfSetter($oneOfFields)
80103
80128
  });
80104
80129
 
80130
+ // Virtual OneOf for proto3 optional field
80131
+ Object.defineProperty(SyncActionValue.prototype, "_nctSaltSyncAction", {
80132
+ get: $util.oneOfGetter($oneOfFields = ["nctSaltSyncAction"]),
80133
+ set: $util.oneOfSetter($oneOfFields)
80134
+ });
80135
+
80105
80136
  SyncActionValue.create = function create(properties) {
80106
80137
  return new SyncActionValue(properties);
80107
80138
  };
@@ -80247,6 +80278,8 @@ export const proto = $root.proto = (() => {
80247
80278
  $root.proto.SyncActionValue.AiThreadRenameAction.encode(m.aiThreadRenameAction, w.uint32(610).fork()).ldelim();
80248
80279
  if (m.interactiveMessageAction != null && Object.hasOwnProperty.call(m, "interactiveMessageAction"))
80249
80280
  $root.proto.SyncActionValue.InteractiveMessageAction.encode(m.interactiveMessageAction, w.uint32(618).fork()).ldelim();
80281
+ if (m.nctSaltSyncAction != null && Object.hasOwnProperty.call(m, "nctSaltSyncAction"))
80282
+ $root.proto.SyncActionValue.NctSaltSyncAction.encode(m.nctSaltSyncAction, w.uint32(642).fork()).ldelim();
80250
80283
  return w;
80251
80284
  };
80252
80285
 
@@ -80535,6 +80568,10 @@ export const proto = $root.proto = (() => {
80535
80568
  m.interactiveMessageAction = $root.proto.SyncActionValue.InteractiveMessageAction.decode(r, r.uint32());
80536
80569
  break;
80537
80570
  }
80571
+ case 80: {
80572
+ m.nctSaltSyncAction = $root.proto.SyncActionValue.NctSaltSyncAction.decode(r, r.uint32());
80573
+ break;
80574
+ }
80538
80575
  default:
80539
80576
  r.skipType(t & 7);
80540
80577
  break;
@@ -80897,6 +80934,11 @@ export const proto = $root.proto = (() => {
80897
80934
  throw TypeError(".proto.SyncActionValue.interactiveMessageAction: object expected");
80898
80935
  m.interactiveMessageAction = $root.proto.SyncActionValue.InteractiveMessageAction.fromObject(d.interactiveMessageAction);
80899
80936
  }
80937
+ if (d.nctSaltSyncAction != null) {
80938
+ if (typeof d.nctSaltSyncAction !== "object")
80939
+ throw TypeError(".proto.SyncActionValue.nctSaltSyncAction: object expected");
80940
+ m.nctSaltSyncAction = $root.proto.SyncActionValue.NctSaltSyncAction.fromObject(d.nctSaltSyncAction);
80941
+ }
80900
80942
  return m;
80901
80943
  };
80902
80944
 
@@ -81252,6 +81294,11 @@ export const proto = $root.proto = (() => {
81252
81294
  if (o.oneofs)
81253
81295
  d._interactiveMessageAction = "interactiveMessageAction";
81254
81296
  }
81297
+ if (m.nctSaltSyncAction != null && m.hasOwnProperty("nctSaltSyncAction")) {
81298
+ d.nctSaltSyncAction = $root.proto.SyncActionValue.NctSaltSyncAction.toObject(m.nctSaltSyncAction, o);
81299
+ if (o.oneofs)
81300
+ d._nctSaltSyncAction = "nctSaltSyncAction";
81301
+ }
81255
81302
  return d;
81256
81303
  };
81257
81304
 
@@ -81266,6 +81313,98 @@ export const proto = $root.proto = (() => {
81266
81313
  return typeUrlPrefix + "/proto.SyncActionValue";
81267
81314
  };
81268
81315
 
81316
+ SyncActionValue.NctSaltSyncAction = (function() {
81317
+
81318
+ function NctSaltSyncAction(p) {
81319
+ if (p)
81320
+ for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
81321
+ if (p[ks[i]] != null)
81322
+ this[ks[i]] = p[ks[i]];
81323
+ }
81324
+
81325
+ NctSaltSyncAction.prototype.salt = null;
81326
+
81327
+ let $oneOfFields;
81328
+
81329
+ // Virtual OneOf for proto3 optional field
81330
+ Object.defineProperty(NctSaltSyncAction.prototype, "_salt", {
81331
+ get: $util.oneOfGetter($oneOfFields = ["salt"]),
81332
+ set: $util.oneOfSetter($oneOfFields)
81333
+ });
81334
+
81335
+ NctSaltSyncAction.create = function create(properties) {
81336
+ return new NctSaltSyncAction(properties);
81337
+ };
81338
+
81339
+ NctSaltSyncAction.encode = function encode(m, w) {
81340
+ if (!w)
81341
+ w = $Writer.create();
81342
+ if (m.salt != null && Object.hasOwnProperty.call(m, "salt"))
81343
+ w.uint32(10).bytes(m.salt);
81344
+ return w;
81345
+ };
81346
+
81347
+ NctSaltSyncAction.decode = function decode(r, l, e) {
81348
+ if (!(r instanceof $Reader))
81349
+ r = $Reader.create(r);
81350
+ var c = l === undefined ? r.len : r.pos + l, m = new $root.proto.SyncActionValue.NctSaltSyncAction();
81351
+ while (r.pos < c) {
81352
+ var t = r.uint32();
81353
+ if (t === e)
81354
+ break;
81355
+ switch (t >>> 3) {
81356
+ case 1: {
81357
+ m.salt = r.bytes();
81358
+ break;
81359
+ }
81360
+ default:
81361
+ r.skipType(t & 7);
81362
+ break;
81363
+ }
81364
+ }
81365
+ return m;
81366
+ };
81367
+
81368
+ NctSaltSyncAction.fromObject = function fromObject(d) {
81369
+ if (d instanceof $root.proto.SyncActionValue.NctSaltSyncAction)
81370
+ return d;
81371
+ var m = new $root.proto.SyncActionValue.NctSaltSyncAction();
81372
+ if (d.salt != null) {
81373
+ if (typeof d.salt === "string")
81374
+ $util.base64.decode(d.salt, m.salt = $util.newBuffer($util.base64.length(d.salt)), 0);
81375
+ else if (d.salt.length >= 0)
81376
+ m.salt = d.salt;
81377
+ }
81378
+ return m;
81379
+ };
81380
+
81381
+ NctSaltSyncAction.toObject = function toObject(m, o) {
81382
+ if (!o)
81383
+ o = {};
81384
+ var d = {};
81385
+ if (m.salt != null && m.hasOwnProperty("salt")) {
81386
+ d.salt = o.bytes === String ? $util.base64.encode(m.salt, 0, m.salt.length) : o.bytes === Array ? Array.prototype.slice.call(m.salt) : m.salt;
81387
+ if (o.oneofs)
81388
+ d._salt = "salt";
81389
+ }
81390
+ return d;
81391
+ };
81392
+
81393
+ NctSaltSyncAction.prototype.toJSON = function toJSON() {
81394
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
81395
+ };
81396
+
81397
+ NctSaltSyncAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
81398
+ if (typeUrlPrefix === undefined) {
81399
+ typeUrlPrefix = "type.googleapis.com";
81400
+ }
81401
+ return typeUrlPrefix + "/proto.SyncActionValue.NctSaltSyncAction";
81402
+ };
81403
+
81404
+ return NctSaltSyncAction;
81405
+ })();
81406
+
81407
+
81269
81408
  SyncActionValue.AgentAction = (function() {
81270
81409
 
81271
81410
  function AgentAction(p) {
@@ -1052,6 +1052,33 @@ export const makeChatsSocket = (config) => {
1052
1052
  break;
1053
1053
  }
1054
1054
  });
1055
+ // The NCT salt (used to compute cstoken) is delivered via the regular_high app-state
1056
+ // collection, which a full app-state sync only fetches after history sync. When history
1057
+ // sync is disabled, skipped, or times out, fetch regular_high on its own so cstoken works.
1058
+ let nctSaltSyncInFlight = false;
1059
+ const ensureNctSaltSynced = async () => {
1060
+ if (authState.creds.nctSalt?.length || nctSaltSyncInFlight) {
1061
+ return;
1062
+ }
1063
+ nctSaltSyncInFlight = true;
1064
+ try {
1065
+ // The salt may legitimately be absent. Only fetch regular_high if it was never synced:
1066
+ // once it has a persisted version, the salt simply isn't provided for this account, so
1067
+ // re-fetching on every reconnect/timeout won't help (and would loop forever).
1068
+ const { regular_high: state } = await authState.keys.get('app-state-sync-version', ['regular_high']);
1069
+ if (state?.version) {
1070
+ return;
1071
+ }
1072
+ logger.info('no NCT salt stored — syncing regular_high to fetch it');
1073
+ await resyncAppState(['regular_high'], false);
1074
+ }
1075
+ catch (error) {
1076
+ onUnexpectedError(error, 'nct salt regular_high resync');
1077
+ }
1078
+ finally {
1079
+ nctSaltSyncInFlight = false;
1080
+ }
1081
+ };
1055
1082
  ev.on('connection.update', ({ connection, receivedPendingNotifications }) => {
1056
1083
  if (connection === 'close') {
1057
1084
  blockedCollections.clear();
@@ -1081,6 +1108,7 @@ export const makeChatsSocket = (config) => {
1081
1108
  logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.');
1082
1109
  syncState = SyncState.Online;
1083
1110
  setTimeout(() => ev.flush(), 0);
1111
+ void ensureNctSaltSynced();
1084
1112
  return;
1085
1113
  }
1086
1114
  // On reconnection (accountSyncCounter > 0), the server does not push
@@ -1090,6 +1118,7 @@ export const makeChatsSocket = (config) => {
1090
1118
  logger.info('Reconnection with existing sync data, skipping history sync wait. Transitioning to Online.');
1091
1119
  syncState = SyncState.Online;
1092
1120
  setTimeout(() => ev.flush(), 0);
1121
+ void ensureNctSaltSynced();
1093
1122
  return;
1094
1123
  }
1095
1124
  logger.info('First connection, awaiting history sync notification with a 20s timeout.');
@@ -1106,6 +1135,7 @@ export const makeChatsSocket = (config) => {
1106
1135
  // regardless of the state machine phase.
1107
1136
  const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
1108
1137
  ev.emit('creds.update', { accountSyncCounter });
1138
+ void ensureNctSaltSynced();
1109
1139
  }
1110
1140
  }, 20000);
1111
1141
  });
@@ -1195,4 +1225,3 @@ export const makeChatsSocket = (config) => {
1195
1225
  removeQuickReply
1196
1226
  };
1197
1227
  };
1198
- //# sourceMappingURL=chats.js.map
@@ -34,6 +34,9 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
34
34
  updateMemberLabel: (jid: string, memberLabel: string) => Promise<string>;
35
35
  updateMediaMessage: (message: WAMessage) => Promise<WAMessage>;
36
36
  sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<WAMessage | undefined>;
37
+ sendStatusMention: (jidList: string[], content: AnyMessageContent, options?: MiscMessageGenerationOptions & {
38
+ delayMs?: number;
39
+ }) => Promise<WAMessage>;
37
40
  newsletterCreate: (name: string, description?: string) => Promise<import("../Types/index.js").NewsletterMetadata>;
38
41
  newsletterUpdate: (jid: string, updates: import("../Types/index.js").NewsletterUpdate) => Promise<unknown>;
39
42
  newsletterSubscribers: (jid: string) => Promise<{
@@ -196,4 +199,19 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
196
199
  fetchAccountReachoutTimelock: () => Promise<import("../Types/index.js").ReachoutTimelockState>;
197
200
  fetchNewChatMessageCap: () => Promise<import("../Types/index.js").NewChatMessageCapInfo>;
198
201
  };
199
- //# sourceMappingURL=messages-send.d.ts.map
202
+ export type StatusMentionDeps = {
203
+ logger: SocketConfig['logger'];
204
+ config: SocketConfig;
205
+ userJid: string;
206
+ waUploadToServer: import("../Types/index.js").WAMediaUploadFunction;
207
+ relayMessage: (jid: string, message: proto.IMessage, options: MessageRelayOptions) => Promise<string>;
208
+ groupMetadata: (jid: string) => Promise<import("../Types/index.js").GroupMetadata>;
209
+ cachedGroupMetadata?: SocketConfig['cachedGroupMetadata'];
210
+ upsertMessage: (...args: any[]) => Promise<any>;
211
+ messageMutex: {
212
+ mutex: <T>(code: () => Promise<T> | T) => Promise<T>;
213
+ };
214
+ };
215
+ export declare const sendStatusMentionImpl: (deps: StatusMentionDeps, jidList: string[], content: AnyMessageContent, options?: MiscMessageGenerationOptions & {
216
+ delayMs?: number;
217
+ }) => Promise<WAMessage>;
@@ -1,15 +1,117 @@
1
1
  import NodeCache from '@cacheable/node-cache';
2
2
  import { Boom } from '@hapi/boom';
3
+ import { randomBytes } from 'crypto';
3
4
  import { proto } from '../../WAProto/index.js';
4
5
  import { DEFAULT_CACHE_TTLS, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
5
- import { aggregateMessageKeysNotFromMe, assertMediaContent, assertMeId, bindWaitForEvent, decryptMediaRetryData, DEF_MEDIA_HOST, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, generateMessageIDV2, generateParticipantHashV2, generateWAMessage, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, MessageRetryManager, normalizeMessageContent, parseAndInjectE2ESessions, unixTimestampSeconds } from '../Utils/index.js';
6
+ import { aggregateMessageKeysNotFromMe, assertMediaContent, assertMeId, bindWaitForEvent, decryptMediaRetryData, DEF_MEDIA_HOST, delay, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, generateMessageIDV2, generateParticipantHashV2, generateWAMessage, generateWAMessageFromContent, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, MessageRetryManager, normalizeMessageContent, parseAndInjectE2ESessions, unixTimestampSeconds } from '../Utils/index.js';
6
7
  import { getUrlInfo } from '../Utils/link-preview.js';
7
8
  import { makeKeyedMutex, makeMutex } from '../Utils/make-mutex.js';
8
9
  import { getMessageReportingToken, shouldIncludeReportingToken } from '../Utils/reporting-utils.js';
9
- import { buildMergedTcTokenIndexWrite, isTcTokenExpired, resolveIssuanceJid, resolveTcTokenJid, shouldSendNewTcToken, storeTcTokensFromIqResult } from '../Utils/tc-token-utils.js';
10
+ import { buildMergedTcTokenIndexWrite, computeCsToken, isTcTokenExpired, resolveIssuanceJid, resolveTcTokenJid, shouldSendNewTcToken, storeTcTokensFromIqResult } from '../Utils/tc-token-utils.js';
10
11
  import { areJidsSameUser, getBinaryNodeChild, getBinaryNodeChildren, isHostedLidUser, isHostedPnUser, isJidBot, isJidGroup, isJidMetaAI, isLidUser, isPnUser, jidDecode, jidEncode, jidNormalizedUser, PSA_WID, S_WHATSAPP_NET } from '../WABinary/index.js';
11
12
  import { USyncQuery, USyncUser } from '../WAUSync/index.js';
12
13
  import { makeNewsletterSocket } from './newsletter.js';
14
+ /**
15
+ * Status (story) mein contacts/groups ko mention karne ka wire flow.
16
+ * Pehle status content `status@broadcast` par relay hota hai — `statusJidList` mein
17
+ * tamam expanded participants aur `<meta><mentioned_users>` node mein asal mention
18
+ * JIDs. Phir har mentioned JID/group ko alag `statusMentionMessage` /
19
+ * `groupStatusMentionMessage` (protocolMessage type 25 = STATUS_MENTION_MESSAGE)
20
+ * relay hota hai, ~1500ms pacing ke sath. Deps inject kiye jate hain taake socket
21
+ * factory aur unit tests dono isi implementation ko istemal kar saken.
22
+ */
23
+ export const sendStatusMentionImpl = async (deps, jidList, content, options = {}) => {
24
+ const { logger, config, userJid, waUploadToServer, relayMessage, groupMetadata, cachedGroupMetadata, upsertMessage, messageMutex } = deps;
25
+ const { delayMs = 1500 } = options;
26
+ const allUsers = new Set();
27
+ const fullMsg = await generateWAMessage('status@broadcast', content, {
28
+ logger,
29
+ userJid,
30
+ upload: waUploadToServer,
31
+ mediaCache: config.mediaCache,
32
+ options: config.options,
33
+ ...options,
34
+ messageId: generateMessageIDV2(userJid)
35
+ });
36
+ for (const id of jidList) {
37
+ if (isJidGroup(id)) {
38
+ try {
39
+ const groupData = (cachedGroupMetadata ? await cachedGroupMetadata(id) : null) || (await groupMetadata(id));
40
+ for (const participant of groupData.participants) {
41
+ allUsers.add(participant.id);
42
+ }
43
+ }
44
+ catch (error) {
45
+ logger.error({ error, jid: id }, 'status mention ke liye group metadata fail ho gaya');
46
+ }
47
+ }
48
+ else {
49
+ allUsers.add(id);
50
+ }
51
+ }
52
+ await relayMessage('status@broadcast', fullMsg.message, {
53
+ messageId: fullMsg.key.id,
54
+ statusJidList: Array.from(allUsers),
55
+ additionalNodes: [
56
+ {
57
+ tag: 'meta',
58
+ attrs: {},
59
+ content: [
60
+ {
61
+ tag: 'mentioned_users',
62
+ attrs: {},
63
+ content: jidList.map(id => ({
64
+ tag: 'to',
65
+ attrs: { jid: id },
66
+ content: undefined
67
+ }))
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ });
73
+ if (config.emitOwnEvents) {
74
+ process.nextTick(async () => {
75
+ await messageMutex.mutex(() => upsertMessage(fullMsg, 'append'));
76
+ });
77
+ }
78
+ for (const id of jidList) {
79
+ const isGroup = isJidGroup(id);
80
+ const mentionMsg = generateWAMessageFromContent(id, {
81
+ messageContextInfo: {
82
+ messageSecret: randomBytes(32)
83
+ },
84
+ [isGroup ? 'groupStatusMentionMessage' : 'statusMentionMessage']: {
85
+ message: {
86
+ protocolMessage: {
87
+ key: fullMsg.key,
88
+ type: proto.Message.ProtocolMessage.Type.STATUS_MENTION_MESSAGE
89
+ }
90
+ }
91
+ }
92
+ }, {
93
+ userJid
94
+ });
95
+ await relayMessage(id, mentionMsg.message, {
96
+ additionalNodes: [
97
+ {
98
+ tag: 'meta',
99
+ attrs: isGroup
100
+ ? { is_group_status_mention: 'true' }
101
+ : { is_status_mention: 'true' },
102
+ content: undefined
103
+ }
104
+ ]
105
+ });
106
+ if (config.emitOwnEvents) {
107
+ process.nextTick(async () => {
108
+ await messageMutex.mutex(() => upsertMessage(mentionMsg, 'append'));
109
+ });
110
+ }
111
+ await delay(delayMs);
112
+ }
113
+ return fullMsg;
114
+ };
13
115
  export const makeMessagesSocket = (config) => {
14
116
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: httpRequestOptions, patchMessageBeforeSending, cachedGroupMetadata, enableRecentMessageCache, maxMsgRetryCount } = config;
15
117
  const sock = makeNewsletterSocket(config);
@@ -827,6 +929,23 @@ export const makeMessagesSocket = (config) => {
827
929
  content: tcTokenBuffer
828
930
  });
829
931
  }
932
+ else if (is1on1Send &&
933
+ sock.serverProps.privacyTokenOn1to1 &&
934
+ authState.creds.me?.lid &&
935
+ authState.creds.nctSalt?.length &&
936
+ tcTokenJid &&
937
+ isLidUser(tcTokenJid)) {
938
+ // no tctoken from the recipient — fall back to a self-computed cstoken (WA Web parity;
939
+ // only sent from a LID-addressed account, so skip PN-only sessions). The privacyTokenOn1to1
940
+ // AB gate above is kept for the fallback too: with the gate off, no privacy token is attached.
941
+ ;
942
+ stanza.content.push({
943
+ tag: 'cstoken',
944
+ attrs: {},
945
+ content: computeCsToken(authState.creds.nctSalt, tcTokenJid)
946
+ });
947
+ logger.debug({ jid: destinationJid }, 'attached cstoken fallback');
948
+ }
830
949
  if (additionalNodes && additionalNodes.length > 0) {
831
950
  ;
832
951
  stanza.content.push(...additionalNodes);
@@ -1050,6 +1169,19 @@ export const makeMessagesSocket = (config) => {
1050
1169
  ev.emit('messages.update', [{ key: message.key, update: { message: message.message } }]);
1051
1170
  return message;
1052
1171
  },
1172
+ sendStatusMention: async (jidList, content, options = {}) => {
1173
+ return sendStatusMentionImpl({
1174
+ logger,
1175
+ config,
1176
+ userJid: authState.creds.me.id,
1177
+ waUploadToServer,
1178
+ relayMessage,
1179
+ groupMetadata,
1180
+ cachedGroupMetadata,
1181
+ upsertMessage,
1182
+ messageMutex
1183
+ }, jidList, content, options);
1184
+ },
1053
1185
  sendMessage: async (jid, content, options = {}) => {
1054
1186
  const userJid = authState.creds.me.id;
1055
1187
  if (typeof content === 'object' &&
@@ -1142,4 +1274,3 @@ export const makeMessagesSocket = (config) => {
1142
1274
  }
1143
1275
  };
1144
1276
  };
1145
- //# sourceMappingURL=messages-send.js.map
@@ -12,6 +12,7 @@ import { BinaryInfo } from '../WAM/BinaryInfo.js';
12
12
  import { USyncQuery, USyncUser } from '../WAUSync/index.js';
13
13
  import { WebSocketClient } from './Client/index.js';
14
14
  import { executeWMexQuery } from './mex.js';
15
+ import { printStablebailBanner } from '../Utils/banner.js';
15
16
  /**
16
17
  * Connects to WA servers and performs:
17
18
  * - simple queries (no retry mechanism, wait for connection establishment)
@@ -22,6 +23,8 @@ export const makeSocket = (config) => {
22
23
  const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository } = config;
23
24
  const publicWAMBuffer = new BinaryInfo();
24
25
  let serverTimeOffsetMs = 0;
26
+ /** stablebail banner har socket instance par zyada se zyada aik dafa print hota hai */
27
+ let stablebailBannerPrinted = false;
25
28
  const uqTagId = generateMdTagPrefix();
26
29
  const generateMessageTag = () => `${uqTagId}${epoch++}`;
27
30
  if (printQRInTerminal) {
@@ -790,6 +793,10 @@ export const makeSocket = (config) => {
790
793
  clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
791
794
  ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
792
795
  ev.emit('connection.update', { connection: 'open' });
796
+ if (config.banner !== false && !stablebailBannerPrinted) {
797
+ stablebailBannerPrinted = true;
798
+ printStablebailBanner();
799
+ }
793
800
  void sendUnifiedSession();
794
801
  if (node.attrs.lid && authState.creds.me?.id) {
795
802
  const myLID = node.attrs.lid;
@@ -64,6 +64,8 @@ export type AuthenticationCreds = SignalCreds & {
64
64
  lastPropHash: string | undefined;
65
65
  routingInfo: Buffer | undefined;
66
66
  additionalData?: any | undefined;
67
+ /** NCT salt for cstoken computation, provisioned via nctSaltSync app state */
68
+ nctSalt?: Uint8Array | undefined;
67
69
  };
68
70
  export type SignalDataTypeMap = {
69
71
  'pre-key': KeyPair;
@@ -114,4 +116,3 @@ export type AuthenticationState = {
114
116
  keys: SignalKeyStore;
115
117
  };
116
118
  export {};
117
- //# sourceMappingURL=Auth.d.ts.map
@@ -59,6 +59,8 @@ export type SocketConfig = {
59
59
  * @deprecated This feature has been removed
60
60
  */
61
61
  printQRInTerminal?: boolean;
62
+ /** stablebail banner connection open hone par aik dafa print hota hai — band karne ke liye false (default: true) */
63
+ banner?: boolean;
62
64
  /** should events be emitted for actions done by this socket connection */
63
65
  emitOwnEvents: boolean;
64
66
  /** custom upload hosts to upload media to */
@@ -133,4 +135,3 @@ export type SocketConfig = {
133
135
  cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
134
136
  makeSignalRepository: (auth: SignalAuthState, logger: ILogger, pnToLIDFunc?: (jids: string[]) => Promise<LIDMapping[] | undefined>) => SignalRepositoryWithLIDStore;
135
137
  };
136
- //# sourceMappingURL=Socket.d.ts.map
@@ -296,7 +296,7 @@ export const initAuthCreds = () => {
296
296
  pairingCode: undefined,
297
297
  lastPropHash: undefined,
298
298
  routingInfo: undefined,
299
- additionalData: undefined
299
+ additionalData: undefined,
300
+ nctSalt: undefined
300
301
  };
301
302
  };
302
- //# sourceMappingURL=auth-utils.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * stablebail banner — connection open hone par aik dafa print hota hai.
3
+ * Socket config `banner: false` se band ho jata hai. Kabhi throw nahi karta.
4
+ */
5
+ export declare const printStablebailBanner: () => void;
6
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * stablebail banner — bot ke connect (connection open) hone par sirf aik dafa
3
+ * print hota hai. Socket config mein `banner: false` de kar band kar sakte hain.
4
+ * Koi external dependency nahi, aur ye function kabhi throw nahi karta.
5
+ */
6
+ const BANNER_LINES = [
7
+ '╭───────────────────────────╮',
8
+ '│ ✦ Q A D E E R ✦ │',
9
+ '│ stablebail • Qadeer-Xtech │',
10
+ '╰───────────────────────────╯'
11
+ ];
12
+ export const printStablebailBanner = () => {
13
+ try {
14
+ console.log(BANNER_LINES.join('\n'));
15
+ }
16
+ catch {
17
+ // banner kabhi bhi socket ko fail nahi kar sakta
18
+ }
19
+ };
@@ -850,6 +850,11 @@ export const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) =
850
850
  value: action.privacySettingChannelsPersonalisedRecommendationAction
851
851
  });
852
852
  }
853
+ else if (action?.nctSaltSyncAction) {
854
+ const salt = action.nctSaltSyncAction.salt;
855
+ logger?.info({ hasSalt: !!salt?.length }, 'nctSaltSyncAction received from app-state sync');
856
+ ev.emit('creds.update', { nctSalt: salt?.length ? new Uint8Array(salt) : undefined });
857
+ }
853
858
  else {
854
859
  logger?.debug({ syncAction, id }, 'unprocessable update');
855
860
  }
@@ -869,4 +874,3 @@ export const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) =
869
874
  return lastMsgTimestamp >= chatLastMsgTimestamp;
870
875
  }
871
876
  };
872
- //# sourceMappingURL=chat-utils.js.map
@@ -111,6 +111,7 @@ export const processHistoryMessage = (item, logger) => {
111
111
  contacts,
112
112
  messages,
113
113
  lidPnMappings,
114
+ nctSalt: item.nctSalt ? new Uint8Array(item.nctSalt) : undefined,
114
115
  pastParticipants: item.pastParticipants,
115
116
  syncType: item.syncType,
116
117
  progress: item.progress
@@ -131,4 +132,3 @@ export const getHistoryMsg = (message) => {
131
132
  const anyHistoryMsg = normalizedContent?.protocolMessage?.historySyncNotification;
132
133
  return anyHistoryMsg;
133
134
  };
134
- //# sourceMappingURL=history.js.map
@@ -10,6 +10,7 @@ export * from './history.js';
10
10
  export * from './chat-utils.js';
11
11
  export * from './lt-hash.js';
12
12
  export * from './auth-utils.js';
13
+ export * from './banner.js';
13
14
  export * from './use-multi-file-auth-state.js';
14
15
  export * from './link-preview.js';
15
16
  export * from './event-buffer.js';
@@ -19,4 +20,3 @@ export * from './browser-utils.js';
19
20
  export * from './companion-reg-client-utils.js';
20
21
  export * from './identity-change-handler.js';
21
22
  export * from './stanza-ack.js';
22
- //# sourceMappingURL=index.js.map
@@ -267,6 +267,10 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
267
267
  .catch(err => logger?.warn({ err }, 'failed to store LID-PN mappings from history sync'));
268
268
  }
269
269
  await storeTcTokensFromHistorySync(data.chats, signalRepository, keyStore, logger);
270
+ if (data.nctSalt?.length) {
271
+ logger?.info('nctSalt received from history sync');
272
+ ev.emit('creds.update', { nctSalt: data.nctSalt });
273
+ }
270
274
  ev.emit('messaging-history.set', {
271
275
  ...data,
272
276
  isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND ? isLatest : undefined,
@@ -627,4 +631,3 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
627
631
  }
628
632
  };
629
633
  export default processMessage;
630
- //# sourceMappingURL=process-message.js.map
@@ -33,5 +33,6 @@ type StoreTcTokensParams = {
33
33
  onNewJidStored?: (jid: string) => void;
34
34
  };
35
35
  export declare function storeTcTokensFromIqResult({ result, fallbackJid, keys, getLIDForPN, onNewJidStored }: StoreTcTokensParams): Promise<void>;
36
- export {};
37
- //# sourceMappingURL=tc-token-utils.d.ts.map
36
+ /** Client-side fallback token when the recipient hasn't issued a tctoken. Mirrors WA Web genCsTokenBody. */
37
+ export declare function computeCsToken(nctSalt: Uint8Array, recipientLid: string): Uint8Array;
38
+ export {};