@fer2809fl/baileys 7.0.1 → 7.0.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.
- package/README.md +322 -578
- package/WAProto/WAProto.proto +916 -360
- package/WAProto/fix-imports.js +18 -22
- package/WAProto/index.d.ts +15471 -8638
- package/WAProto/index.js +80576 -45941
- package/lib/Defaults/index.d.ts +14 -18
- package/lib/Defaults/index.js +111 -115
- package/lib/Signal/libsignal.js +22 -31
- package/lib/Signal/lid-mapping.d.ts +0 -4
- package/lib/Signal/lid-mapping.js +0 -6
- package/lib/Socket/business.d.ts +8 -75
- package/lib/Socket/business.js +1 -0
- package/lib/Socket/chats.d.ts +0 -6
- package/lib/Socket/chats.js +3 -67
- package/lib/Socket/communities.d.ts +641 -336
- package/lib/Socket/communities.js +3 -6
- package/lib/Socket/dugong.d.ts +130 -0
- package/lib/Socket/dugong.js +772 -0
- package/lib/Socket/groups.d.ts +18 -23
- package/lib/Socket/groups.js +88 -168
- package/lib/Socket/index.d.ts +631 -322
- package/lib/Socket/index.js +12 -9
- package/lib/Socket/messages-recv.d.ts +52 -84
- package/lib/Socket/messages-recv.js +193 -677
- package/lib/Socket/messages-send.d.ts +643 -262
- package/lib/Socket/messages-send.js +1559 -1359
- package/lib/Socket/mex.d.ts +0 -1
- package/lib/Socket/mex.js +8 -22
- package/lib/Socket/native-buttons.js +231 -0
- package/lib/Socket/newsletter.d.ts +27 -42
- package/lib/Socket/newsletter.js +439 -402
- package/lib/Socket/socket.d.ts +2 -6
- package/lib/Socket/socket.js +47 -39
- package/lib/Types/Auth.d.ts +0 -1
- package/lib/Types/Bussines.d.ts +34 -22
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +0 -1
- package/lib/Types/Contact.d.ts +0 -2
- package/lib/Types/Events.d.ts +1 -20
- package/lib/Types/GroupMetadata.d.ts +1 -4
- package/lib/Types/Message.d.ts +348 -354
- package/lib/Types/Message.js +0 -4
- package/lib/Types/{Mex.d.ts → Newsletter.d.ts} +7 -17
- package/lib/Types/{Mex.js → Newsletter.js} +5 -3
- package/lib/Types/Signal.d.ts +1 -12
- package/lib/Types/Socket.d.ts +148 -135
- package/lib/Types/State.d.ts +0 -65
- package/lib/Types/State.js +0 -43
- package/lib/Types/index.d.ts +52 -52
- package/lib/Types/index.js +30 -23
- package/lib/Utils/auth-utils.d.ts +0 -5
- package/lib/Utils/auth-utils.js +0 -12
- package/lib/Utils/browser-utils.js +0 -1
- package/lib/Utils/crypto.d.ts +12 -12
- package/lib/Utils/decode-wa-message.d.ts +0 -18
- package/lib/Utils/decode-wa-message.js +0 -34
- package/lib/Utils/event-buffer.d.ts +0 -2
- package/lib/Utils/generics.d.ts +2 -3
- package/lib/Utils/generics.js +1 -10
- package/lib/Utils/history.d.ts +0 -2
- package/lib/Utils/history.js +9 -12
- package/lib/Utils/identity-change-handler.d.ts +0 -7
- package/lib/Utils/identity-change-handler.js +0 -1
- package/lib/Utils/index.d.ts +23 -30
- package/lib/Utils/index.js +3 -9
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/message-retry-manager.d.ts +0 -5
- package/lib/Utils/message-retry-manager.js +11 -11
- package/lib/Utils/messages-media.d.ts +13 -45
- package/lib/Utils/messages-media.js +98 -293
- package/lib/Utils/messages.d.ts +3 -16
- package/lib/Utils/messages.js +1123 -1219
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/process-message.js +1 -103
- package/lib/Utils/rich-messages.d.ts +277 -0
- package/lib/Utils/rich-messages.js +1144 -0
- package/lib/Utils/signal.d.ts +0 -13
- package/lib/Utils/signal.js +0 -42
- package/lib/Utils/sticker-pack.d.ts +10 -0
- package/lib/Utils/sticker-pack.js +111 -0
- package/lib/Utils/sync-action-utils.js +0 -1
- package/lib/Utils/tc-token-utils.d.ts +1 -26
- package/lib/Utils/tc-token-utils.js +5 -151
- package/lib/Utils/validate-connection.d.ts +0 -1
- package/lib/Utils/validate-connection.js +3 -13
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/generic-utils.d.ts +3 -1
- package/lib/WABinary/generic-utils.js +78 -0
- package/lib/WABinary/jid-utils.d.ts +0 -11
- package/lib/WABinary/jid-utils.js +0 -33
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -26
- package/lib/WAUSync/Protocols/index.d.ts +0 -1
- package/lib/WAUSync/USyncQuery.d.ts +0 -1
- package/lib/WAUSync/USyncQuery.js +1 -1
- package/lib/WAUSync/USyncUser.d.ts +0 -4
- package/lib/WAUSync/USyncUser.js +0 -8
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -4
- package/package.json +27 -31
- package/LICENSE +0 -21
- package/engine-requirements.js +0 -10
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/smgss.d.ts +0 -119
- package/lib/Socket/smgss.d.ts.map +0 -1
- package/lib/Socket/smgss.js +0 -453
- package/lib/Socket/smgss.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/index.d.ts.map +0 -1
- package/lib/Store/index.js +0 -4
- package/lib/Store/index.js.map +0 -1
- package/lib/Store/make-in-memory-store.d.ts +0 -132
- package/lib/Store/make-in-memory-store.d.ts.map +0 -1
- package/lib/Store/make-in-memory-store.js +0 -450
- package/lib/Store/make-in-memory-store.js.map +0 -1
- package/lib/Store/make-ordered-dictionary.d.ts +0 -14
- package/lib/Store/make-ordered-dictionary.d.ts.map +0 -1
- package/lib/Store/make-ordered-dictionary.js +0 -80
- package/lib/Store/make-ordered-dictionary.js.map +0 -1
- package/lib/Store/object-repository.d.ts +0 -13
- package/lib/Store/object-repository.d.ts.map +0 -1
- package/lib/Store/object-repository.js +0 -24
- package/lib/Store/object-repository.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Mex.d.ts.map +0 -1
- package/lib/Types/Mex.js.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/button-handler.d.ts +0 -28
- package/lib/Utils/button-handler.d.ts.map +0 -1
- package/lib/Utils/button-handler.js +0 -140
- package/lib/Utils/button-handler.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/companion-reg-client-utils.d.ts.map +0 -1
- package/lib/Utils/companion-reg-client-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/identity-change-handler.d.ts.map +0 -1
- package/lib/Utils/identity-change-handler.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/interactive.d.ts +0 -60
- package/lib/Utils/interactive.d.ts.map +0 -1
- package/lib/Utils/interactive.js +0 -224
- package/lib/Utils/interactive.js.map +0 -1
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-composer.d.ts +0 -93
- package/lib/Utils/message-composer.d.ts.map +0 -1
- package/lib/Utils/message-composer.js +0 -311
- package/lib/Utils/message-composer.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages-newsletter.d.ts +0 -74
- package/lib/Utils/messages-newsletter.d.ts.map +0 -1
- package/lib/Utils/messages-newsletter.js +0 -128
- package/lib/Utils/messages-newsletter.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/offline-node-processor.d.ts.map +0 -1
- package/lib/Utils/offline-node-processor.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/reporting-utils.d.ts.map +0 -1
- package/lib/Utils/reporting-utils.js.map +0 -1
- package/lib/Utils/shortcake-crypto.d.ts +0 -36
- package/lib/Utils/shortcake-crypto.d.ts.map +0 -1
- package/lib/Utils/shortcake-crypto.js +0 -71
- package/lib/Utils/shortcake-crypto.js.map +0 -1
- package/lib/Utils/shortcake.d.ts +0 -36
- package/lib/Utils/shortcake.d.ts.map +0 -1
- package/lib/Utils/shortcake.js +0 -162
- package/lib/Utils/shortcake.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/stanza-ack.d.ts.map +0 -1
- package/lib/Utils/stanza-ack.js.map +0 -1
- package/lib/Utils/sync-action-utils.d.ts.map +0 -1
- package/lib/Utils/sync-action-utils.js.map +0 -1
- package/lib/Utils/tc-token-utils.d.ts.map +0 -1
- package/lib/Utils/tc-token-utils.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-single-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-single-file-auth-state.js +0 -111
- package/lib/Utils/use-single-file-auth-state.js.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.d.ts +0 -14
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-sqlite-auth-state.js +0 -107
- package/lib/Utils/use-sqlite-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts.map +0 -1
- package/lib/WABinary/generic-utils.js.map +0 -1
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts.map +0 -1
- package/lib/WABinary/jid-utils.js.map +0 -1
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Utils/signal.d.ts
CHANGED
|
@@ -15,19 +15,6 @@ export declare const generateOrGetPreKeys: (creds: AuthenticationCreds, range: n
|
|
|
15
15
|
};
|
|
16
16
|
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
|
|
17
17
|
export declare const xmppPreKey: (pair: KeyPair, id: number) => BinaryNode;
|
|
18
|
-
export declare const extractE2ESessionFromRetryReceipt: (receipt: BinaryNode) => {
|
|
19
|
-
registrationId: number;
|
|
20
|
-
identityKey: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
21
|
-
signedPreKey: {
|
|
22
|
-
keyId: number;
|
|
23
|
-
publicKey: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
24
|
-
signature: Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>;
|
|
25
|
-
};
|
|
26
|
-
preKey: {
|
|
27
|
-
keyId: number;
|
|
28
|
-
publicKey: Uint8Array;
|
|
29
|
-
} | undefined;
|
|
30
|
-
} | null;
|
|
31
18
|
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepositoryWithLIDStore) => Promise<void>;
|
|
32
19
|
export declare const extractDeviceJids: (result: USyncQueryResultList[], myJid: string, myLid: string, excludeZeroDevices: boolean) => FullJid[];
|
|
33
20
|
/**
|
package/lib/Utils/signal.js
CHANGED
|
@@ -55,48 +55,6 @@ export const xmppPreKey = (pair, id) => ({
|
|
|
55
55
|
{ tag: 'value', attrs: {}, content: pair.public }
|
|
56
56
|
]
|
|
57
57
|
});
|
|
58
|
-
const isValidUInt = (n) => typeof n === 'number' && Number.isInteger(n);
|
|
59
|
-
export const extractE2ESessionFromRetryReceipt = (receipt) => {
|
|
60
|
-
const keysNode = getBinaryNodeChild(receipt, 'keys');
|
|
61
|
-
if (!keysNode)
|
|
62
|
-
return null;
|
|
63
|
-
const typeBuf = getBinaryNodeChildBuffer(keysNode, 'type');
|
|
64
|
-
if (!typeBuf || typeBuf.length !== 1 || typeBuf[0] !== KEY_BUNDLE_TYPE[0])
|
|
65
|
-
return null;
|
|
66
|
-
const identity = getBinaryNodeChildBuffer(keysNode, 'identity');
|
|
67
|
-
const skey = getBinaryNodeChild(keysNode, 'skey');
|
|
68
|
-
if (!identity || identity.length !== 32 || !skey)
|
|
69
|
-
return null;
|
|
70
|
-
const registrationId = getBinaryNodeChildUInt(receipt, 'registration', 4);
|
|
71
|
-
if (!isValidUInt(registrationId))
|
|
72
|
-
return null;
|
|
73
|
-
const signedPubKey = getBinaryNodeChildBuffer(skey, 'value');
|
|
74
|
-
const signedSig = getBinaryNodeChildBuffer(skey, 'signature');
|
|
75
|
-
const signedKeyId = getBinaryNodeChildUInt(skey, 'id', 3);
|
|
76
|
-
if (!signedPubKey || signedPubKey.length !== 32 || !signedSig || !isValidUInt(signedKeyId)) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const preKeyNode = getBinaryNodeChild(keysNode, 'key');
|
|
80
|
-
let preKey;
|
|
81
|
-
if (preKeyNode) {
|
|
82
|
-
const preKeyPub = getBinaryNodeChildBuffer(preKeyNode, 'value');
|
|
83
|
-
const preKeyId = getBinaryNodeChildUInt(preKeyNode, 'id', 3);
|
|
84
|
-
if (!preKeyPub || preKeyPub.length !== 32 || !isValidUInt(preKeyId)) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
preKey = { keyId: preKeyId, publicKey: generateSignalPubKey(preKeyPub) };
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
registrationId,
|
|
91
|
-
identityKey: generateSignalPubKey(identity),
|
|
92
|
-
signedPreKey: {
|
|
93
|
-
keyId: signedKeyId,
|
|
94
|
-
publicKey: generateSignalPubKey(signedPubKey),
|
|
95
|
-
signature: signedSig
|
|
96
|
-
},
|
|
97
|
-
preKey
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
58
|
export const parseAndInjectE2ESessions = async (node, repository) => {
|
|
101
59
|
const extractKey = (key) => key
|
|
102
60
|
? {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StickerPackContent } from '../Types/Message.js';
|
|
2
|
+
export type MakeStickerPackOptions = StickerPackContent & {
|
|
3
|
+
contextInfo?: any;
|
|
4
|
+
};
|
|
5
|
+
export declare const makeStickerPack: (
|
|
6
|
+
options?: MakeStickerPackOptions,
|
|
7
|
+
) => {
|
|
8
|
+
stickerPack: StickerPackContent;
|
|
9
|
+
contextInfo?: any;
|
|
10
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default emojis assigned to stickers when none are provided.
|
|
3
|
+
* Rotates through this list by sticker index.
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_EMOJIS = [
|
|
6
|
+
"😀",
|
|
7
|
+
"😂",
|
|
8
|
+
"😍",
|
|
9
|
+
"🔥",
|
|
10
|
+
"👍",
|
|
11
|
+
"🎉",
|
|
12
|
+
"😎",
|
|
13
|
+
"🤩",
|
|
14
|
+
"💯",
|
|
15
|
+
"🥳",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Normalize a single sticker entry.
|
|
20
|
+
* Input can be:
|
|
21
|
+
* - Buffer
|
|
22
|
+
* - { url: string }
|
|
23
|
+
* - { sticker: Buffer | { url: string }, emojis?: string[], accessibilityLabel?: string }
|
|
24
|
+
*
|
|
25
|
+
* @param {Buffer | { url: string } | object} entry
|
|
26
|
+
* @param {number} index
|
|
27
|
+
* @returns {{ sticker: Buffer | { url: string }, emojis: string[], accessibilityLabel: string }}
|
|
28
|
+
*/
|
|
29
|
+
const normalizeSticker = (entry, index) => {
|
|
30
|
+
if (
|
|
31
|
+
Buffer.isBuffer(entry) ||
|
|
32
|
+
(entry &&
|
|
33
|
+
typeof entry === "object" &&
|
|
34
|
+
"url" in entry &&
|
|
35
|
+
!("sticker" in entry))
|
|
36
|
+
) {
|
|
37
|
+
return {
|
|
38
|
+
sticker: entry,
|
|
39
|
+
emojis: [DEFAULT_EMOJIS[index % DEFAULT_EMOJIS.length]],
|
|
40
|
+
accessibilityLabel: "",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
sticker: entry.sticker || entry.data,
|
|
45
|
+
emojis: entry.emojis || [DEFAULT_EMOJIS[index % DEFAULT_EMOJIS.length]],
|
|
46
|
+
accessibilityLabel: entry.accessibilityLabel || "",
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build a stickerPack message object ready to pass to sock.sendMessage.
|
|
52
|
+
*
|
|
53
|
+
* @param {object} options
|
|
54
|
+
* @param {string} options.name - Pack display name
|
|
55
|
+
* @param {string} [options.publisher] - Pack publisher/author name
|
|
56
|
+
* @param {string} [options.description] - Pack description
|
|
57
|
+
* @param {string} [options.packId] - Custom pack ID (auto-generated if omitted)
|
|
58
|
+
* @param {Array<Buffer | { url: string } | { sticker: Buffer | { url: string }, emojis?: string[] }>} options.stickers
|
|
59
|
+
* List of stickers — accepts raw buffers, URL objects, or full sticker descriptor objects.
|
|
60
|
+
* @param {Buffer | { url: string }} [options.cover]
|
|
61
|
+
* Tray/cover image. Defaults to the first sticker if omitted.
|
|
62
|
+
* @param {object} [options.contextInfo] - Optional context info (mentions, forwarding, etc.)
|
|
63
|
+
* @returns {{ stickerPack: object }}
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // With buffers
|
|
67
|
+
* await sock.sendMessage(jid, makeStickerPack({
|
|
68
|
+
* name: 'My Pack',
|
|
69
|
+
* stickers: [buf1, buf2, buf3]
|
|
70
|
+
* }));
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // With URLs
|
|
74
|
+
* await sock.sendMessage(jid, makeStickerPack({
|
|
75
|
+
* name: 'Anime Pack',
|
|
76
|
+
* publisher: 'Ourin AI',
|
|
77
|
+
* stickers: [
|
|
78
|
+
* { url: 'https://example.com/s1.webp', emojis: ['😀'] },
|
|
79
|
+
* { url: 'https://example.com/s2.webp' }
|
|
80
|
+
* ],
|
|
81
|
+
* cover: { url: 'https://example.com/cover.jpg' }
|
|
82
|
+
* }));
|
|
83
|
+
*/
|
|
84
|
+
export const makeStickerPack = ({
|
|
85
|
+
name,
|
|
86
|
+
publisher = "Ourin AI",
|
|
87
|
+
description = "",
|
|
88
|
+
packId,
|
|
89
|
+
stickers = [],
|
|
90
|
+
cover,
|
|
91
|
+
contextInfo,
|
|
92
|
+
} = {}) => {
|
|
93
|
+
if (!name) throw new Error("makeStickerPack: name is required");
|
|
94
|
+
if (!stickers.length)
|
|
95
|
+
throw new Error("makeStickerPack: at least one sticker is required");
|
|
96
|
+
|
|
97
|
+
const normalizedStickers = stickers.map(normalizeSticker);
|
|
98
|
+
const resolvedCover = cover ?? normalizedStickers[0].sticker;
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
stickerPack: {
|
|
102
|
+
name,
|
|
103
|
+
publisher,
|
|
104
|
+
description,
|
|
105
|
+
...(packId ? { packId } : {}),
|
|
106
|
+
stickers: normalizedStickers,
|
|
107
|
+
cover: resolvedCover,
|
|
108
|
+
},
|
|
109
|
+
...(contextInfo ? { contextInfo } : {}),
|
|
110
|
+
};
|
|
111
|
+
};
|
|
@@ -1,37 +1,12 @@
|
|
|
1
1
|
import type { SignalKeyStoreWithTransaction } from '../Types/index.js';
|
|
2
2
|
import type { BinaryNode } from '../WABinary/index.js';
|
|
3
|
-
/** Sentinel key under `tctoken` store holding a JSON array of tracked storage JIDs for cross-session pruning. */
|
|
4
|
-
export declare const TC_TOKEN_INDEX_KEY = "__index";
|
|
5
|
-
/** Read the persisted tctoken JID index and return its entries (never contains the sentinel key itself). */
|
|
6
|
-
export declare function readTcTokenIndex(keys: SignalKeyStoreWithTransaction): Promise<string[]>;
|
|
7
|
-
/** Build a SignalDataSet fragment that writes the merged index (persisted ∪ added) under the sentinel key. */
|
|
8
|
-
export declare function buildMergedTcTokenIndexWrite(keys: SignalKeyStoreWithTransaction, addedJids: Iterable<string>): Promise<{
|
|
9
|
-
[TC_TOKEN_INDEX_KEY]: {
|
|
10
|
-
token: Buffer;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
export declare function isTcTokenExpired(timestamp: number | string | null | undefined): boolean;
|
|
14
|
-
export declare function shouldSendNewTcToken(senderTimestamp: number | undefined): boolean;
|
|
15
|
-
/** Resolve JID to LID for tctoken storage (WA Web stores under LID) */
|
|
16
|
-
export declare function resolveTcTokenJid(jid: string, getLIDForPN: (pn: string) => Promise<string | null>): Promise<string>;
|
|
17
|
-
/** Resolve target JID for issuing privacy token based on AB prop 14303 */
|
|
18
|
-
export declare function resolveIssuanceJid(jid: string, issueToLid: boolean, getLIDForPN: (pn: string) => Promise<string | null>, getPNForLID?: (lid: string) => Promise<string | null>): Promise<string>;
|
|
19
3
|
type TcTokenParams = {
|
|
20
4
|
jid: string;
|
|
21
5
|
baseContent?: BinaryNode[];
|
|
22
6
|
authState: {
|
|
23
7
|
keys: SignalKeyStoreWithTransaction;
|
|
24
8
|
};
|
|
25
|
-
getLIDForPN: (pn: string) => Promise<string | null>;
|
|
26
|
-
};
|
|
27
|
-
export declare function buildTcTokenFromJid({ authState, jid, baseContent, getLIDForPN }: TcTokenParams): Promise<BinaryNode[] | undefined>;
|
|
28
|
-
type StoreTcTokensParams = {
|
|
29
|
-
result: BinaryNode;
|
|
30
|
-
fallbackJid: string;
|
|
31
|
-
keys: SignalKeyStoreWithTransaction;
|
|
32
|
-
getLIDForPN: (pn: string) => Promise<string | null>;
|
|
33
|
-
onNewJidStored?: (jid: string) => void;
|
|
34
9
|
};
|
|
35
|
-
export declare function
|
|
10
|
+
export declare function buildTcTokenFromJid({ authState, jid, baseContent }: TcTokenParams): Promise<BinaryNode[] | undefined>;
|
|
36
11
|
export {};
|
|
37
12
|
//# sourceMappingURL=tc-token-utils.d.ts.map
|
|
@@ -1,123 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
// Same phone-number pattern as WABinary's isJidBot, applied against the user
|
|
3
|
-
// part so the check is invariant to @c.us ↔ @s.whatsapp.net normalization.
|
|
4
|
-
const BOT_PHONE_REGEX = /^1313555\d{4}$|^131655500\d{2}$/;
|
|
5
|
-
/**
|
|
6
|
-
* Mirrors WA Web's `Wid.isRegularUser()` (user ∧ ¬PSA ∧ ¬Bot). Used to gate tctoken
|
|
7
|
-
* storage against malformed notifications — WA Web filters server-side but we
|
|
8
|
-
* defend here for parity with `WAWebSetTcTokenChatAction.handleIncomingTcToken`.
|
|
9
|
-
* Works for both pre- and post-normalized JIDs (`@c.us` vs `@s.whatsapp.net`).
|
|
10
|
-
*/
|
|
11
|
-
function isRegularUser(jid) {
|
|
12
|
-
if (!jid)
|
|
13
|
-
return false;
|
|
14
|
-
const user = jid.split('@')[0] ?? '';
|
|
15
|
-
if (user === '0')
|
|
16
|
-
return false; // PSA
|
|
17
|
-
if (BOT_PHONE_REGEX.test(user))
|
|
18
|
-
return false; // Bot by phone pattern
|
|
19
|
-
if (isJidMetaAI(jid))
|
|
20
|
-
return false; // MetaAI (@bot server)
|
|
21
|
-
return !!(isPnUser(jid) || isLidUser(jid) || isHostedPnUser(jid) || isHostedLidUser(jid) || jid.endsWith('@c.us'));
|
|
22
|
-
}
|
|
23
|
-
const TC_TOKEN_BUCKET_DURATION = 604800; // 7 days
|
|
24
|
-
const TC_TOKEN_NUM_BUCKETS = 4; // ~28-day rolling window
|
|
25
|
-
/** Sentinel key under `tctoken` store holding a JSON array of tracked storage JIDs for cross-session pruning. */
|
|
26
|
-
export const TC_TOKEN_INDEX_KEY = '__index';
|
|
27
|
-
/** Read the persisted tctoken JID index and return its entries (never contains the sentinel key itself). */
|
|
28
|
-
export async function readTcTokenIndex(keys) {
|
|
29
|
-
const data = await keys.get('tctoken', [TC_TOKEN_INDEX_KEY]);
|
|
30
|
-
const entry = data[TC_TOKEN_INDEX_KEY];
|
|
31
|
-
if (!entry?.token?.length)
|
|
32
|
-
return [];
|
|
33
|
-
try {
|
|
34
|
-
const parsed = JSON.parse(Buffer.from(entry.token).toString());
|
|
35
|
-
if (!Array.isArray(parsed))
|
|
36
|
-
return [];
|
|
37
|
-
return parsed.filter((j) => typeof j === 'string' && j.length > 0 && j !== TC_TOKEN_INDEX_KEY);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/** Build a SignalDataSet fragment that writes the merged index (persisted ∪ added) under the sentinel key. */
|
|
44
|
-
export async function buildMergedTcTokenIndexWrite(keys, addedJids) {
|
|
45
|
-
const persisted = await readTcTokenIndex(keys);
|
|
46
|
-
const merged = new Set(persisted);
|
|
47
|
-
for (const jid of addedJids) {
|
|
48
|
-
if (jid && jid !== TC_TOKEN_INDEX_KEY)
|
|
49
|
-
merged.add(jid);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
[TC_TOKEN_INDEX_KEY]: { token: Buffer.from(JSON.stringify([...merged])) }
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
// WA Web has separate sender/receiver AB props for these but they're identical today
|
|
56
|
-
export function isTcTokenExpired(timestamp) {
|
|
57
|
-
if (timestamp === null || timestamp === undefined)
|
|
58
|
-
return true;
|
|
59
|
-
const ts = typeof timestamp === 'string' ? parseInt(timestamp) : timestamp;
|
|
60
|
-
if (isNaN(ts))
|
|
61
|
-
return true;
|
|
62
|
-
const now = Math.floor(Date.now() / 1000);
|
|
63
|
-
const currentBucket = Math.floor(now / TC_TOKEN_BUCKET_DURATION);
|
|
64
|
-
const cutoffBucket = currentBucket - (TC_TOKEN_NUM_BUCKETS - 1);
|
|
65
|
-
const cutoffTimestamp = cutoffBucket * TC_TOKEN_BUCKET_DURATION;
|
|
66
|
-
return ts < cutoffTimestamp;
|
|
67
|
-
}
|
|
68
|
-
export function shouldSendNewTcToken(senderTimestamp) {
|
|
69
|
-
if (senderTimestamp === undefined)
|
|
70
|
-
return true;
|
|
71
|
-
const now = Math.floor(Date.now() / 1000);
|
|
72
|
-
const currentBucket = Math.floor(now / TC_TOKEN_BUCKET_DURATION);
|
|
73
|
-
const senderBucket = Math.floor(senderTimestamp / TC_TOKEN_BUCKET_DURATION);
|
|
74
|
-
return currentBucket > senderBucket;
|
|
75
|
-
}
|
|
76
|
-
/** Resolve JID to LID for tctoken storage (WA Web stores under LID) */
|
|
77
|
-
export async function resolveTcTokenJid(jid, getLIDForPN) {
|
|
78
|
-
if (isLidUser(jid))
|
|
79
|
-
return jid;
|
|
80
|
-
const lid = await getLIDForPN(jid);
|
|
81
|
-
return lid ?? jid;
|
|
82
|
-
}
|
|
83
|
-
/** Resolve target JID for issuing privacy token based on AB prop 14303 */
|
|
84
|
-
export async function resolveIssuanceJid(jid, issueToLid, getLIDForPN, getPNForLID) {
|
|
85
|
-
if (issueToLid) {
|
|
86
|
-
if (isLidUser(jid))
|
|
87
|
-
return jid;
|
|
88
|
-
const lid = await getLIDForPN(jid);
|
|
89
|
-
return lid ?? jid;
|
|
90
|
-
}
|
|
91
|
-
if (!isLidUser(jid))
|
|
92
|
-
return jid;
|
|
93
|
-
if (getPNForLID) {
|
|
94
|
-
const pn = await getPNForLID(jid);
|
|
95
|
-
return pn ?? jid;
|
|
96
|
-
}
|
|
97
|
-
return jid;
|
|
98
|
-
}
|
|
99
|
-
export async function buildTcTokenFromJid({ authState, jid, baseContent = [], getLIDForPN }) {
|
|
1
|
+
export async function buildTcTokenFromJid({ authState, jid, baseContent = [] }) {
|
|
100
2
|
try {
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
const tcTokenBuffer = entry?.token;
|
|
105
|
-
const timestamp = entry?.timestamp;
|
|
106
|
-
if (!tcTokenBuffer?.length || timestamp === undefined || isTcTokenExpired(timestamp)) {
|
|
107
|
-
if (tcTokenBuffer) {
|
|
108
|
-
// Preserve senderTimestamp so shouldSendNewTcToken() keeps its dedupe state
|
|
109
|
-
// after we drop the unusable peer token. Only wipe the record entirely when
|
|
110
|
-
// there's nothing worth keeping.
|
|
111
|
-
const cleared = entry?.senderTimestamp !== undefined
|
|
112
|
-
? { token: Buffer.alloc(0), senderTimestamp: entry.senderTimestamp }
|
|
113
|
-
: null;
|
|
114
|
-
await authState.keys.set({ tctoken: { [storageJid]: cleared } });
|
|
115
|
-
}
|
|
3
|
+
const tcTokenData = await authState.keys.get('tctoken', [jid]);
|
|
4
|
+
const tcTokenBuffer = tcTokenData?.[jid]?.token;
|
|
5
|
+
if (!tcTokenBuffer)
|
|
116
6
|
return baseContent.length > 0 ? baseContent : undefined;
|
|
117
|
-
}
|
|
118
7
|
baseContent.push({
|
|
119
8
|
tag: 'tctoken',
|
|
120
|
-
attrs: {
|
|
9
|
+
attrs: {},
|
|
121
10
|
content: tcTokenBuffer
|
|
122
11
|
});
|
|
123
12
|
return baseContent;
|
|
@@ -126,39 +15,4 @@ export async function buildTcTokenFromJid({ authState, jid, baseContent = [], ge
|
|
|
126
15
|
return baseContent.length > 0 ? baseContent : undefined;
|
|
127
16
|
}
|
|
128
17
|
}
|
|
129
|
-
export async function storeTcTokensFromIqResult({ result, fallbackJid, keys, getLIDForPN, onNewJidStored }) {
|
|
130
|
-
const tokensNode = getBinaryNodeChild(result, 'tokens');
|
|
131
|
-
if (!tokensNode)
|
|
132
|
-
return;
|
|
133
|
-
const tokenNodes = getBinaryNodeChildren(tokensNode, 'token');
|
|
134
|
-
for (const tokenNode of tokenNodes) {
|
|
135
|
-
if (tokenNode.attrs.type !== 'trusted_contact' || !(tokenNode.content instanceof Uint8Array)) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
// In notifications tokenNode.attrs.jid is your own device JID, not the sender's
|
|
139
|
-
const rawJid = jidNormalizedUser(fallbackJid || tokenNode.attrs.jid);
|
|
140
|
-
if (!isRegularUser(rawJid))
|
|
141
|
-
continue;
|
|
142
|
-
const storageJid = await resolveTcTokenJid(rawJid, getLIDForPN);
|
|
143
|
-
const existingTcData = await keys.get('tctoken', [storageJid]);
|
|
144
|
-
const existingEntry = existingTcData[storageJid];
|
|
145
|
-
const existingTs = existingEntry?.timestamp ? Number(existingEntry.timestamp) : 0;
|
|
146
|
-
const incomingTs = tokenNode.attrs.t ? Number(tokenNode.attrs.t) : 0;
|
|
147
|
-
// timestamp-less tokens would be immediately expired
|
|
148
|
-
if (!incomingTs)
|
|
149
|
-
continue;
|
|
150
|
-
if (existingTs > 0 && existingTs > incomingTs)
|
|
151
|
-
continue;
|
|
152
|
-
await keys.set({
|
|
153
|
-
tctoken: {
|
|
154
|
-
[storageJid]: {
|
|
155
|
-
...existingEntry,
|
|
156
|
-
token: Buffer.from(tokenNode.content),
|
|
157
|
-
timestamp: tokenNode.attrs.t
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
onNewJidStored?.(storageJid);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
18
|
//# sourceMappingURL=tc-token-utils.js.map
|
|
@@ -2,7 +2,6 @@ import { proto } from '../../WAProto/index.js';
|
|
|
2
2
|
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types/index.js';
|
|
3
3
|
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
4
|
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
|
5
|
-
export declare const getPlatformType: (platform: string) => proto.DeviceProps.PlatformType;
|
|
6
5
|
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
|
7
6
|
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, "advSecretKey" | "signedIdentityKey" | "signalIdentities">) => {
|
|
8
7
|
creds: Partial<AuthenticationCreds>;
|
|
@@ -13,9 +13,7 @@ const getUserAgent = (config) => {
|
|
|
13
13
|
secondary: config.version[1],
|
|
14
14
|
tertiary: config.version[2]
|
|
15
15
|
},
|
|
16
|
-
platform:
|
|
17
|
-
? proto.ClientPayload.UserAgent.Platform.ANDROID
|
|
18
|
-
: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
16
|
+
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
19
17
|
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
20
18
|
osVersion: '0.1',
|
|
21
19
|
device: 'Desktop',
|
|
@@ -45,12 +43,7 @@ const getClientPayload = (config) => {
|
|
|
45
43
|
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
46
44
|
userAgent: getUserAgent(config)
|
|
47
45
|
};
|
|
48
|
-
|
|
49
|
-
payload.webInfo = getWebInfo(config);
|
|
50
|
-
}
|
|
51
|
-
if (config.pushName) {
|
|
52
|
-
payload.pushName = config.pushName;
|
|
53
|
-
}
|
|
46
|
+
payload.webInfo = getWebInfo(config);
|
|
54
47
|
return payload;
|
|
55
48
|
};
|
|
56
49
|
export const generateLoginNode = (userJid, config) => {
|
|
@@ -66,11 +59,8 @@ export const generateLoginNode = (userJid, config) => {
|
|
|
66
59
|
};
|
|
67
60
|
return proto.ClientPayload.fromObject(payload);
|
|
68
61
|
};
|
|
69
|
-
|
|
62
|
+
const getPlatformType = (platform) => {
|
|
70
63
|
const platformType = platform.toUpperCase();
|
|
71
|
-
if (platformType === 'ANDROID') {
|
|
72
|
-
return proto.DeviceProps.PlatformType.ANDROID_PHONE;
|
|
73
|
-
}
|
|
74
64
|
return (proto.DeviceProps.PlatformType[platformType] ||
|
|
75
65
|
proto.DeviceProps.PlatformType.CHROME);
|
|
76
66
|
};
|
package/lib/WABinary/decode.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BinaryNode, BinaryNodeCodingOptions } from './types.js';
|
|
2
|
-
export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer
|
|
2
|
+
export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer>;
|
|
3
3
|
export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
|
|
4
4
|
index: number;
|
|
5
5
|
}) => BinaryNode;
|
|
@@ -3,7 +3,7 @@ import { type BinaryNode } from './types.js';
|
|
|
3
3
|
export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
|
|
4
4
|
export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
|
|
5
5
|
export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
|
|
6
|
-
export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array<ArrayBufferLike> | Buffer
|
|
6
|
+
export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array<ArrayBufferLike> | (BinaryNode[] & Buffer) | (string & Buffer) | undefined;
|
|
7
7
|
export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => string | undefined;
|
|
8
8
|
export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined;
|
|
9
9
|
export declare const assertNodeErrorFree: (node: BinaryNode) => void;
|
|
@@ -12,4 +12,6 @@ export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: strin
|
|
|
12
12
|
};
|
|
13
13
|
export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
|
|
14
14
|
export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): string;
|
|
15
|
+
export declare const getBinaryNodeFilter: (node: BinaryNode[] | undefined) => boolean;
|
|
16
|
+
export declare const getAdditionalNode: (name: string) => BinaryNode[];
|
|
15
17
|
//# sourceMappingURL=generic-utils.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
2
|
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
import { unixTimestampSeconds } from '../Utils/generics.js';
|
|
3
4
|
import {} from './types.js';
|
|
4
5
|
// some extra useful utilities
|
|
5
6
|
const indexCache = new WeakMap();
|
|
@@ -110,4 +111,81 @@ export function binaryNodeToString(node, i = 0) {
|
|
|
110
111
|
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
111
112
|
return tag + content;
|
|
112
113
|
}
|
|
114
|
+
export const getBinaryNodeFilter = (node) => {
|
|
115
|
+
if (!Array.isArray(node))
|
|
116
|
+
return false;
|
|
117
|
+
return node.some((item) => ['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
|
|
118
|
+
['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
|
|
119
|
+
['hsm', 'biz'].includes(item?.tag) ||
|
|
120
|
+
(['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'));
|
|
121
|
+
};
|
|
122
|
+
const ORDER_RESPONSE_NAME = {
|
|
123
|
+
review_and_pay: 'order_details',
|
|
124
|
+
review_order: 'order_status',
|
|
125
|
+
payment_info: 'payment_info',
|
|
126
|
+
payment_status: 'payment_status',
|
|
127
|
+
payment_method: 'payment_method'
|
|
128
|
+
};
|
|
129
|
+
const FLOW_NAME = {
|
|
130
|
+
cta_catalog: 'cta_catalog',
|
|
131
|
+
mpm: 'mpm',
|
|
132
|
+
call_request: 'call_permission_request',
|
|
133
|
+
view_catalog: 'automated_greeting_message_view_catalog',
|
|
134
|
+
wa_pay_detail: 'wa_payment_transaction_details',
|
|
135
|
+
send_location: 'send_location'
|
|
136
|
+
};
|
|
137
|
+
export const getAdditionalNode = (name) => {
|
|
138
|
+
const lowerName = name?.toLowerCase();
|
|
139
|
+
const ts = unixTimestampSeconds(new Date()) - 77980457;
|
|
140
|
+
if (ORDER_RESPONSE_NAME[lowerName]) {
|
|
141
|
+
return [{
|
|
142
|
+
tag: 'biz',
|
|
143
|
+
attrs: { native_flow_name: ORDER_RESPONSE_NAME[lowerName] },
|
|
144
|
+
content: []
|
|
145
|
+
}];
|
|
146
|
+
}
|
|
147
|
+
if (FLOW_NAME[lowerName] || lowerName === 'interactive' || lowerName === 'buttons' || lowerName === 'list') {
|
|
148
|
+
return [{
|
|
149
|
+
tag: 'biz',
|
|
150
|
+
attrs: {
|
|
151
|
+
actual_actors: '2',
|
|
152
|
+
host_storage: '2',
|
|
153
|
+
privacy_mode_ts: `${ts}`
|
|
154
|
+
},
|
|
155
|
+
content: [{
|
|
156
|
+
tag: 'engagement',
|
|
157
|
+
attrs: {
|
|
158
|
+
customer_service_state: 'open',
|
|
159
|
+
conversation_state: 'open'
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
tag: 'interactive',
|
|
163
|
+
attrs: { type: 'native_flow', v: '1' },
|
|
164
|
+
content: [{
|
|
165
|
+
tag: 'native_flow',
|
|
166
|
+
attrs: {
|
|
167
|
+
v: '9',
|
|
168
|
+
name: FLOW_NAME[lowerName] ?? 'mixed'
|
|
169
|
+
},
|
|
170
|
+
content: []
|
|
171
|
+
}]
|
|
172
|
+
}]
|
|
173
|
+
}];
|
|
174
|
+
}
|
|
175
|
+
return [{
|
|
176
|
+
tag: 'biz',
|
|
177
|
+
attrs: {
|
|
178
|
+
actual_actors: '2',
|
|
179
|
+
host_storage: '2',
|
|
180
|
+
privacy_mode_ts: `${ts}`
|
|
181
|
+
},
|
|
182
|
+
content: [{
|
|
183
|
+
tag: 'engagement',
|
|
184
|
+
attrs: {
|
|
185
|
+
customer_service_state: 'open',
|
|
186
|
+
conversation_state: 'open'
|
|
187
|
+
}
|
|
188
|
+
}]
|
|
189
|
+
}];
|
|
190
|
+
};
|
|
113
191
|
//# sourceMappingURL=generic-utils.js.map
|
|
@@ -45,15 +45,4 @@ export declare const isHostedLidUser: (jid: string | undefined) => boolean | und
|
|
|
45
45
|
export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
|
|
46
46
|
export declare const jidNormalizedUser: (jid: string | undefined) => string;
|
|
47
47
|
export declare const transferDevice: (fromJid: string, toJid: string) => string;
|
|
48
|
-
/**
|
|
49
|
-
* Resuelve el JID objetivo de un comando siguiendo esta prioridad:
|
|
50
|
-
* 1. Mensaje citado (quoted)
|
|
51
|
-
* 2. Primera mención (@usuario)
|
|
52
|
-
* 3. Argumento numérico pasado como texto
|
|
53
|
-
* 4. Remitente del mensaje (fallback)
|
|
54
|
-
*
|
|
55
|
-
* Esto permite detectar y normalizar el JID sin tener que pasar
|
|
56
|
-
* manualmente el número del bot/usuario en cada comando.
|
|
57
|
-
*/
|
|
58
|
-
export declare const resolveJid: (m: any, arg?: string) => string;
|
|
59
48
|
//# sourceMappingURL=jid-utils.d.ts.map
|
|
@@ -93,37 +93,4 @@ export const transferDevice = (fromJid, toJid) => {
|
|
|
93
93
|
const { server, user } = jidDecode(toJid);
|
|
94
94
|
return jidEncode(user, server, deviceId);
|
|
95
95
|
};
|
|
96
|
-
/**
|
|
97
|
-
* Resuelve el JID objetivo de un comando siguiendo esta prioridad:
|
|
98
|
-
* 1. Mensaje citado (quoted)
|
|
99
|
-
* 2. Primera mención (@usuario)
|
|
100
|
-
* 3. Argumento numérico pasado como texto
|
|
101
|
-
* 4. Remitente del mensaje (fallback)
|
|
102
|
-
*
|
|
103
|
-
* Esto permite detectar y normalizar el JID sin tener que pasar
|
|
104
|
-
* manualmente el número del bot/usuario en cada comando.
|
|
105
|
-
*/
|
|
106
|
-
export const resolveJid = (m, arg = '') => {
|
|
107
|
-
// 1. Mensaje citado
|
|
108
|
-
const quoted = m?.quoted?.sender || m?.quoted?.key?.participant || m?.quoted?.participant;
|
|
109
|
-
if (quoted) {
|
|
110
|
-
return jidNormalizedUser(quoted);
|
|
111
|
-
}
|
|
112
|
-
// 2. Primera mención
|
|
113
|
-
const menciones = m?.message?.extendedTextMessage?.contextInfo?.mentionedJid ||
|
|
114
|
-
m?.message?.imageMessage?.contextInfo?.mentionedJid ||
|
|
115
|
-
[];
|
|
116
|
-
if (menciones.length > 0) {
|
|
117
|
-
return jidNormalizedUser(menciones[0]);
|
|
118
|
-
}
|
|
119
|
-
// 3. Argumento numérico
|
|
120
|
-
if (arg) {
|
|
121
|
-
const num = String(arg).replace(/[^0-9]/g, '');
|
|
122
|
-
if (num.length >= 7) {
|
|
123
|
-
return `${num}@s.whatsapp.net`;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// 4. Fallback al remitente
|
|
127
|
-
return jidNormalizedUser(m?.sender);
|
|
128
|
-
};
|
|
129
96
|
//# sourceMappingURL=jid-utils.js.map
|
package/lib/WAM/encode.d.ts
CHANGED
|
@@ -11,34 +11,11 @@ export class USyncContactProtocol {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
getUserElement(user) {
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
tag: 'contact',
|
|
17
|
-
attrs: {},
|
|
18
|
-
content: user.phone
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
if (user.username) {
|
|
22
|
-
return {
|
|
23
|
-
tag: 'contact',
|
|
24
|
-
attrs: {
|
|
25
|
-
username: user.username,
|
|
26
|
-
...(user.usernameKey ? { pin: user.usernameKey } : {}),
|
|
27
|
-
...(user.lid ? { lid: user.lid } : {})
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (user.type) {
|
|
32
|
-
return {
|
|
33
|
-
tag: 'contact',
|
|
34
|
-
attrs: {
|
|
35
|
-
type: user.type
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
14
|
+
//TODO: Implement type / username fields (not yet supported)
|
|
39
15
|
return {
|
|
40
16
|
tag: 'contact',
|
|
41
|
-
attrs: {}
|
|
17
|
+
attrs: {},
|
|
18
|
+
content: user.phone
|
|
42
19
|
};
|
|
43
20
|
}
|
|
44
21
|
parser(node) {
|