@vinzsocket/baileys 3.0.0 → 3.0.15
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/GenerateStatics.sh +2 -2
- package/WAProto/WAProto.proto +1339 -493
- package/WAProto/fix-imports.js +79 -14
- package/WAProto/index.d.ts +5274 -1945
- package/WAProto/index.js +97691 -1
- package/lib/Defaults/index.d.ts +25 -8
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +124 -109
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Signal/Group/ciphertext-message.js +11 -15
- package/lib/Signal/Group/group-session-builder.js +27 -32
- package/lib/Signal/Group/group_cipher.d.ts +1 -2
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -1
- package/lib/Signal/Group/group_cipher.js +75 -92
- package/lib/Signal/Group/group_cipher.js.map +1 -1
- package/lib/Signal/Group/index.js +12 -77
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
- package/lib/Signal/Group/keyhelper.js +16 -24
- package/lib/Signal/Group/keyhelper.js.map +1 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -1
- package/lib/Signal/Group/sender-chain-key.js +24 -34
- package/lib/Signal/Group/sender-chain-key.js.map +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -58
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -1
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-message.js +64 -65
- package/lib/Signal/Group/sender-key-message.js.map +1 -1
- package/lib/Signal/Group/sender-key-name.js +41 -44
- package/lib/Signal/Group/sender-key-record.d.ts +1 -1
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-record.js +36 -47
- package/lib/Signal/Group/sender-key-record.js.map +1 -1
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-state.js +76 -93
- package/lib/Signal/Group/sender-key-state.js.map +1 -1
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -1
- package/lib/Signal/Group/sender-message-key.js +25 -31
- package/lib/Signal/Group/sender-message-key.js.map +1 -1
- package/lib/Signal/libsignal.d.ts +4 -7
- package/lib/Signal/libsignal.d.ts.map +1 -1
- package/lib/Signal/libsignal.js +417 -401
- package/lib/Signal/libsignal.js.map +1 -1
- package/lib/Signal/lid-mapping.d.ts +16 -23
- package/lib/Signal/lid-mapping.d.ts.map +1 -1
- package/lib/Signal/lid-mapping.js +273 -108
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/Client/index.js +3 -25
- package/lib/Socket/Client/types.d.ts +2 -2
- package/lib/Socket/Client/types.d.ts.map +1 -1
- package/lib/Socket/Client/types.js +10 -14
- package/lib/Socket/Client/websocket.d.ts +1 -1
- package/lib/Socket/Client/websocket.d.ts.map +1 -1
- package/lib/Socket/Client/websocket.js +53 -54
- package/lib/Socket/Client/websocket.js.map +1 -1
- package/lib/Socket/business.d.ts +45 -16
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +374 -360
- package/lib/Socket/business.js.map +1 -1
- package/lib/Socket/chats.d.ts +34 -8
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +1162 -1038
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +56 -16
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/communities.js +418 -466
- package/lib/Socket/communities.js.map +1 -1
- package/lib/Socket/dugong.d.ts +205 -0
- package/lib/Socket/dugong.js +415 -0
- package/lib/Socket/groups.d.ts +32 -8
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +337 -390
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +57 -16
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +10 -18
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +49 -19
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +1738 -1391
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +47 -15
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +1144 -1242
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.js +38 -48
- package/lib/Socket/newsletter.d.ts +30 -7
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +175 -222
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +15 -6
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +932 -913
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Types/Auth.d.ts +12 -0
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Auth.js +2 -3
- package/lib/Types/Bussines.js +2 -3
- package/lib/Types/Call.d.ts +2 -1
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Call.js +2 -3
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js +8 -5
- package/lib/Types/Contact.d.ts +2 -0
- package/lib/Types/Contact.d.ts.map +1 -1
- package/lib/Types/Contact.js +2 -3
- package/lib/Types/Events.d.ts +66 -9
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/Events.js +2 -1
- package/lib/Types/GroupMetadata.d.ts +5 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.js +2 -3
- package/lib/Types/Label.js +23 -26
- package/lib/Types/LabelAssociation.js +5 -8
- package/lib/Types/Message.d.ts +31 -11
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +9 -18
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/{Newsletter.d.ts → Mex.d.ts} +11 -5
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +37 -0
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Product.js +2 -3
- package/lib/Types/Signal.d.ts +21 -16
- package/lib/Types/Signal.d.ts.map +1 -1
- package/lib/Types/Signal.js +2 -1
- package/lib/Types/Socket.d.ts +23 -17
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/Socket.js.map +1 -1
- package/lib/Types/State.d.ts +58 -0
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js +55 -15
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/USync.js +2 -1
- package/lib/Types/index.d.ts +1 -1
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +25 -163
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +7 -2
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +272 -458
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.js +208 -221
- package/lib/Utils/chat-utils.d.ts +35 -6
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js +828 -800
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +35 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +7 -11
- package/lib/Utils/crypto.d.ts.map +1 -1
- package/lib/Utils/crypto.js +88 -142
- package/lib/Utils/crypto.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +22 -2
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +293 -261
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +2 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +599 -558
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +6 -7
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +331 -362
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/history.d.ts +14 -10
- package/lib/Utils/history.d.ts.map +1 -1
- package/lib/Utils/history.js +129 -93
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +44 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +50 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +4 -3
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +23 -234
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.d.ts +1 -2
- package/lib/Utils/link-preview.d.ts.map +1 -1
- package/lib/Utils/link-preview.js +69 -83
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/logger.js +3 -9
- package/lib/Utils/lt-hash.d.ts +7 -12
- package/lib/Utils/lt-hash.d.ts.map +1 -1
- package/lib/Utils/lt-hash.js +3 -50
- package/lib/Utils/lt-hash.js.map +1 -1
- package/lib/Utils/make-mutex.d.ts +1 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -1
- package/lib/Utils/make-mutex.js +30 -40
- package/lib/Utils/make-mutex.js.map +1 -1
- package/lib/Utils/mention.d.ts +8 -21
- package/lib/Utils/mention.js +99 -96
- package/lib/Utils/message-retry-manager.d.ts +38 -5
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +259 -159
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +30 -10
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +734 -710
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +19 -4
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +817 -800
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/noise-handler.d.ts +4 -4
- package/lib/Utils/noise-handler.d.ts.map +1 -1
- package/lib/Utils/noise-handler.js +195 -165
- package/lib/Utils/noise-handler.js.map +1 -1
- package/lib/Utils/offline-node-processor.d.ts +17 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +26 -9
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +601 -422
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- package/lib/Utils/signal.d.ts +17 -4
- package/lib/Utils/signal.d.ts.map +1 -1
- package/lib/Utils/signal.js +180 -203
- package/lib/Utils/signal.js.map +1 -1
- package/lib/Utils/stanza-ack.d.ts +11 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +49 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +37 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +163 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +98 -98
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +191 -185
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/WABinary/constants.js +1297 -35
- package/lib/WABinary/decode.d.ts.map +1 -1
- package/lib/WABinary/decode.js +254 -229
- package/lib/WABinary/decode.js.map +1 -1
- package/lib/WABinary/encode.js +210 -209
- package/lib/WABinary/encode.js.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +1 -1
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +99 -105
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/index.js +6 -58
- package/lib/WABinary/jid-utils.d.ts +12 -1
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +83 -67
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +9 -13
- package/lib/WAM/constants.d.ts +1 -1
- package/lib/WAM/constants.d.ts.map +1 -1
- package/lib/WAM/constants.js +22853 -1
- package/lib/WAM/constants.js.map +1 -1
- package/lib/WAM/encode.js +135 -132
- package/lib/WAM/index.js +4 -36
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +50 -31
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +50 -58
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +25 -29
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +35 -37
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +4 -2
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +23 -27
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +47 -61
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +2 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +27 -23
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/index.js +6 -58
- package/lib/WAUSync/Protocols/index.js.map +1 -1
- package/lib/WAUSync/USyncQuery.d.ts +1 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
- package/lib/WAUSync/USyncQuery.js +94 -94
- package/lib/WAUSync/USyncQuery.js.map +1 -1
- package/lib/WAUSync/USyncUser.d.ts +4 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -1
- package/lib/WAUSync/USyncUser.js +30 -26
- package/lib/WAUSync/USyncUser.js.map +1 -1
- package/lib/WAUSync/index.js +4 -36
- package/lib/index.d.ts +0 -1
- package/lib/index.js +11 -112
- package/package.json +49 -22
- package/README.md +0 -1315
- package/lib/Signal/Group/queue-job.d.ts +0 -2
- package/lib/Signal/Group/queue-job.js +0 -59
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/index.js +0 -47
- package/lib/Store/make-cache-manager-store.d.ts +0 -17
- package/lib/Store/make-cache-manager-store.js +0 -104
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-in-memory-store.js +0 -490
- package/lib/Store/make-ordered-dictionary.d.ts +0 -14
- package/lib/Store/make-ordered-dictionary.js +0 -81
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Store/object-repository.js +0 -30
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js +0 -34
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Utils/baileys-event-stream.d.ts +0 -17
- package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
- package/lib/Utils/baileys-event-stream.js +0 -71
- package/lib/Utils/baileys-event-stream.js.map +0 -1
- package/lib/Utils/extended-messages.d.ts +0 -73
- package/lib/Utils/extended-messages.js +0 -283
- package/lib/Utils/lid-resolver.d.ts +0 -17
- package/lib/Utils/lid-resolver.js +0 -79
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
|
+
export class USyncStatusProtocol {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.name = 'status';
|
|
5
|
+
}
|
|
6
|
+
getQueryElement() {
|
|
7
|
+
return {
|
|
8
|
+
tag: 'status',
|
|
9
|
+
attrs: {}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
getUserElement() {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
parser(node) {
|
|
16
|
+
if (node.tag === 'status') {
|
|
17
|
+
assertNodeErrorFree(node);
|
|
18
|
+
let status = node?.content?.toString() ?? null;
|
|
19
|
+
const setAt = new Date(+(node?.attrs.t || 0) * 1000);
|
|
20
|
+
if (!status) {
|
|
21
|
+
if (node.attrs?.code && +node.attrs.code === 401) {
|
|
22
|
+
status = '';
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
status = null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (typeof status === 'string' && status.length === 0) {
|
|
29
|
+
status = null;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
status,
|
|
33
|
+
setAt
|
|
34
|
+
};
|
|
29
35
|
}
|
|
30
|
-
} else if (typeof status === 'string' && status.length === 0) {
|
|
31
|
-
status = null;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
status,
|
|
35
|
-
setAt
|
|
36
|
-
};
|
|
37
36
|
}
|
|
38
|
-
}
|
|
39
37
|
}
|
|
40
|
-
|
|
38
|
+
//# sourceMappingURL=USyncStatusProtocol.js.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { USyncQueryProtocol } from '../../Types/USync.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type BinaryNode } from '../../WABinary/index.js';
|
|
3
|
+
import { USyncUser } from '../USyncUser.js';
|
|
3
4
|
export declare class USyncUsernameProtocol implements USyncQueryProtocol {
|
|
4
5
|
name: string;
|
|
5
6
|
getQueryElement(): BinaryNode;
|
|
6
|
-
getUserElement(): null;
|
|
7
|
+
getUserElement(user: USyncUser): BinaryNode | null;
|
|
7
8
|
parser(node: BinaryNode): string | null;
|
|
8
9
|
}
|
|
10
|
+
//# sourceMappingURL=USyncUsernameProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"USyncUsernameProtocol.d.ts","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/USyncUsernameProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,qBAAa,qBAAsB,YAAW,kBAAkB;IAC/D,IAAI,SAAa;IAEjB,eAAe,IAAI,UAAU;IAO7B,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI;IAKlD,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI;CAQvC"}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(0, _index.assertNodeErrorFree)(node);
|
|
24
|
-
return typeof node.content === 'string' ? node.content : null;
|
|
1
|
+
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
|
+
import { USyncUser } from '../USyncUser.js';
|
|
3
|
+
export class USyncUsernameProtocol {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.name = 'username';
|
|
6
|
+
}
|
|
7
|
+
getQueryElement() {
|
|
8
|
+
return {
|
|
9
|
+
tag: 'username',
|
|
10
|
+
attrs: {}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
getUserElement(user) {
|
|
14
|
+
void user;
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
parser(node) {
|
|
18
|
+
if (node.tag === 'username') {
|
|
19
|
+
assertNodeErrorFree(node);
|
|
20
|
+
return typeof node.content === 'string' ? node.content : null;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
25
23
|
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
24
|
}
|
|
29
|
-
|
|
25
|
+
//# sourceMappingURL=USyncUsernameProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"USyncUsernameProtocol.js","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/USyncUsernameProtocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,OAAO,qBAAqB;IAAlC;QACC,SAAI,GAAG,UAAU,CAAA;IAsBlB,CAAC;IApBA,eAAe;QACd,OAAO;YACN,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,EAAE;SACT,CAAA;IACF,CAAC;IAED,cAAc,CAAC,IAAe;QAC7B,KAAK,IAAI,CAAA;QACT,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,IAAgB;QACtB,IAAI,IAAI,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;YAC7B,mBAAmB,CAAC,IAAI,CAAC,CAAA;YACzB,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;QAC9D,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -1,65 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary/index.js';
|
|
2
|
+
import { USyncUser } from '../USyncUser.js';
|
|
3
|
+
export class USyncBotProfileProtocol {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.name = 'bot';
|
|
6
|
+
}
|
|
7
|
+
getQueryElement() {
|
|
8
|
+
return {
|
|
9
|
+
tag: 'bot',
|
|
10
|
+
attrs: {},
|
|
11
|
+
content: [{ tag: 'profile', attrs: { v: '1' } }]
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getUserElement(user) {
|
|
15
|
+
return {
|
|
16
|
+
tag: 'bot',
|
|
17
|
+
attrs: {},
|
|
18
|
+
content: [{ tag: 'profile', attrs: { persona_id: user.personaId } }]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
parser(node) {
|
|
22
|
+
const botNode = getBinaryNodeChild(node, 'bot');
|
|
23
|
+
const profile = getBinaryNodeChild(botNode, 'profile');
|
|
24
|
+
const commandsNode = getBinaryNodeChild(profile, 'commands');
|
|
25
|
+
const promptsNode = getBinaryNodeChild(profile, 'prompts');
|
|
26
|
+
const commands = [];
|
|
27
|
+
const prompts = [];
|
|
28
|
+
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
|
|
29
|
+
commands.push({
|
|
30
|
+
name: getBinaryNodeChildString(command, 'name'),
|
|
31
|
+
description: getBinaryNodeChildString(command, 'description')
|
|
32
|
+
});
|
|
19
33
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
getUserElement(user) {
|
|
24
|
-
return {
|
|
25
|
-
tag: 'bot',
|
|
26
|
-
attrs: {},
|
|
27
|
-
content: [{
|
|
28
|
-
tag: 'profile',
|
|
29
|
-
attrs: {
|
|
30
|
-
persona_id: user.personaId
|
|
34
|
+
for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
|
|
35
|
+
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: (0, _index.getBinaryNodeChildString)(command, 'name'),
|
|
45
|
-
description: (0, _index.getBinaryNodeChildString)(command, 'description')
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
for (const prompt of (0, _index.getBinaryNodeChildren)(promptsNode, 'prompt')) {
|
|
49
|
-
prompts.push(`${(0, _index.getBinaryNodeChildString)(prompt, 'emoji')} ${(0, _index.getBinaryNodeChildString)(prompt, 'text')}`);
|
|
37
|
+
return {
|
|
38
|
+
isDefault: !!getBinaryNodeChild(profile, 'default'),
|
|
39
|
+
jid: node.attrs.jid,
|
|
40
|
+
name: getBinaryNodeChildString(profile, 'name'),
|
|
41
|
+
attributes: getBinaryNodeChildString(profile, 'attributes'),
|
|
42
|
+
description: getBinaryNodeChildString(profile, 'description'),
|
|
43
|
+
category: getBinaryNodeChildString(profile, 'category'),
|
|
44
|
+
personaId: profile.attrs['persona_id'],
|
|
45
|
+
commandsDescription: getBinaryNodeChildString(commandsNode, 'description'),
|
|
46
|
+
commands,
|
|
47
|
+
prompts
|
|
48
|
+
};
|
|
50
49
|
}
|
|
51
|
-
return {
|
|
52
|
-
isDefault: !!(0, _index.getBinaryNodeChild)(profile, 'default'),
|
|
53
|
-
jid: node.attrs.jid,
|
|
54
|
-
name: (0, _index.getBinaryNodeChildString)(profile, 'name'),
|
|
55
|
-
attributes: (0, _index.getBinaryNodeChildString)(profile, 'attributes'),
|
|
56
|
-
description: (0, _index.getBinaryNodeChildString)(profile, 'description'),
|
|
57
|
-
category: (0, _index.getBinaryNodeChildString)(profile, 'category'),
|
|
58
|
-
personaId: profile.attrs['persona_id'],
|
|
59
|
-
commandsDescription: (0, _index.getBinaryNodeChildString)(commandsNode, 'description'),
|
|
60
|
-
commands,
|
|
61
|
-
prompts
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
50
|
}
|
|
65
|
-
|
|
51
|
+
//# sourceMappingURL=UsyncBotProfileProtocol.js.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { USyncQueryProtocol } from '../../Types/USync.js';
|
|
2
2
|
import type { BinaryNode } from '../../WABinary/index.js';
|
|
3
|
+
import type { USyncUser } from '../USyncUser.js';
|
|
3
4
|
export declare class USyncLIDProtocol implements USyncQueryProtocol {
|
|
4
5
|
name: string;
|
|
5
6
|
getQueryElement(): BinaryNode;
|
|
6
|
-
getUserElement(): null;
|
|
7
|
+
getUserElement(user: USyncUser): BinaryNode | null;
|
|
7
8
|
parser(node: BinaryNode): string | null;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=UsyncLIDProtocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsyncLIDProtocol.d.ts","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/UsyncLIDProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"UsyncLIDProtocol.d.ts","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/UsyncLIDProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,qBAAa,gBAAiB,YAAW,kBAAkB;IAC1D,IAAI,SAAQ;IAEZ,eAAe,IAAI,UAAU;IAO7B,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI;IAWlD,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI;CAOvC"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
export class USyncLIDProtocol {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.name = 'lid';
|
|
4
|
+
}
|
|
5
|
+
getQueryElement() {
|
|
6
|
+
return {
|
|
7
|
+
tag: 'lid',
|
|
8
|
+
attrs: {}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
getUserElement(user) {
|
|
12
|
+
if (user.lid) {
|
|
13
|
+
return {
|
|
14
|
+
tag: 'lid',
|
|
15
|
+
attrs: { jid: user.lid }
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
parser(node) {
|
|
23
|
+
if (node.tag === 'lid') {
|
|
24
|
+
return node.attrs.val;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
21
27
|
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
28
|
}
|
|
25
|
-
|
|
29
|
+
//# sourceMappingURL=UsyncLIDProtocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsyncLIDProtocol.js","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/UsyncLIDProtocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UsyncLIDProtocol.js","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/UsyncLIDProtocol.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,gBAAgB;IAA7B;QACC,SAAI,GAAG,KAAK,CAAA;IA2Bb,CAAC;IAzBA,eAAe;QACd,OAAO;YACN,GAAG,EAAE,KAAK;YACV,KAAK,EAAE,EAAE;SACT,CAAA;IACF,CAAC;IAED,cAAc,CAAC,IAAe;QAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,OAAO;gBACN,GAAG,EAAE,KAAK;gBACV,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;aACxB,CAAA;QACF,CAAC;aAAM,CAAC;YACP,OAAO,IAAI,CAAA;QACZ,CAAC;IACF,CAAC;IAED,MAAM,CAAC,IAAgB;QACtB,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAI,CAAA;QACvB,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA"}
|
|
@@ -1,58 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (key in exports && exports[key] === _USyncDeviceProtocol[key]) return;
|
|
8
|
-
Object.defineProperty(exports, key, {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return _USyncDeviceProtocol[key];
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
var _USyncContactProtocol = require("./USyncContactProtocol.js");
|
|
16
|
-
Object.keys(_USyncContactProtocol).forEach(function (key) {
|
|
17
|
-
if (key === "default" || key === "__esModule") return;
|
|
18
|
-
if (key in exports && exports[key] === _USyncContactProtocol[key]) return;
|
|
19
|
-
Object.defineProperty(exports, key, {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _USyncContactProtocol[key];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
var _USyncStatusProtocol = require("./USyncStatusProtocol.js");
|
|
27
|
-
Object.keys(_USyncStatusProtocol).forEach(function (key) {
|
|
28
|
-
if (key === "default" || key === "__esModule") return;
|
|
29
|
-
if (key in exports && exports[key] === _USyncStatusProtocol[key]) return;
|
|
30
|
-
Object.defineProperty(exports, key, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _USyncStatusProtocol[key];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
var _USyncDisappearingModeProtocol = require("./USyncDisappearingModeProtocol.js");
|
|
38
|
-
Object.keys(_USyncDisappearingModeProtocol).forEach(function (key) {
|
|
39
|
-
if (key === "default" || key === "__esModule") return;
|
|
40
|
-
if (key in exports && exports[key] === _USyncDisappearingModeProtocol[key]) return;
|
|
41
|
-
Object.defineProperty(exports, key, {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return _USyncDisappearingModeProtocol[key];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
var _USyncUsernameProtocol = require("./USyncUsernameProtocol.js");
|
|
49
|
-
Object.keys(_USyncUsernameProtocol).forEach(function (key) {
|
|
50
|
-
if (key === "default" || key === "__esModule") return;
|
|
51
|
-
if (key in exports && exports[key] === _USyncUsernameProtocol[key]) return;
|
|
52
|
-
Object.defineProperty(exports, key, {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return _USyncUsernameProtocol[key];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
1
|
+
export * from './USyncDeviceProtocol.js';
|
|
2
|
+
export * from './USyncContactProtocol.js';
|
|
3
|
+
export * from './USyncStatusProtocol.js';
|
|
4
|
+
export * from './USyncDisappearingModeProtocol.js';
|
|
5
|
+
export * from './USyncUsernameProtocol.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/WAUSync/Protocols/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA"}
|
|
@@ -18,7 +18,7 @@ export declare class USyncQuery {
|
|
|
18
18
|
withMode(mode: string): this;
|
|
19
19
|
withContext(context: string): this;
|
|
20
20
|
withUser(user: USyncUser): this;
|
|
21
|
-
parseUSyncQueryResult(result: BinaryNode): USyncQueryResult | undefined;
|
|
21
|
+
parseUSyncQueryResult(result: BinaryNode | undefined): USyncQueryResult | undefined;
|
|
22
22
|
withDeviceProtocol(): this;
|
|
23
23
|
withContactProtocol(): this;
|
|
24
24
|
withStatusProtocol(): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"USyncQuery.d.ts","sourceRoot":"","sources":["../../src/WAUSync/USyncQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"USyncQuery.d.ts","sourceRoot":"","sources":["../../src/WAUSync/USyncQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,aAAa,CAAA;AAUjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9E,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,oBAAoB,EAAE,CAAA;IAC5B,QAAQ,EAAE,oBAAoB,EAAE,CAAA;CAChC,CAAA;AAED,qBAAa,UAAU;IACtB,SAAS,EAAE,kBAAkB,EAAE,CAAA;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;;IASZ,QAAQ,CAAC,IAAI,EAAE,MAAM;IAKrB,WAAW,CAAC,OAAO,EAAE,MAAM;IAK3B,QAAQ,CAAC,IAAI,EAAE,SAAS;IAKxB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS;IAwDnF,kBAAkB;IAKlB,mBAAmB;IAKnB,kBAAkB;IAKlB,4BAA4B;IAK5B,sBAAsB;IAKtB,eAAe;IAKf,oBAAoB;CAIpB"}
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
this.protocols = [];
|
|
14
|
-
this.users = [];
|
|
15
|
-
this.context = 'interactive';
|
|
16
|
-
this.mode = 'query';
|
|
17
|
-
}
|
|
18
|
-
withMode(mode) {
|
|
19
|
-
this.mode = mode;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
withContext(context) {
|
|
23
|
-
this.context = context;
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
withUser(user) {
|
|
27
|
-
this.users.push(user);
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
parseUSyncQueryResult(result) {
|
|
31
|
-
if (result.attrs.type !== 'result') {
|
|
32
|
-
return;
|
|
1
|
+
import { getBinaryNodeChild } from '../WABinary/index.js';
|
|
2
|
+
import { USyncBotProfileProtocol } from './Protocols/UsyncBotProfileProtocol.js';
|
|
3
|
+
import { USyncLIDProtocol } from './Protocols/UsyncLIDProtocol.js';
|
|
4
|
+
import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol, USyncUsernameProtocol } from './Protocols/index.js';
|
|
5
|
+
import { USyncUser } from './USyncUser.js';
|
|
6
|
+
export class USyncQuery {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.protocols = [];
|
|
9
|
+
this.users = [];
|
|
10
|
+
this.context = 'interactive';
|
|
11
|
+
this.mode = 'query';
|
|
33
12
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}).filter(([, b]) => b !== null)) : {};
|
|
59
|
-
return {
|
|
60
|
-
...data,
|
|
61
|
-
id
|
|
13
|
+
withMode(mode) {
|
|
14
|
+
this.mode = mode;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
withContext(context) {
|
|
18
|
+
this.context = context;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
withUser(user) {
|
|
22
|
+
this.users.push(user);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
parseUSyncQueryResult(result) {
|
|
26
|
+
if (result?.attrs.type !== 'result') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
|
|
30
|
+
return [protocol.name, protocol.parser];
|
|
31
|
+
}));
|
|
32
|
+
const queryResult = {
|
|
33
|
+
// TODO: implement errors etc.
|
|
34
|
+
list: [],
|
|
35
|
+
sideList: []
|
|
62
36
|
};
|
|
63
|
-
|
|
37
|
+
const usyncNode = getBinaryNodeChild(result, 'usync');
|
|
38
|
+
//TODO: implement error backoff, refresh etc.
|
|
39
|
+
//TODO: see if there are any errors in the result node
|
|
40
|
+
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
|
41
|
+
const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined;
|
|
42
|
+
if (listNode?.content && Array.isArray(listNode.content)) {
|
|
43
|
+
queryResult.list = listNode.content.reduce((acc, node) => {
|
|
44
|
+
const id = node?.attrs.jid;
|
|
45
|
+
if (id) {
|
|
46
|
+
const data = Array.isArray(node?.content)
|
|
47
|
+
? Object.fromEntries(node.content
|
|
48
|
+
.map(content => {
|
|
49
|
+
const protocol = content.tag;
|
|
50
|
+
const parser = protocolMap[protocol];
|
|
51
|
+
if (parser) {
|
|
52
|
+
return [protocol, parser(content)];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return [protocol, null];
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.filter(([, b]) => b !== null))
|
|
59
|
+
: {};
|
|
60
|
+
acc.push({ ...data, id });
|
|
61
|
+
}
|
|
62
|
+
return acc;
|
|
63
|
+
}, []);
|
|
64
|
+
}
|
|
65
|
+
//TODO: implement side list
|
|
66
|
+
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
67
|
+
return queryResult;
|
|
68
|
+
}
|
|
69
|
+
withDeviceProtocol() {
|
|
70
|
+
this.protocols.push(new USyncDeviceProtocol());
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
withContactProtocol() {
|
|
74
|
+
this.protocols.push(new USyncContactProtocol());
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
withStatusProtocol() {
|
|
78
|
+
this.protocols.push(new USyncStatusProtocol());
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
withDisappearingModeProtocol() {
|
|
82
|
+
this.protocols.push(new USyncDisappearingModeProtocol());
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
withBotProfileProtocol() {
|
|
86
|
+
this.protocols.push(new USyncBotProfileProtocol());
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
withLIDProtocol() {
|
|
90
|
+
this.protocols.push(new USyncLIDProtocol());
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
withUsernameProtocol() {
|
|
94
|
+
this.protocols.push(new USyncUsernameProtocol());
|
|
95
|
+
return this;
|
|
64
96
|
}
|
|
65
|
-
//TODO: implement side list
|
|
66
|
-
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
67
|
-
return queryResult;
|
|
68
|
-
}
|
|
69
|
-
withDeviceProtocol() {
|
|
70
|
-
this.protocols.push(new _index2.USyncDeviceProtocol());
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
withContactProtocol() {
|
|
74
|
-
this.protocols.push(new _index2.USyncContactProtocol());
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
withStatusProtocol() {
|
|
78
|
-
this.protocols.push(new _index2.USyncStatusProtocol());
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
withDisappearingModeProtocol() {
|
|
82
|
-
this.protocols.push(new _index2.USyncDisappearingModeProtocol());
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
withBotProfileProtocol() {
|
|
86
|
-
this.protocols.push(new _UsyncBotProfileProtocol.USyncBotProfileProtocol());
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
withLIDProtocol() {
|
|
90
|
-
this.protocols.push(new _UsyncLIDProtocol.USyncLIDProtocol());
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
withUsernameProtocol() {
|
|
94
|
-
this.protocols.push(new _USyncUsernameProtocol.USyncUsernameProtocol());
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
//# sourceMappingURL=USyncQuery.js.map
|