@prototypevip/baileys 0.0.1
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/LICENSE +23 -0
- package/WAProto/index.js +131118 -0
- package/engine-requirements.js +1 -0
- package/lib/Defaults/index.js +187 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.js +41 -0
- package/lib/Signal/Group/group_cipher.js +108 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.js +14 -0
- package/lib/Signal/Group/sender-chain-key.js +31 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +79 -0
- package/lib/Signal/Group/sender-key-name.js +49 -0
- package/lib/Signal/Group/sender-key-record.js +46 -0
- package/lib/Signal/Group/sender-key-state.js +104 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.js +532 -0
- package/lib/Signal/lid-mapping.js +312 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +64 -0
- package/lib/Socket/business.js +293 -0
- package/lib/Socket/chats.js +1124 -0
- package/lib/Socket/communities.js +528 -0
- package/lib/Socket/groups.js +465 -0
- package/lib/Socket/index.js +14 -0
- package/lib/Socket/messages-recv.js +2325 -0
- package/lib/Socket/messages-send.js +1746 -0
- package/lib/Socket/mex.js +55 -0
- package/lib/Socket/newsletter.js +317 -0
- package/lib/Socket/socket.js +1185 -0
- package/lib/Store/cache-factory.js +20 -0
- package/lib/Store/index.js +5 -0
- package/lib/Store/make-in-memory-store.js +523 -0
- package/lib/Store/make-ordered-dictionary.js +203 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Store/prototype-store.js +958 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.js +18 -0
- package/lib/Types/Mex.js +37 -0
- package/lib/Types/Newsletter.js +36 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.js +25 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +78 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.js +33 -0
- package/lib/Utils/auth-utils.js +303 -0
- package/lib/Utils/browser-utils.js +32 -0
- package/lib/Utils/business.js +245 -0
- package/lib/Utils/chat-utils.js +971 -0
- package/lib/Utils/companion-reg-client-utils.js +54 -0
- package/lib/Utils/constants.js +24 -0
- package/lib/Utils/crypto.js +133 -0
- package/lib/Utils/cstoken-utils.js +41 -0
- package/lib/Utils/decode-wa-message.js +406 -0
- package/lib/Utils/event-buffer.js +616 -0
- package/lib/Utils/generics.js +438 -0
- package/lib/Utils/history.js +147 -0
- package/lib/Utils/identity-change-handler.js +63 -0
- package/lib/Utils/index.js +29 -0
- package/lib/Utils/interactive-message-handler.js +478 -0
- package/lib/Utils/link-preview.js +91 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.js +6 -0
- package/lib/Utils/make-mutex.js +31 -0
- package/lib/Utils/message-retry-manager.js +291 -0
- package/lib/Utils/messages-media.js +881 -0
- package/lib/Utils/messages.js +1434 -0
- package/lib/Utils/noise-handler.js +229 -0
- package/lib/Utils/normalize-message-identity.js +73 -0
- package/lib/Utils/offline-node-processor.js +50 -0
- package/lib/Utils/pre-key-manager.js +119 -0
- package/lib/Utils/process-message.js +648 -0
- package/lib/Utils/reporting-utils.js +355 -0
- package/lib/Utils/rich-message-utils.js +264 -0
- package/lib/Utils/signal.js +233 -0
- package/lib/Utils/stanza-ack.js +33 -0
- package/lib/Utils/sticker-utils.js +221 -0
- package/lib/Utils/sync-action-utils.js +53 -0
- package/lib/Utils/tc-token-utils.js +182 -0
- package/lib/Utils/use-multi-file-auth-state.js +118 -0
- package/lib/Utils/use-prototype-auth-state.js +217 -0
- package/lib/Utils/use-single-file-auth-state.js +94 -0
- package/lib/Utils/validate-connection.js +235 -0
- package/lib/WABinary/constants.js +1468 -0
- package/lib/WABinary/decode.js +258 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.js +202 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.js +94 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.js +20669 -0
- package/lib/WAM/encode.js +151 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +59 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +59 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +21 -0
- package/lib/WAUSync/Protocols/index.js +4 -0
- package/lib/WAUSync/USyncQuery.js +133 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.js +12 -0
- package/package.json +78 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
export function makeOrderedDictionary(idGetter) {
|
|
2
|
+
const map = new Map();
|
|
3
|
+
|
|
4
|
+
let head = null;
|
|
5
|
+
let tail = null;
|
|
6
|
+
|
|
7
|
+
let cached = [];
|
|
8
|
+
let dirty = true;
|
|
9
|
+
|
|
10
|
+
const hooks = {
|
|
11
|
+
add: new Set(),
|
|
12
|
+
update: new Set(),
|
|
13
|
+
remove: new Set(),
|
|
14
|
+
batch: new Set(),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const emit = (type, payload) => {
|
|
18
|
+
const set = hooks[type];
|
|
19
|
+
if (!set) return;
|
|
20
|
+
for (const fn of set) {
|
|
21
|
+
try {
|
|
22
|
+
fn(payload);
|
|
23
|
+
} catch {}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const rebuild = () => {
|
|
28
|
+
const arr = [];
|
|
29
|
+
let curr = head;
|
|
30
|
+
while (curr) {
|
|
31
|
+
arr.push(curr.item);
|
|
32
|
+
curr = curr.next;
|
|
33
|
+
}
|
|
34
|
+
cached = arr;
|
|
35
|
+
dirty = false;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const get = (id) => map.get(id)?.item;
|
|
39
|
+
|
|
40
|
+
const upsert = (item, mode = "append") => {
|
|
41
|
+
const id = idGetter(item);
|
|
42
|
+
|
|
43
|
+
const existing = map.get(id);
|
|
44
|
+
|
|
45
|
+
if (existing) {
|
|
46
|
+
existing.item = item;
|
|
47
|
+
dirty = true;
|
|
48
|
+
emit("update", item);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const node = { id, item, prev: null, next: null };
|
|
53
|
+
|
|
54
|
+
map.set(id, node);
|
|
55
|
+
|
|
56
|
+
if (!head) {
|
|
57
|
+
head = tail = node;
|
|
58
|
+
} else if (mode === "append") {
|
|
59
|
+
tail.next = node;
|
|
60
|
+
node.prev = tail;
|
|
61
|
+
tail = node;
|
|
62
|
+
} else {
|
|
63
|
+
node.next = head;
|
|
64
|
+
head.prev = node;
|
|
65
|
+
head = node;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
dirty = true;
|
|
69
|
+
emit("add", item);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const update = (item) => {
|
|
73
|
+
const id = idGetter(item);
|
|
74
|
+
const node = map.get(id);
|
|
75
|
+
if (!node) return false;
|
|
76
|
+
|
|
77
|
+
node.item = item;
|
|
78
|
+
dirty = true;
|
|
79
|
+
|
|
80
|
+
emit("update", item);
|
|
81
|
+
return true;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const remove = (item) => {
|
|
85
|
+
const id = idGetter(item);
|
|
86
|
+
const node = map.get(id);
|
|
87
|
+
if (!node) return false;
|
|
88
|
+
|
|
89
|
+
if (node.prev) node.prev.next = node.next;
|
|
90
|
+
else head = node.next;
|
|
91
|
+
|
|
92
|
+
if (node.next) node.next.prev = node.prev;
|
|
93
|
+
else tail = node.prev;
|
|
94
|
+
|
|
95
|
+
map.delete(id);
|
|
96
|
+
|
|
97
|
+
node.prev = node.next = null;
|
|
98
|
+
|
|
99
|
+
dirty = true;
|
|
100
|
+
emit("remove", item);
|
|
101
|
+
|
|
102
|
+
return true;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const updateAssign = (id, patch) => {
|
|
106
|
+
const node = map.get(id);
|
|
107
|
+
if (!node) return false;
|
|
108
|
+
|
|
109
|
+
const data = typeof patch === "function" ? patch(node.item) : patch;
|
|
110
|
+
|
|
111
|
+
Object.assign(node.item, data);
|
|
112
|
+
|
|
113
|
+
const newId = idGetter(node.item);
|
|
114
|
+
|
|
115
|
+
if (newId !== id) {
|
|
116
|
+
map.delete(id);
|
|
117
|
+
map.set(newId, node);
|
|
118
|
+
node.id = newId;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
dirty = true;
|
|
122
|
+
emit("update", node.item);
|
|
123
|
+
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const clear = () => {
|
|
128
|
+
map.clear();
|
|
129
|
+
head = tail = null;
|
|
130
|
+
cached = [];
|
|
131
|
+
dirty = false;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const filter = (fn) => {
|
|
135
|
+
let curr = head;
|
|
136
|
+
|
|
137
|
+
while (curr) {
|
|
138
|
+
const next = curr.next;
|
|
139
|
+
|
|
140
|
+
if (!fn(curr.item)) {
|
|
141
|
+
map.delete(curr.id);
|
|
142
|
+
|
|
143
|
+
if (curr.prev) curr.prev.next = curr.next;
|
|
144
|
+
else head = curr.next;
|
|
145
|
+
|
|
146
|
+
if (curr.next) curr.next.prev = curr.prev;
|
|
147
|
+
else tail = curr.prev;
|
|
148
|
+
|
|
149
|
+
curr.prev = curr.next = null;
|
|
150
|
+
|
|
151
|
+
dirty = true;
|
|
152
|
+
emit("remove", curr.item);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
curr = next;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const snapshot = () => {
|
|
160
|
+
return {
|
|
161
|
+
data: dirty ? (rebuild(), cached) : cached,
|
|
162
|
+
size: map.size,
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const iterator = function* () {
|
|
167
|
+
let curr = head;
|
|
168
|
+
while (curr) {
|
|
169
|
+
yield curr.item;
|
|
170
|
+
curr = curr.next;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const on = (type, fn) => {
|
|
175
|
+
if (hooks[type]) hooks[type].add(fn);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const off = (type, fn) => {
|
|
179
|
+
hooks[type]?.delete(fn);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const array = () => {
|
|
183
|
+
if (dirty) rebuild();
|
|
184
|
+
return cached;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
get,
|
|
189
|
+
upsert,
|
|
190
|
+
update,
|
|
191
|
+
remove,
|
|
192
|
+
updateAssign,
|
|
193
|
+
clear,
|
|
194
|
+
filter,
|
|
195
|
+
|
|
196
|
+
array,
|
|
197
|
+
snapshot,
|
|
198
|
+
iterator,
|
|
199
|
+
|
|
200
|
+
on,
|
|
201
|
+
off,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class ObjectRepository {
|
|
2
|
+
constructor(entities = {}) {
|
|
3
|
+
this.entityMap = new Map(Object.entries(entities));
|
|
4
|
+
}
|
|
5
|
+
findById(id) {
|
|
6
|
+
return this.entityMap.get(id);
|
|
7
|
+
}
|
|
8
|
+
findAll() {
|
|
9
|
+
return Array.from(this.entityMap.values());
|
|
10
|
+
}
|
|
11
|
+
upsertById(id, entity) {
|
|
12
|
+
return this.entityMap.set(id, { ...entity });
|
|
13
|
+
}
|
|
14
|
+
deleteById(id) {
|
|
15
|
+
return this.entityMap.delete(id);
|
|
16
|
+
}
|
|
17
|
+
count() {
|
|
18
|
+
return this.entityMap.size;
|
|
19
|
+
}
|
|
20
|
+
toJSON() {
|
|
21
|
+
return this.findAll();
|
|
22
|
+
}
|
|
23
|
+
}
|