kage-baileys 3.0.6 → 3.2.3
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/Example/connection.cjs +4 -0
- package/README.MD +4726 -48
- package/WAProto/WAProto.proto +3395 -415
- package/WAProto/compat.cjs +12 -0
- package/WAProto/index.d.ts +47104 -19888
- package/WAProto/index.js +131979 -57361
- package/lib/Addon/http-error.js +43 -0
- package/lib/Addon/index.js +32 -0
- package/lib/Addon/keyed-db.js +250 -0
- package/lib/Addon/link-preview.js +82 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/connection.js +110 -0
- package/lib/Defaults/constants.js +156 -0
- package/lib/Defaults/history.js +46 -0
- package/lib/Defaults/index.js +230 -0
- package/lib/Defaults/media.js +104 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Defaults/prefix.js +44 -0
- package/lib/Extensions/business-advanced.js +382 -0
- package/lib/Extensions/business.js +159 -0
- package/lib/Extensions/chats-advanced.js +1106 -0
- package/lib/Extensions/chats.js +349 -0
- package/lib/Extensions/communities-advanced.js +430 -0
- package/lib/Extensions/community.js +94 -0
- package/lib/Extensions/groups-advanced.js +343 -0
- package/lib/Extensions/index.js +30 -0
- package/lib/Extensions/messages-recv-advanced.js +1690 -0
- package/lib/Extensions/messages-send-advanced.js +622 -0
- package/lib/Extensions/messages-send.js +1380 -0
- package/lib/Extensions/newsletter-advanced.js +228 -0
- package/lib/Extensions/newsletter.js +72 -0
- package/lib/Extensions/socket.js +389 -0
- package/lib/Modded/message_builder.js +2084 -4
- package/lib/Signal/Group/ciphertext-message.js +54 -0
- package/lib/Signal/Group/group-session-builder.js +124 -0
- package/lib/Signal/Group/group_cipher.js +216 -0
- package/lib/Signal/Group/index.js +124 -0
- package/lib/Signal/Group/keyhelper.js +108 -0
- package/lib/Signal/Group/sender-chain-key.js +83 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +157 -0
- package/lib/Signal/Group/sender-key-message.js +166 -0
- package/lib/Signal/Group/sender-key-name.js +130 -0
- package/lib/Signal/Group/sender-key-record.js +113 -0
- package/lib/Signal/Group/sender-key-state.js +208 -0
- package/lib/Signal/Group/sender-message-key.js +82 -0
- package/lib/Signal/libsignal.js +935 -0
- package/lib/Signal/lid-mapping.js +545 -1
- package/lib/Socket/Client/index.js +60 -0
- package/lib/Socket/Client/types.js +51 -0
- package/lib/Socket/Client/websocket.js +152 -0
- package/lib/Socket/business.js +831 -0
- package/lib/Socket/chats.js +2535 -49
- package/lib/Socket/communities.js +450 -1
- package/lib/Socket/community.js +1022 -0
- package/lib/Socket/dugong.js +1 -1
- package/lib/Socket/groups.js +747 -0
- package/lib/Socket/index.js +60 -2
- package/lib/Socket/messages-recv.js +3450 -5
- package/lib/Socket/messages-send.js +3123 -0
- package/lib/Socket/mex.js +126 -1
- package/lib/Socket/newsletter.js +465 -0
- package/lib/Socket/socket.js +2217 -1
- package/lib/Store/index.js +79 -0
- package/lib/Store/make-cache-manager-store.js +186 -0
- package/lib/Store/make-in-memory-store.js +878 -0
- package/lib/Store/make-ordered-dictionary.js +187 -0
- package/lib/Store/object-repository.js +78 -0
- package/lib/Types/Auth.js +25 -0
- package/lib/Types/Bussines.js +25 -1
- package/lib/Types/Call.js +25 -0
- package/lib/Types/Chat.js +39 -0
- package/lib/Types/Contact.js +25 -0
- package/lib/Types/Events.js +25 -0
- package/lib/Types/GroupMetadata.js +25 -0
- package/lib/Types/Label.js +76 -0
- package/lib/Types/LabelAssociation.js +40 -0
- package/lib/Types/Message.js +57 -0
- package/lib/Types/Mex.js +56 -1
- package/lib/Types/MexUpdates.js +46 -0
- package/lib/Types/Newsletter.js +56 -0
- package/lib/Types/Product.js +25 -0
- package/lib/Types/RichType.js +23 -0
- package/lib/Types/Signal.js +25 -0
- package/lib/Types/Socket.js +25 -0
- package/lib/Types/State.js +92 -0
- package/lib/Types/USync.js +25 -0
- package/lib/Types/index.js +133 -0
- package/lib/Utils/auth-utils.js +703 -0
- package/lib/Utils/automation-tools.js +51 -16
- package/lib/Utils/baileys-event-stream.js +146 -0
- package/lib/Utils/browser-utils.js +95 -0
- package/lib/Utils/business.js +525 -0
- package/lib/Utils/chat-utils.js +1861 -0
- package/lib/Utils/companion-reg-client-utils.js +55 -1
- package/lib/Utils/crypto.js +355 -0
- package/lib/Utils/decode-wa-message.js +709 -0
- package/lib/Utils/event-buffer.js +1323 -8
- package/lib/Utils/generics.js +945 -1
- package/lib/Utils/history.js +266 -0
- package/lib/Utils/identity-change-handler.js +62 -1
- package/lib/Utils/index.js +114 -0
- package/lib/Utils/link-preview.js +179 -0
- package/lib/Utils/logger.js +42 -0
- package/lib/Utils/lt-hash.js +73 -0
- package/lib/Utils/make-mutex.js +104 -0
- package/lib/Utils/message-inspector.js +110 -0
- package/lib/Utils/message-retry-manager.js +507 -2
- package/lib/Utils/messages-media.js +1931 -1
- package/lib/Utils/messages.js +3748 -0
- package/lib/Utils/noise-handler.js +423 -0
- package/lib/Utils/offline-node-processor.js +53 -1
- package/lib/Utils/pre-key-manager.js +255 -1
- package/lib/Utils/process-message.js +1592 -0
- package/lib/Utils/reporting-utils.js +272 -1
- package/lib/Utils/rich-message-utils.js +377 -0
- package/lib/Utils/rich-messages.js +1 -1
- package/lib/Utils/signal.js +437 -0
- package/lib/Utils/stanza-ack.js +51 -1
- package/lib/Utils/status-refresh.js +37 -0
- package/lib/Utils/status-tools.js +4 -2
- package/lib/Utils/sync-action-utils.js +63 -1
- package/lib/Utils/tc-token-utils.js +185 -1
- package/lib/Utils/terminal-banner.js +31 -0
- package/lib/Utils/use-multi-file-auth-state.js +271 -0
- package/lib/Utils/use-single-file-auth-state.js +108 -0
- package/lib/Utils/use-sqlite-auth-state.js +142 -0
- package/lib/Utils/validate-connection.js +497 -1
- package/lib/Utils/view-once-compat.js +13 -5
- package/lib/VoIP/audio-feeder.js +150 -0
- package/lib/VoIP/index.js +289 -0
- package/lib/VoIP/relay-transport.js +608 -0
- package/lib/VoIP/signaling.js +583 -0
- package/lib/VoIP/types.js +30 -0
- package/lib/VoIP/wasm-engine.js +1261 -2
- package/lib/VoIP/worker-bootstrap.js +1090 -2
- package/lib/WABinary/constants.js +2805 -0
- package/lib/WABinary/decode.js +649 -2
- package/lib/WABinary/encode.js +564 -2
- package/lib/WABinary/generic-utils.js +401 -0
- package/lib/WABinary/index.js +82 -0
- package/lib/WABinary/jid-utils.js +290 -0
- package/lib/WABinary/types.js +25 -0
- package/lib/WAM/BinaryInfo.js +50 -0
- package/lib/WAM/constants.js +45747 -0
- package/lib/WAM/encode.js +393 -0
- package/lib/WAM/index.js +78 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +135 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +110 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +142 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +85 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +69 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +107 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +38 -1
- package/lib/WAUSync/Protocols/index.js +83 -0
- package/lib/WAUSync/USyncQuery.js +241 -2
- package/lib/WAUSync/USyncUser.js +86 -0
- package/lib/WAUSync/index.js +78 -0
- package/lib/assets/wasm/loader.js +1875 -1
- package/lib/assets/wasm/worker-modules.js +11047 -1
- package/lib/index.d.ts +126 -0
- package/lib/index.js +53 -21
- package/lib/index.mjs +437 -0
- package/licenses/upstream-MIT.txt +22 -0
- package/maintenance/api-coverage.json +1642 -0
- package/maintenance/archivos-sha256.json +207 -0
- package/maintenance/consumer-validation.log +3 -0
- package/maintenance/dependency-audit.json +4 -4
- package/maintenance/extension-inventory.json +57 -0
- package/maintenance/protocol-update.json +1101 -0
- package/maintenance/protocol-wire-audit.json +4 -0
- package/maintenance/reference-socket-surface.json +209 -0
- package/maintenance/resumen-validacion.json +50 -0
- package/maintenance/validation.log +2725 -0
- package/maintenance/verification.json +566 -0
- package/package.json +107 -9
- package/scripts/check-imports.cjs +10 -0
- package/scripts/check-package.cjs +40 -0
- package/scripts/check-syntax.cjs +1 -1
- package/scripts/generate-protobuf.cjs +6 -1
- package/scripts/generate-public-types.cjs +9 -0
- package/scripts/kage-base64-fix.cjs +45 -0
- package/scripts/maintenance.cjs +10 -0
- package/test/advanced.test.cjs +24 -0
- package/test/base64-fix.test.cjs +49 -0
- package/test/maintenance.test.cjs +1 -1
- package/test/npm-publication.test.cjs +141 -0
- package/test/recepcion-reparada.test.cjs +98 -0
- package/test/resilience-binary.test.cjs +69 -0
- package/test/resilience-transport.test.cjs +34 -0
- package/test/types.test.ts +5 -0
- package/test/upgrade.test.cjs +104 -0
- package/tsconfig.json +20 -0
- package/WAProto/p.html +0 -1
- package/lib/KageExtra/Modded/message_builder.js +0 -2330
- package/lib/KageExtra/VoIP/audio-feeder.js +0 -136
- package/lib/KageExtra/VoIP/index.js +0 -282
- package/lib/KageExtra/VoIP/relay-transport.js +0 -559
- package/lib/KageExtra/VoIP/signaling.js +0 -603
- package/lib/KageExtra/VoIP/types.js +0 -17
- package/lib/KageExtra/VoIP/wasm-engine.js +0 -1214
- package/lib/KageExtra/VoIP/worker-bootstrap.js +0 -1042
- package/lib/KageExtra/assets/wasm/loader.js +0 -5
- package/lib/KageExtra/assets/wasm/whatsapp.wasm +0 -0
- package/lib/KageExtra/assets/wasm/worker-modules.js +0 -273
- package/lib/KageExtra/index.js +0 -3
- package/lib/KageExtra/package.json +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -24
- package/maintenance/revision-full-check.txt +0 -1097
- package/maintenance/revision-library-tests.tap +0 -1088
- package/maintenance/revision-protobuf.txt +0 -5
- package/maintenance/revision-syntax.txt +0 -5
- package/maintenance/schema-coverage.json +0 -23
- package/maintenance/schema-merge.json +0 -30
- package/maintenance/validation-node20.txt +0 -191
- package/maintenance/validation-node22.txt +0 -237
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpError = void 0;
|
|
4
|
+
class HttpError extends Error {
|
|
5
|
+
constructor(message, options = {}) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = this.constructor.name;
|
|
8
|
+
this.isHttpError = true;
|
|
9
|
+
this.isServer = true;
|
|
10
|
+
const statusCode = options?.statusCode || 400;
|
|
11
|
+
this.data = options?.data || null;
|
|
12
|
+
this.output = {
|
|
13
|
+
statusCode,
|
|
14
|
+
payload: {
|
|
15
|
+
statusCode,
|
|
16
|
+
error: HttpError.getStatusText(statusCode),
|
|
17
|
+
message,
|
|
18
|
+
},
|
|
19
|
+
headers: {},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
get statusCode() {
|
|
23
|
+
return this.output.statusCode;
|
|
24
|
+
}
|
|
25
|
+
static getStatusText(statusCode) {
|
|
26
|
+
const statuses = {
|
|
27
|
+
400: 'Bad Request',
|
|
28
|
+
401: 'Unauthorized',
|
|
29
|
+
403: 'Forbidden',
|
|
30
|
+
404: 'Not Found',
|
|
31
|
+
405: 'Method Not Allowed',
|
|
32
|
+
409: 'Conflict',
|
|
33
|
+
422: 'Unprocessable Entity',
|
|
34
|
+
429: 'Too Many Requests',
|
|
35
|
+
500: 'Internal Server Error',
|
|
36
|
+
501: 'Not Implemented',
|
|
37
|
+
502: 'Bad Gateway',
|
|
38
|
+
503: 'Service Unavailable',
|
|
39
|
+
};
|
|
40
|
+
return statuses[statusCode] || 'Internal Server Error';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.HttpError = HttpError;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { Mutex } = require('async-mutex');
|
|
3
|
+
const NodeCache = require('@cacheable/node-cache').default;
|
|
4
|
+
const PQueue = require('p-queue').default;
|
|
5
|
+
const {zipSync}=require('fflate');
|
|
6
|
+
const fs=require('node:fs/promises');
|
|
7
|
+
const os=require('node:os');
|
|
8
|
+
const path=require('node:path');
|
|
9
|
+
const {randomUUID}=require('node:crypto');
|
|
10
|
+
exports.createMutex=()=>new Mutex();
|
|
11
|
+
exports.createQueue=(concurrency=1)=>new PQueue({concurrency});
|
|
12
|
+
exports.createCache=(options={})=>{
|
|
13
|
+
const cache=new NodeCache({stdTTL:options.ttl||0,useClones:false,checkperiod:0,maxKeys:options.maxSize||-1});
|
|
14
|
+
cache.delete=key=>cache.del(key);cache.clear=()=>cache.flushAll();cache.close=()=>cache.flushAll();
|
|
15
|
+
return cache;
|
|
16
|
+
};
|
|
17
|
+
exports.createZip=async input=>{
|
|
18
|
+
const entries={};
|
|
19
|
+
if(Array.isArray(input))for(const item of input){const name=item.name||item.filename||item.path;if(!name)throw new TypeError('Cada archivo ZIP necesita un nombre');entries[name]=new Uint8Array(item.data||item.buffer||item.content);}
|
|
20
|
+
else for(const [name,value]of Object.entries(input))entries[name]=new Uint8Array(value);
|
|
21
|
+
return Buffer.from(zipSync(entries));
|
|
22
|
+
};
|
|
23
|
+
exports.getFile=async input=>{
|
|
24
|
+
const file=path.join(os.tmpdir(),'kage-'+randomUUID());
|
|
25
|
+
let data=input;
|
|
26
|
+
if(typeof input==='string'){if(/^https?:/.test(input)){const res=await fetch(input);if(!res.ok)throw new Error('Error HTTP '+res.status);data=Buffer.from(await res.arrayBuffer());}else data=await fs.readFile(input);}
|
|
27
|
+
await fs.writeFile(file,data,{mode:0o600});return file;
|
|
28
|
+
};
|
|
29
|
+
exports.detectMediaInfo=async input=>{const mm=await import('music-metadata');return typeof input==='string'?mm.parseFile(input):mm.parseBuffer(input);};
|
|
30
|
+
exports.encodeQR=(input,options)=>require('qrcode').toDataURL(input,options);
|
|
31
|
+
exports.getAudioWaveform=async input=>{const b=await fs.readFile(input);const media=require('../Utils/messages-media.js');return {waveform:await media.getAudioWaveform(b),seconds:await media.getAudioDuration(b)};};
|
|
32
|
+
Object.assign(exports,require('./http-error.js'),require('./keyed-db.js'),require('./link-preview.js'));
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyedDB = void 0;
|
|
4
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5
|
+
if (kind === "m")
|
|
6
|
+
throw new TypeError("Private method is not writable");
|
|
7
|
+
if (kind === "a" && !f)
|
|
8
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
10
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
14
|
+
if (kind === "a" && !f)
|
|
15
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
16
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
17
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
19
|
+
};
|
|
20
|
+
var _KeyedDB_instances, _KeyedDB_spec, _KeyedDB_idGetter, _KeyedDB_items, _KeyedDB_byId, _KeyedDB_key, _KeyedDB_id, _KeyedDB_lowerBound, _KeyedDB_sameKey, _KeyedDB_insertNew;
|
|
21
|
+
function snapshotProperties(value) {
|
|
22
|
+
if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return Object.getOwnPropertyDescriptors(value);
|
|
26
|
+
}
|
|
27
|
+
function restoreProperties(value, snapshot) {
|
|
28
|
+
if (!snapshot) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
32
|
+
if (!Object.prototype.hasOwnProperty.call(snapshot, key)) {
|
|
33
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
34
|
+
if (descriptor?.configurable) {
|
|
35
|
+
Reflect.deleteProperty(value, key);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
Object.defineProperties(value, snapshot);
|
|
40
|
+
}
|
|
41
|
+
class KeyedDB {
|
|
42
|
+
constructor(key, id) {
|
|
43
|
+
_KeyedDB_instances.add(this);
|
|
44
|
+
_KeyedDB_spec.set(this, void 0);
|
|
45
|
+
_KeyedDB_idGetter.set(this, void 0);
|
|
46
|
+
_KeyedDB_items.set(this, []);
|
|
47
|
+
_KeyedDB_byId.set(this, new Map());
|
|
48
|
+
if (typeof key?.key !== 'function' || typeof key?.compare !== 'function') {
|
|
49
|
+
throw new TypeError('key must provide key(value) and compare(a, b) functions');
|
|
50
|
+
}
|
|
51
|
+
if (id !== undefined && typeof id !== 'function') {
|
|
52
|
+
throw new TypeError('id must be a function');
|
|
53
|
+
}
|
|
54
|
+
__classPrivateFieldSet(this, _KeyedDB_spec, key, "f");
|
|
55
|
+
__classPrivateFieldSet(this, _KeyedDB_idGetter, id, "f");
|
|
56
|
+
}
|
|
57
|
+
clear() {
|
|
58
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").length = 0;
|
|
59
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").clear();
|
|
60
|
+
}
|
|
61
|
+
insertIfAbsent(...values) {
|
|
62
|
+
const inserted = [];
|
|
63
|
+
for (const value of values) {
|
|
64
|
+
if (!value) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const id = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
68
|
+
if (__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
72
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
73
|
+
if (index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 0, value);
|
|
77
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
78
|
+
inserted.push(value);
|
|
79
|
+
}
|
|
80
|
+
return inserted;
|
|
81
|
+
}
|
|
82
|
+
upsert(...values) {
|
|
83
|
+
const updated = [];
|
|
84
|
+
for (const value of values) {
|
|
85
|
+
if (!value) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const id = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
89
|
+
const previous = __classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id);
|
|
90
|
+
const exists = __classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id);
|
|
91
|
+
const key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
92
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
93
|
+
if (index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key) && __classPrivateFieldGet(this, _KeyedDB_items, "f")[index] !== previous) {
|
|
94
|
+
throw new Error(`duplicate key: ${String(key)}`);
|
|
95
|
+
}
|
|
96
|
+
if (!exists) {
|
|
97
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 0, value);
|
|
98
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const oldKey = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, previous);
|
|
102
|
+
const oldIndex = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, oldKey);
|
|
103
|
+
if (__classPrivateFieldGet(this, _KeyedDB_items, "f")[oldIndex] !== previous) {
|
|
104
|
+
throw new Error('KeyedDB index is inconsistent');
|
|
105
|
+
}
|
|
106
|
+
if (__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, oldKey, key)) {
|
|
107
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f")[oldIndex] = value;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(oldIndex, 1);
|
|
111
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key), 0, value);
|
|
112
|
+
}
|
|
113
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
114
|
+
updated.push(value);
|
|
115
|
+
}
|
|
116
|
+
return updated;
|
|
117
|
+
}
|
|
118
|
+
update(id, callback) {
|
|
119
|
+
if (typeof callback !== 'function') {
|
|
120
|
+
throw new TypeError('update must be a function');
|
|
121
|
+
}
|
|
122
|
+
if (!__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
const value = __classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id);
|
|
126
|
+
const oldId = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
127
|
+
const oldKey = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
128
|
+
const oldIndex = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, oldKey);
|
|
129
|
+
if (__classPrivateFieldGet(this, _KeyedDB_items, "f")[oldIndex] !== value) {
|
|
130
|
+
throw new Error('KeyedDB index is inconsistent');
|
|
131
|
+
}
|
|
132
|
+
const snapshot = snapshotProperties(value);
|
|
133
|
+
let removed = false;
|
|
134
|
+
try {
|
|
135
|
+
callback(value);
|
|
136
|
+
const nextId = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value);
|
|
137
|
+
const nextKey = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
138
|
+
if (!Object.is(nextId, oldId) && __classPrivateFieldGet(this, _KeyedDB_byId, "f").has(nextId)) {
|
|
139
|
+
throw new Error(`duplicate ID: ${String(nextId)}`);
|
|
140
|
+
}
|
|
141
|
+
if (__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, oldKey, nextKey)) {
|
|
142
|
+
if (!Object.is(nextId, oldId)) {
|
|
143
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").delete(oldId);
|
|
144
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(nextId, value);
|
|
145
|
+
}
|
|
146
|
+
return 1;
|
|
147
|
+
}
|
|
148
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(oldIndex, 1);
|
|
149
|
+
removed = true;
|
|
150
|
+
const nextIndex = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, nextKey);
|
|
151
|
+
if (nextIndex < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[nextIndex]), nextKey)) {
|
|
152
|
+
throw new Error(`duplicate key: ${String(nextKey)}`);
|
|
153
|
+
}
|
|
154
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(nextIndex, 0, value);
|
|
155
|
+
removed = false;
|
|
156
|
+
if (!Object.is(nextId, oldId)) {
|
|
157
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").delete(oldId);
|
|
158
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(nextId, value);
|
|
159
|
+
}
|
|
160
|
+
return 2;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
restoreProperties(value, snapshot);
|
|
164
|
+
if (removed) {
|
|
165
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(oldIndex, 0, value);
|
|
166
|
+
}
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
get(id) {
|
|
171
|
+
return __classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id);
|
|
172
|
+
}
|
|
173
|
+
deleteById(id, assertPresent = true) {
|
|
174
|
+
if (!__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
175
|
+
if (assertPresent) {
|
|
176
|
+
throw new Error('Value not found');
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
return this.delete(__classPrivateFieldGet(this, _KeyedDB_byId, "f").get(id));
|
|
181
|
+
}
|
|
182
|
+
delete(value) {
|
|
183
|
+
if (value == null) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value);
|
|
187
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
188
|
+
if (index >= __classPrivateFieldGet(this, _KeyedDB_items, "f").length || !__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key)) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const removed = __classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 1)[0];
|
|
192
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").delete(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, removed));
|
|
193
|
+
return removed;
|
|
194
|
+
}
|
|
195
|
+
filter(predicate = () => true) {
|
|
196
|
+
if (typeof predicate !== 'function') {
|
|
197
|
+
throw new TypeError('predicate must be a function');
|
|
198
|
+
}
|
|
199
|
+
const result = new KeyedDB(__classPrivateFieldGet(this, _KeyedDB_spec, "f"), __classPrivateFieldGet(this, _KeyedDB_idGetter, "f"));
|
|
200
|
+
for (let index = 0; index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length; index++) {
|
|
201
|
+
const value = __classPrivateFieldGet(this, _KeyedDB_items, "f")[index];
|
|
202
|
+
if (predicate(value, index)) {
|
|
203
|
+
__classPrivateFieldGet(result, _KeyedDB_items, "f").push(value);
|
|
204
|
+
__classPrivateFieldGet(result, _KeyedDB_byId, "f").set(__classPrivateFieldGet(result, _KeyedDB_instances, "m", _KeyedDB_id).call(result, value), value);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
all() {
|
|
210
|
+
return __classPrivateFieldGet(this, _KeyedDB_items, "f").slice();
|
|
211
|
+
}
|
|
212
|
+
toJSON() {
|
|
213
|
+
return __classPrivateFieldGet(this, _KeyedDB_items, "f");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.KeyedDB = KeyedDB;
|
|
217
|
+
_KeyedDB_spec = new WeakMap(), _KeyedDB_idGetter = new WeakMap(), _KeyedDB_items = new WeakMap(), _KeyedDB_byId = new WeakMap(), _KeyedDB_instances = new WeakSet(), _KeyedDB_key = function _KeyedDB_key(value) {
|
|
218
|
+
return __classPrivateFieldGet(this, _KeyedDB_spec, "f").key(value);
|
|
219
|
+
}, _KeyedDB_id = function _KeyedDB_id(value) {
|
|
220
|
+
const id = __classPrivateFieldGet(this, _KeyedDB_idGetter, "f") ? __classPrivateFieldGet(this, _KeyedDB_idGetter, "f").call(this, value) : String(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value));
|
|
221
|
+
if (id == null) {
|
|
222
|
+
throw new TypeError('ID must not be null or undefined');
|
|
223
|
+
}
|
|
224
|
+
return id;
|
|
225
|
+
}, _KeyedDB_lowerBound = function _KeyedDB_lowerBound(key) {
|
|
226
|
+
let low = 0;
|
|
227
|
+
let high = __classPrivateFieldGet(this, _KeyedDB_items, "f").length;
|
|
228
|
+
while (low < high) {
|
|
229
|
+
const mid = low + ((high - low) >>> 1);
|
|
230
|
+
if (__classPrivateFieldGet(this, _KeyedDB_spec, "f").compare(__classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[mid]), key) < 0) {
|
|
231
|
+
low = mid + 1;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
high = mid;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return low;
|
|
238
|
+
}, _KeyedDB_sameKey = function _KeyedDB_sameKey(a, b) {
|
|
239
|
+
return __classPrivateFieldGet(this, _KeyedDB_spec, "f").compare(a, b) === 0;
|
|
240
|
+
}, _KeyedDB_insertNew = function _KeyedDB_insertNew(value, id = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_id).call(this, value), key = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, value)) {
|
|
241
|
+
if (__classPrivateFieldGet(this, _KeyedDB_byId, "f").has(id)) {
|
|
242
|
+
throw new Error(`duplicate ID: ${String(id)}`);
|
|
243
|
+
}
|
|
244
|
+
const index = __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_lowerBound).call(this, key);
|
|
245
|
+
if (index < __classPrivateFieldGet(this, _KeyedDB_items, "f").length && __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_sameKey).call(this, __classPrivateFieldGet(this, _KeyedDB_instances, "m", _KeyedDB_key).call(this, __classPrivateFieldGet(this, _KeyedDB_items, "f")[index]), key)) {
|
|
246
|
+
throw new Error(`duplicate key: ${String(key)}`);
|
|
247
|
+
}
|
|
248
|
+
__classPrivateFieldGet(this, _KeyedDB_items, "f").splice(index, 0, value);
|
|
249
|
+
__classPrivateFieldGet(this, _KeyedDB_byId, "f").set(id, value);
|
|
250
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLinkPreview = getLinkPreview;
|
|
4
|
+
const index_js_1 = require("../Defaults/index.js");
|
|
5
|
+
const http_error_js_1 = require("./http-error.js");
|
|
6
|
+
const MAX = 262144;
|
|
7
|
+
const TAG = /<(meta|link)\b([^>]*)>|<title[^>]*>([^<]*)/gi;
|
|
8
|
+
const ATTR = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/g;
|
|
9
|
+
const ENT = /&(?:#(\d+)|#x([\da-f]+)|(amp|lt|gt|quot|apos));/gi;
|
|
10
|
+
const MAP = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'" };
|
|
11
|
+
const txt = s => s && s.replace(ENT, (_, d, h, n) => {
|
|
12
|
+
if (n)
|
|
13
|
+
return MAP[n.toLowerCase()];
|
|
14
|
+
const c = d ? +d : parseInt(h, 16);
|
|
15
|
+
return c <= 0x10FFFF ? String.fromCodePoint(c) : '';
|
|
16
|
+
}).replace(/\s+/g, ' ').trim();
|
|
17
|
+
async function readHead(res) {
|
|
18
|
+
let html = '';
|
|
19
|
+
for await (const chunk of res.body) {
|
|
20
|
+
html += index_js_1.TEXT_DECODER.decode(chunk, { stream: true });
|
|
21
|
+
const i = html.search(/<\/head>|<body/i);
|
|
22
|
+
if (i !== -1)
|
|
23
|
+
return html.slice(0, i);
|
|
24
|
+
if (html.length > MAX)
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return html;
|
|
28
|
+
}
|
|
29
|
+
async function getLinkPreview(url, timeout = 3000) {
|
|
30
|
+
const res = await fetch(url, {
|
|
31
|
+
signal: AbortSignal.timeout(timeout),
|
|
32
|
+
headers: {
|
|
33
|
+
Accept: 'text/html',
|
|
34
|
+
'Accept-Language': 'en-US,en;q=0.9',
|
|
35
|
+
'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)'
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (!res.ok)
|
|
39
|
+
throw new http_error_js_1.HttpError(`HTTP ${res.status} ${res.statusText}`);
|
|
40
|
+
if (!/html/i.test(res.headers.get('content-type') ?? '')) {
|
|
41
|
+
await res.body?.cancel();
|
|
42
|
+
return { url: res.url };
|
|
43
|
+
}
|
|
44
|
+
const base = res.url;
|
|
45
|
+
const abs = v => {
|
|
46
|
+
try {
|
|
47
|
+
return v && new URL(v, base).href;
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
};
|
|
51
|
+
const m = {};
|
|
52
|
+
let title, icon;
|
|
53
|
+
for (const [, kind, attrs, t] of (await readHead(res)).matchAll(TAG)) {
|
|
54
|
+
if (t !== undefined) {
|
|
55
|
+
title ?? (title = t);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const a = {};
|
|
59
|
+
for (const x of attrs.matchAll(ATTR))
|
|
60
|
+
a[x[1].toLowerCase()] = x[2] ?? x[3] ?? x[4];
|
|
61
|
+
if (kind.toLowerCase() === 'meta') {
|
|
62
|
+
const k = (a.property ?? a.name ?? a.itemprop)?.toLowerCase();
|
|
63
|
+
if (k && a.content)
|
|
64
|
+
m[k] ?? (m[k] = a.content);
|
|
65
|
+
}
|
|
66
|
+
else if (a.href) {
|
|
67
|
+
const r = a.rel?.toLowerCase() ?? '';
|
|
68
|
+
if (/(^|\s)icon(\s|$)/.test(r))
|
|
69
|
+
icon ?? (icon = a.href);
|
|
70
|
+
else if (r === 'image_src')
|
|
71
|
+
m.image_src ?? (m.image_src = a.href);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
url: base,
|
|
76
|
+
title: txt(m['og:title'] ?? m['twitter:title'] ?? title),
|
|
77
|
+
description: txt(m['og:description'] ?? m['twitter:description'] ?? m.description),
|
|
78
|
+
favicon: abs(icon ?? '/favicon.ico'),
|
|
79
|
+
image: abs(m['og:image'] ?? m['og:image:secure_url'] ?? m['twitter:image'] ?? m['twitter:image:src'] ?? m.image ?? m.image_src),
|
|
80
|
+
video: abs(m['og:video'] ?? m['og:video:secure_url'] ?? m['og:video:url'] ?? m['twitter:player:stream'])
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const { Browsers } = require("../Utils/browser-utils")
|
|
6
|
+
const { default: logger } = require("../Utils/logger")
|
|
7
|
+
const { makeLibSignalRepository } = require("../Signal/libsignal")
|
|
8
|
+
const { version } = require("./baileys-version.json")
|
|
9
|
+
|
|
10
|
+
const DEFAULT_CONNECTION_CONFIG = {
|
|
11
|
+
version,
|
|
12
|
+
browser: Browsers.windows('Chrome'),
|
|
13
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
14
|
+
connectTimeoutMs: 20000,
|
|
15
|
+
keepAliveIntervalMs: 30000,
|
|
16
|
+
logger: logger.child({ class: 'baileys' }),
|
|
17
|
+
printQRInTerminal: false,
|
|
18
|
+
emitOwnEvents: true,
|
|
19
|
+
defaultQueryTimeoutMs: 60000,
|
|
20
|
+
customUploadHosts: [],
|
|
21
|
+
retryRequestDelayMs: 250,
|
|
22
|
+
maxMsgRetryCount: 5,
|
|
23
|
+
fireInitQueries: true,
|
|
24
|
+
auth: undefined,
|
|
25
|
+
markOnlineOnConnect: true,
|
|
26
|
+
syncFullHistory: false,
|
|
27
|
+
patchMessageBeforeSending: msg => msg,
|
|
28
|
+
shouldSyncHistoryMessage: () => true,
|
|
29
|
+
shouldIgnoreJid: () => false,
|
|
30
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
31
|
+
transactionOpts: {
|
|
32
|
+
maxCommitRetries: 10,
|
|
33
|
+
delayBetweenTriesMs: 3000
|
|
34
|
+
},
|
|
35
|
+
generateHighQualityLinkPreview: false,
|
|
36
|
+
enableAutoSessionRecreation: true,
|
|
37
|
+
enableRecentMessageCache: true,
|
|
38
|
+
options: {},
|
|
39
|
+
appStateMacVerification: {
|
|
40
|
+
patch: false,
|
|
41
|
+
snapshot: false,
|
|
42
|
+
},
|
|
43
|
+
countryCode: 'US',
|
|
44
|
+
getMessage: async () => undefined,
|
|
45
|
+
cachedGroupMetadata: async () => undefined,
|
|
46
|
+
makeSignalRepository: makeLibSignalRepository
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
DEFAULT_CONNECTION_CONFIG
|
|
51
|
+
}
|
|
52
|
+
// Kage: compatibilidad de API.
|
|
53
|
+
const __kageModule1 = (() => {
|
|
54
|
+
const module = { exports: {} }; const exports = module.exports;
|
|
55
|
+
"use strict"
|
|
56
|
+
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
58
|
+
|
|
59
|
+
const { Browsers } = require("../Utils/browser-utils")
|
|
60
|
+
const { default: logger } = require("../Utils/logger")
|
|
61
|
+
const { makeLibSignalRepository } = require("../Signal/libsignal")
|
|
62
|
+
const { version } = require("./baileys-version.json")
|
|
63
|
+
|
|
64
|
+
const DEFAULT_CONNECTION_CONFIG = {
|
|
65
|
+
version,
|
|
66
|
+
browser: Browsers.windows('Chrome'),
|
|
67
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
68
|
+
connectTimeoutMs: 20000,
|
|
69
|
+
keepAliveIntervalMs: 30000,
|
|
70
|
+
logger: logger.child({ class: 'baileys' }),
|
|
71
|
+
printQRInTerminal: false,
|
|
72
|
+
emitOwnEvents: true,
|
|
73
|
+
defaultQueryTimeoutMs: 60000,
|
|
74
|
+
customUploadHosts: [],
|
|
75
|
+
retryRequestDelayMs: 250,
|
|
76
|
+
maxMsgRetryCount: 5,
|
|
77
|
+
fireInitQueries: true,
|
|
78
|
+
auth: undefined,
|
|
79
|
+
markOnlineOnConnect: true,
|
|
80
|
+
syncFullHistory: false,
|
|
81
|
+
patchMessageBeforeSending: msg => msg,
|
|
82
|
+
shouldSyncHistoryMessage: () => true,
|
|
83
|
+
shouldIgnoreJid: () => false,
|
|
84
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
85
|
+
transactionOpts: {
|
|
86
|
+
maxCommitRetries: 10,
|
|
87
|
+
delayBetweenTriesMs: 3000
|
|
88
|
+
},
|
|
89
|
+
generateHighQualityLinkPreview: false,
|
|
90
|
+
enableAutoSessionRecreation: true,
|
|
91
|
+
enableRecentMessageCache: true,
|
|
92
|
+
options: {},
|
|
93
|
+
appStateMacVerification: {
|
|
94
|
+
patch: false,
|
|
95
|
+
snapshot: false,
|
|
96
|
+
},
|
|
97
|
+
countryCode: 'US',
|
|
98
|
+
getMessage: async () => undefined,
|
|
99
|
+
cachedGroupMetadata: async () => undefined,
|
|
100
|
+
makeSignalRepository: makeLibSignalRepository
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module.exports = {
|
|
104
|
+
DEFAULT_CONNECTION_CONFIG
|
|
105
|
+
}
|
|
106
|
+
return module.exports;
|
|
107
|
+
})();
|
|
108
|
+
for (const key of Object.keys(__kageModule1)) {
|
|
109
|
+
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule1[key]});
|
|
110
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const UNAUTHORIZED_CODES = [401, 403, 419]
|
|
6
|
+
|
|
7
|
+
const PHONENUMBER_MCC = require("./phonenumber-mcc.json")
|
|
8
|
+
|
|
9
|
+
const DEFAULT_ORIGIN = 'https://web.whatsapp.com'
|
|
10
|
+
|
|
11
|
+
const PHONE_CONNECTION_CB = 'CB:Pong'
|
|
12
|
+
|
|
13
|
+
const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0])
|
|
14
|
+
|
|
15
|
+
const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1])
|
|
16
|
+
|
|
17
|
+
const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5])
|
|
18
|
+
|
|
19
|
+
const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6])
|
|
20
|
+
|
|
21
|
+
const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
|
|
22
|
+
|
|
23
|
+
const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
|
|
24
|
+
|
|
25
|
+
const DICT_VERSION = 3
|
|
26
|
+
|
|
27
|
+
const KEY_BUNDLE_TYPE = Buffer.from([5])
|
|
28
|
+
|
|
29
|
+
const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]) // last is "DICT_VERSION"
|
|
30
|
+
|
|
31
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
32
|
+
const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g
|
|
33
|
+
|
|
34
|
+
const MIN_PREKEY_COUNT = 5
|
|
35
|
+
|
|
36
|
+
const INITIAL_PREKEY_COUNT = 812
|
|
37
|
+
|
|
38
|
+
const UPLOAD_TIMEOUT = 30000 // 30 seconds
|
|
39
|
+
|
|
40
|
+
const MIN_UPLOAD_INTERVAL = 5000 // seconds minimum between uploads
|
|
41
|
+
|
|
42
|
+
const WA_CERT_DETAILS = {
|
|
43
|
+
SERIAL: 0
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const DEFAULT_CACHE_TTLS = {
|
|
47
|
+
SIGNAL_STORE: 5 * 60,
|
|
48
|
+
MSG_RETRY: 60 * 60,
|
|
49
|
+
CALL_OFFER: 5 * 60,
|
|
50
|
+
USER_DEVICES: 5 * 60, // 5 minutes
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
UNAUTHORIZED_CODES,
|
|
55
|
+
PHONENUMBER_MCC,
|
|
56
|
+
DEFAULT_ORIGIN,
|
|
57
|
+
PHONE_CONNECTION_CB,
|
|
58
|
+
WA_ADV_ACCOUNT_SIG_PREFIX,
|
|
59
|
+
WA_ADV_DEVICE_SIG_PREFIX,
|
|
60
|
+
WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX,
|
|
61
|
+
WA_ADV_HOSTED_DEVICE_SIG_PREFIX,
|
|
62
|
+
WA_DEFAULT_EPHEMERAL,
|
|
63
|
+
NOISE_MODE,
|
|
64
|
+
DICT_VERSION,
|
|
65
|
+
KEY_BUNDLE_TYPE,
|
|
66
|
+
NOISE_WA_HEADER,
|
|
67
|
+
URL_REGEX,
|
|
68
|
+
MIN_PREKEY_COUNT,
|
|
69
|
+
MIN_UPLOAD_INTERVAL,
|
|
70
|
+
INITIAL_PREKEY_COUNT,
|
|
71
|
+
UPLOAD_TIMEOUT,
|
|
72
|
+
WA_CERT_DETAILS,
|
|
73
|
+
DEFAULT_CACHE_TTLS
|
|
74
|
+
}
|
|
75
|
+
// Kage: compatibilidad de API.
|
|
76
|
+
const __kageModule2 = (() => {
|
|
77
|
+
const module = { exports: {} }; const exports = module.exports;
|
|
78
|
+
"use strict"
|
|
79
|
+
|
|
80
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
81
|
+
|
|
82
|
+
const UNAUTHORIZED_CODES = [401, 403, 419]
|
|
83
|
+
|
|
84
|
+
const PHONENUMBER_MCC = require("./phonenumber-mcc.json")
|
|
85
|
+
|
|
86
|
+
const DEFAULT_ORIGIN = 'https://web.whatsapp.com'
|
|
87
|
+
|
|
88
|
+
const PHONE_CONNECTION_CB = 'CB:Pong'
|
|
89
|
+
|
|
90
|
+
const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0])
|
|
91
|
+
|
|
92
|
+
const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1])
|
|
93
|
+
|
|
94
|
+
const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5])
|
|
95
|
+
|
|
96
|
+
const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6])
|
|
97
|
+
|
|
98
|
+
const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
|
|
99
|
+
|
|
100
|
+
const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
|
|
101
|
+
|
|
102
|
+
const DICT_VERSION = 3
|
|
103
|
+
|
|
104
|
+
const KEY_BUNDLE_TYPE = Buffer.from([5])
|
|
105
|
+
|
|
106
|
+
const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]) // last is "DICT_VERSION"
|
|
107
|
+
|
|
108
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
109
|
+
const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g
|
|
110
|
+
|
|
111
|
+
const MIN_PREKEY_COUNT = 5
|
|
112
|
+
|
|
113
|
+
const INITIAL_PREKEY_COUNT = 812
|
|
114
|
+
|
|
115
|
+
const UPLOAD_TIMEOUT = 30000 // 30 seconds
|
|
116
|
+
|
|
117
|
+
const MIN_UPLOAD_INTERVAL = 5000 // seconds minimum between uploads
|
|
118
|
+
|
|
119
|
+
const WA_CERT_DETAILS = {
|
|
120
|
+
SERIAL: 0
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const DEFAULT_CACHE_TTLS = {
|
|
124
|
+
SIGNAL_STORE: 5 * 60,
|
|
125
|
+
MSG_RETRY: 60 * 60,
|
|
126
|
+
CALL_OFFER: 5 * 60,
|
|
127
|
+
USER_DEVICES: 5 * 60, // 5 minutes
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = {
|
|
131
|
+
UNAUTHORIZED_CODES,
|
|
132
|
+
PHONENUMBER_MCC,
|
|
133
|
+
DEFAULT_ORIGIN,
|
|
134
|
+
PHONE_CONNECTION_CB,
|
|
135
|
+
WA_ADV_ACCOUNT_SIG_PREFIX,
|
|
136
|
+
WA_ADV_DEVICE_SIG_PREFIX,
|
|
137
|
+
WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX,
|
|
138
|
+
WA_ADV_HOSTED_DEVICE_SIG_PREFIX,
|
|
139
|
+
WA_DEFAULT_EPHEMERAL,
|
|
140
|
+
NOISE_MODE,
|
|
141
|
+
DICT_VERSION,
|
|
142
|
+
KEY_BUNDLE_TYPE,
|
|
143
|
+
NOISE_WA_HEADER,
|
|
144
|
+
URL_REGEX,
|
|
145
|
+
MIN_PREKEY_COUNT,
|
|
146
|
+
MIN_UPLOAD_INTERVAL,
|
|
147
|
+
INITIAL_PREKEY_COUNT,
|
|
148
|
+
UPLOAD_TIMEOUT,
|
|
149
|
+
WA_CERT_DETAILS,
|
|
150
|
+
DEFAULT_CACHE_TTLS
|
|
151
|
+
}
|
|
152
|
+
return module.exports;
|
|
153
|
+
})();
|
|
154
|
+
for (const key of Object.keys(__kageModule2)) {
|
|
155
|
+
if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule2[key]});
|
|
156
|
+
}
|