@arcaelas/whatsapp 1.0.9 → 1.0.10

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/build/index.d.ts CHANGED
@@ -9,21 +9,12 @@ import Store, { Engine } from './static/Store';
9
9
  /**
10
10
  * @description Estructura de configuración para iniciar sesión con WhatsApp.
11
11
  */
12
- interface IWhatsAppBase {
12
+ interface IWhatsApp {
13
13
  phone: string;
14
14
  store: Engine;
15
+ onCode(code: string): void | Promise<void>;
15
16
  browser?: Baileys.WABrowserDescription | undefined;
16
17
  }
17
- /**
18
- * @description Configuración condicional según tipo de login.
19
- */
20
- type IWhatsApp<T extends 'qr' | 'code'> = IWhatsAppBase & {
21
- loginType: T;
22
- } & (T extends 'qr' ? {
23
- qr: Noop<[qr: string]>;
24
- } : {
25
- code: Noop<[code: string]>;
26
- });
27
18
  /**
28
19
  * @description
29
20
  * Event map for WhatsApp.
@@ -52,7 +43,7 @@ interface EventMap {
52
43
  * qr: (code) => console.log(code),
53
44
  * });
54
45
  */
55
- declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
46
+ declare class WhatsApp extends EventEmitter<EventMap> {
56
47
  /**
57
48
  * @description
58
49
  * Store for WhatsApp Web.
@@ -62,7 +53,7 @@ declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
62
53
  * @description
63
54
  * Options for WhatsApp Web.
64
55
  */
65
- protected options: IWhatsApp<T>;
56
+ protected options: IWhatsApp;
66
57
  /**
67
58
  * @description
68
59
  * Socket for WhatsApp Web.
@@ -73,7 +64,7 @@ declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
73
64
  * Mutex, used to prevent concurrent access to the socket.
74
65
  */
75
66
  protected readonly mutex: Mutex;
76
- constructor(options: IWhatsApp<T>);
67
+ constructor(options: IWhatsApp);
77
68
  /**
78
69
  * @description
79
70
  * Execute a function with the socket and store, means that the function will be executed only when the socket is ready.
@@ -182,7 +173,7 @@ declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
182
173
  }>;
183
174
  getBotListV2: () => Promise<import("baileys/lib/Types").BotListInfo[]>;
184
175
  processingMutex: {
185
- mutex<T_1>(code: () => Promise<T_1> | T_1): Promise<T_1>;
176
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
186
177
  };
187
178
  upsertMessage: (msg: import("baileys/lib/Types").WAProto.IWebMessageInfo, type: import("baileys/lib/Types").MessageUpsertType) => Promise<void>;
188
179
  appPatch: (patchCreate: import("baileys/lib/Types").WAPatchCreate) => Promise<void>;
@@ -230,7 +221,7 @@ declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
230
221
  ev: import("baileys/lib/Types").BaileysEventEmitter & {
231
222
  process(handler: (events: Partial<import("baileys/lib/Types").BaileysEventMap>) => void | Promise<void>): (() => void);
232
223
  buffer(): void;
233
- createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): ((...args: A) => Promise<T_1>);
224
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
234
225
  flush(force?: boolean): boolean;
235
226
  isBuffering(): boolean;
236
227
  };
@@ -242,7 +233,7 @@ declare class WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {
242
233
  user: import("baileys/lib/Types").Contact | undefined;
243
234
  generateMessageTag: () => string;
244
235
  query: (node: import("baileys").BinaryNode, timeoutMs?: number) => Promise<any>;
245
- waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
236
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
246
237
  waitForSocketOpen: () => Promise<void>;
247
238
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
248
239
  sendNode: (frame: import("baileys").BinaryNode) => Promise<void>;
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var P=Object.create;var g=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var b=(o,i)=>{for(var e in i)g(o,e,{get:i[e],enumerable:!0})},u=(o,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of v(i))!R.call(o,a)&&a!==e&&g(o,a,{get:()=>i[a],enumerable:!(r=q(i,a))||r.enumerable});return o},m=(o,i,e)=>(u(o,i,"default"),e&&u(e,i,"default")),n=(o,i,e)=>(e=o!=null?P(E(o)):{},u(i||!o||!o.__esModule?g(e,"default",{value:o,enumerable:!0}):e,o)),I=o=>u(g({},"__esModule",{value:!0}),o);var h={};b(h,{Chat:()=>W.default,Message:()=>C.default,Store:()=>T.default,default:()=>D,useCache:()=>A.default});module.exports=I(h);var l=require("@arcaelas/utils"),k=require("async-mutex"),y=n(require("baileys")),B=n(require("node:events")),f=n(require("./model/chat")),w=n(require("./model/message")),S=n(require("./static/Store")),x=n(require("./static/useCache"));m(h,require("./static/Store"),module.exports);var T=n(require("./static/Store")),A=n(require("./static/useCache"));m(h,require("./model/chat"),module.exports);var W=n(require("./model/chat"));m(h,require("./model/message"),module.exports);var C=n(require("./model/message"));class N extends B.default{constructor(e){super({captureRejections:!0});this.mutex=new k.Mutex;this.on("error",r=>{this.listenerCount("error")===1&&console.error(r)}),this.options={...e,phone:e.phone.replace(/\D/g,"")},this.store=new S.default(this.options.store),this.connect()}async tick(e){return this.mutex.acquire().then(()=>e(this.socket,this.store))}process(e){return this.on("process",r=>{e(r,this.socket,this.store)})}async documents(){return await this.tick(async(e,r)=>{const a={};for await(const d of r.document.values())a[d.key]=d.value;return a})}async chats(){return await this.tick(async(e,r)=>{const a=[];for await(const d of r.chat.values())a.push(new f.default(this,d));return a})}async messages(){return await this.tick(async(e,r)=>{const a=[];for await(const d of r.message.values())a.push(new w.default(this,d));return a})}async connect(){const e=(0,l.promify)(),{state:r,save:a}=await(0,x.default)(this.store),{version:d}=await y.fetchLatestBaileysVersion();if(this.socket=y.makeWASocket({version:d,syncFullHistory:!0,...this.options.browser?{browser:this.options.browser}:{},auth:{creds:r.creds,keys:y.makeCacheableSignalKeyStore(r.keys)},getMessage:async s=>{const t=await this.store.message.get(s.id);return t?t.message:void 0}}),this.socket.ev.process(async s=>{if(s["creds.update"]&&await a(),s["connection.update"]){const{connection:t,lastDisconnect:c}=s["connection.update"];t==="open"?e.resolve(this.socket):t==="close"&&c?.error?.output?.statusCode!==y.DisconnectReason.loggedOut&&e.resolve(await this.connect())}await Promise.allSettled([...s["messaging-history.set"]?.chats||[],...s["chats.upsert"]||[]].map(async t=>{await this.store.chat.set(t),this.emit("chat:created",new f.default(this,t))})),await Promise.allSettled([...s["messaging-history.set"]?.messages||[],...s["messages.upsert"]?.messages||[]].map(async t=>{await this.store.message.set(t),this.emit("message:created",new w.default(this,t))})),await Promise.allSettled((s["chats.update"]||[]).map(async t=>{const c=await this.store.chat.get(t.id);if(c!==null){const p=(0,l.merge)(c,t);await this.store.chat.set(p),this.emit("chat:updated",new f.default(this,p))}})),await Promise.allSettled((s["messages.update"]||[]).map(async t=>{const c=await this.store.message.get(t.key.id);if(c!==null){const p=(0,l.merge)(c,t);await this.store.message.set(p),this.emit("message:updated",new w.default(this,p))}}));for(const{id:t}of s["messages.delete"]?.keys||[])await this.store.message.unset(t),this.emit("message:deleted",t);for(const t of s["chats.delete"]||[])await this.store.chat.unset(t),this.emit("chat:deleted",t);this.emit("process",s,this.socket,this.store)}),await this.socket.waitForConnectionUpdate(async s=>s.connection==="open"),await(0,l.sleep)(5e3),this.socket.authState.creds.registered)e.resolve(this.socket);else if(this.options.loginType==="code")await this.options.code(await this.socket.requestPairingCode(this.options.phone));else if(this.options.loginType==="qr"){const s=(0,l.promify)(),t=setTimeout(()=>s.reject("QR Timeout"),6e4),c=async({qr:p})=>{if(p)try{clearTimeout(t),await this.options.qr(p),s.resolve(p)}catch(M){s.reject(M)}};this.socket.ev.on("connection.update",c),await s.finally(()=>{this.socket.ev.off("connection.update",c)})}return e}}var D=N;0&&(module.exports={Chat,Message,Store,useCache,...require("./static/Store"),...require("./model/chat"),...require("./model/message")});
1
+ "use strict";var M=Object.create;var g=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var q=(s,a)=>{for(var e in a)g(s,e,{get:a[e],enumerable:!0})},u=(s,a,e,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of v(a))!R.call(s,o)&&o!==e&&g(s,o,{get:()=>a[o],enumerable:!(r=E(a,o))||r.enumerable});return s},h=(s,a,e)=>(u(s,a,"default"),e&&u(e,a,"default")),c=(s,a,e)=>(e=s!=null?M(b(s)):{},u(a||!s||!s.__esModule?g(e,"default",{value:s,enumerable:!0}):e,s)),D=s=>u(g({},"__esModule",{value:!0}),s);var n={};q(n,{Chat:()=>P.default,Message:()=>W.default,Store:()=>x.default,default:()=>T,useCache:()=>A.default});module.exports=D(n);var d=require("@arcaelas/utils"),k=require("async-mutex"),y=c(require("baileys")),S=c(require("node:events")),f=c(require("./model/chat")),w=c(require("./model/message")),B=c(require("./static/Store")),C=c(require("./static/useCache"));h(n,require("./static/Store"),module.exports);var x=c(require("./static/Store")),A=c(require("./static/useCache"));h(n,require("./model/chat"),module.exports);var P=c(require("./model/chat"));h(n,require("./model/message"),module.exports);var W=c(require("./model/message"));class I extends S.default{constructor(e){super({captureRejections:!0});this.mutex=new k.Mutex;this.on("error",r=>{this.listenerCount("error")===1&&console.error(r)}),this.options={...e,phone:e.phone.replace(/\D/g,"")},this.store=new B.default(this.options.store),this.connect()}async tick(e){return this.mutex.acquire().then(()=>e(this.socket,this.store))}process(e){return this.on("process",r=>{e(r,this.socket,this.store)})}async documents(){return await this.tick(async(e,r)=>{const o={};for await(const p of r.document.values())o[p.key]=p.value;return o})}async chats(){return await this.tick(async(e,r)=>{const o=[];for await(const p of r.chat.values())o.push(new f.default(this,p));return o})}async messages(){return await this.tick(async(e,r)=>{const o=[];for await(const p of r.message.values())o.push(new w.default(this,p));return o})}async connect(){const e=(0,d.promify)(),{state:r,save:o}=await(0,C.default)(this.store),{version:p}=await y.fetchLatestBaileysVersion();return this.socket=y.makeWASocket({version:p,syncFullHistory:!0,...this.options.browser?{browser:this.options.browser}:{},auth:{creds:r.creds,keys:y.makeCacheableSignalKeyStore(r.keys)}}),await(0,d.sleep)(5e3),this.socket.authState.creds.registered?e.resolve(this.socket):await this.options.code(await this.socket.requestPairingCode(this.options.phone)),this.socket.ev.process(async i=>{if(i["creds.update"]&&await o(),i["connection.update"]){const{connection:t,lastDisconnect:m}=i["connection.update"];t==="open"?e.resolve(this.socket):t==="close"&&m?.error?.output?.statusCode!==y.DisconnectReason.loggedOut&&e.resolve(await this.connect())}await Promise.allSettled([...i["messaging-history.set"]?.chats||[],...i["chats.upsert"]||[]].map(async t=>{await this.store.chat.set(t),this.emit("chat:created",new f.default(this,t))})),await Promise.allSettled([...i["messaging-history.set"]?.messages||[],...i["messages.upsert"]?.messages||[]].map(async t=>{await this.store.message.set(t),this.emit("message:created",new w.default(this,t))})),await Promise.allSettled((i["chats.update"]||[]).map(async t=>{const m=await this.store.chat.get(t.id);if(m!==null){const l=(0,d.merge)(m,t);await this.store.chat.set(l),this.emit("chat:updated",new f.default(this,l))}})),await Promise.allSettled((i["messages.update"]||[]).map(async t=>{const m=await this.store.message.get(t.key.id);if(m!==null){const l=(0,d.merge)(m,t);await this.store.message.set(l),this.emit("message:updated",new w.default(this,l))}}));for(const{id:t}of i["messages.delete"]?.keys||[])await this.store.message.unset(t),this.emit("message:deleted",t);for(const t of i["chats.delete"]||[])await this.store.chat.unset(t),this.emit("chat:deleted",t);this.emit("process",i,this.socket,this.store)}),e}}var T=I;0&&(module.exports={Chat,Message,Store,useCache,...require("./static/Store"),...require("./model/chat"),...require("./model/message")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import { merge, Noop, promify, sleep } from '@arcaelas/utils';\nimport { type Boom } from '@hapi/boom';\nimport { Mutex } from 'async-mutex';\nimport * as Baileys from 'baileys';\nimport EventEmitter from 'node:events';\nimport Chat from './model/chat';\nimport Message from './model/message';\nimport Store, { Engine } from './static/Store';\nimport useCache from './static/useCache';\n\n/**\n * @description Estructura de configuraci\u00F3n para iniciar sesi\u00F3n con WhatsApp.\n */\ninterface IWhatsAppBase {\n phone: string;\n store: Engine;\n browser?: Baileys.WABrowserDescription | undefined;\n}\n\n/**\n * @description Configuraci\u00F3n condicional seg\u00FAn tipo de login.\n */\n// prettier-ignore\ntype IWhatsApp<T extends 'qr' | 'code'> = IWhatsAppBase & {\n loginType: T } & (\n T extends 'qr'\n ? { qr: Noop<[qr: string]> }\n : { code: Noop<[code: string]> }\n );\n\n/**\n * @description\n * Event map for WhatsApp.\n */\ninterface EventMap {\n error: [error: Error];\n open: [];\n close: [];\n qr: [qr: string];\n code: [code: string];\n 'chat:created': [chat: Chat];\n 'chat:updated': [chat: Chat];\n 'chat:deleted': [id: string];\n 'message:created': [message: Message];\n 'message:updated': [message: Message];\n 'message:deleted': [id: string];\n process: [event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store];\n}\n\n/**\n * @description\n * Client for WhatsApp Web.\n * @example\n * const client = new WhatsApp({\n * phone: '1234567890',\n * loginType: 'qr',\n * qr: (code) => console.log(code),\n * });\n */\nclass WhatsApp<T extends 'qr' | 'code'> extends EventEmitter<EventMap> {\n /**\n * @description\n * Store for WhatsApp Web.\n */\n protected store: Store;\n /**\n * @description\n * Options for WhatsApp Web.\n */\n protected options: IWhatsApp<T>;\n /**\n * @description\n * Socket for WhatsApp Web.\n */\n protected socket: Baileys.WASocket;\n /**\n * @description\n * Mutex, used to prevent concurrent access to the socket.\n */\n protected readonly mutex = new Mutex();\n\n constructor(options: IWhatsApp<T>) {\n super({ captureRejections: true });\n this.on('error', (error) => {\n if (this.listenerCount('error') === 1) {\n console.error(error);\n }\n });\n this.options = {\n ...options,\n phone: options.phone.replace(/\\D/g, ''),\n };\n this.store = new Store(this.options.store);\n this.connect();\n }\n\n /**\n * @description\n * Execute a function with the socket and store, means that the function will be executed only when the socket is ready.\n * @param func Function to execute.\n * @returns Result of the function.\n */\n async tick<T extends Noop<[socket: Baileys.WASocket, store: Store], any>>(func: T): Promise<Awaited<ReturnType<T>>> {\n return this.mutex.acquire().then(() => func(this.socket, this.store));\n }\n\n /**\n * @description\n * Process events from the socket.\n * @param func Function to execute.\n * @returns Handler to remove the event listener.\n */\n process(func: Noop<[event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store]>) {\n return this.on('process', (event) => {\n func(event, this.socket, this.store);\n });\n }\n\n /**\n * @description\n * Returns all documents in the store.\n * @returns Promise that resolves to an object containing all documents.\n */\n async documents(): Promise<Record<string, any>> {\n return await this.tick(async (_, store) => {\n const documents: Record<string, any> = {};\n for await (const document of store.document.values()) {\n documents[document.key] = document.value;\n }\n return documents;\n });\n }\n\n /**\n * @description\n * Returns all chats in the store.\n * @returns Promise that resolves to an array of chats.\n */\n async chats(): Promise<Chat[]> {\n return await this.tick(async (_, store) => {\n const chats: Chat[] = [];\n for await (const chat of store.chat.values()) {\n chats.push(new Chat(this, chat));\n }\n return chats;\n });\n }\n\n /**\n * @description\n * Returns all messages in the store.\n * @returns Promise that resolves to an array of messages.\n */\n async messages(): Promise<Message[]> {\n return await this.tick(async (_, store) => {\n const messages: Message[] = [];\n for await (const message of store.message.values()) {\n messages.push(new Message(this, message));\n }\n return messages;\n });\n }\n\n /**\n * @description\n * Connect to WhatsApp Web.\n * @returns Promise that resolves to the socket.\n */\n protected async connect() {\n const promise = promify<Baileys.WASocket>();\n const { state, save } = await useCache(this.store);\n const { version } = await Baileys.fetchLatestBaileysVersion();\n this.socket = Baileys.makeWASocket({\n version,\n syncFullHistory: true,\n ...(this.options.browser ? { browser: this.options.browser } : {}),\n auth: {\n creds: state.creds,\n keys: Baileys.makeCacheableSignalKeyStore(state.keys),\n },\n getMessage: async (key) => {\n const message = await this.store.message.get(key.id!);\n return message ? message.message! : undefined;\n },\n });\n this.socket.ev.process(async (event) => {\n if (event['creds.update']) {\n await save();\n }\n if (event['connection.update']) {\n const { connection, lastDisconnect } = event['connection.update'];\n if (connection === 'open') promise.resolve(this.socket);\n else if (connection === 'close' && (lastDisconnect?.error as Boom)?.output?.statusCode !== Baileys.DisconnectReason.loggedOut) {\n promise.resolve(await this.connect());\n }\n }\n // prettier-ignore\n await Promise.allSettled(\n [...event['messaging-history.set']?.chats || [], ...event['chats.upsert'] || []]\n .map(async chat => {\n await this.store.chat.set(chat);\n this.emit('chat:created', new Chat(this, chat));\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n [...event['messaging-history.set']?.messages || [], ...event['messages.upsert']?.messages || []]\n .map(async message=> {\n await this.store.message.set(message);\n this.emit('message:created', new Message(this, message));\n })\n )\n // prettier-ignore\n await Promise.allSettled(\n (event['chats.update'] || [])\n .map(async update => {\n const payload = await this.store.chat.get(update.id!);\n if (payload !== null) {\n const chat = merge(payload, update) as Baileys.Chat;\n await this.store.chat.set(chat);\n this.emit('chat:updated', new Chat(this, chat));\n }\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n (event['messages.update'] || [])\n .map(async message => {\n const payload = await this.store.message.get(message.key.id!);\n if (payload !== null) {\n const chat = merge(payload, message) as Baileys.WAProto.WebMessageInfo;\n await this.store.message.set(chat);\n this.emit('message:updated', new Message(this, chat));\n }\n })\n );\n\n for (const { id } of event['messages.delete']?.['keys'] || []) {\n await this.store.message.unset(id);\n this.emit('message:deleted', id);\n }\n for (const key of event['chats.delete'] || []) {\n await this.store.chat.unset(key);\n this.emit('chat:deleted', key);\n }\n\n this.emit('process', event, this.socket, this.store);\n });\n\n await this.socket.waitForConnectionUpdate(async (u) => {\n return u.connection === 'open';\n });\n await sleep(5000);\n\n if (this.socket.authState.creds.registered) {\n promise.resolve(this.socket);\n } else if (this.options.loginType === 'code') {\n await this.options['code'](await this.socket.requestPairingCode(this.options.phone));\n } else if (this.options.loginType === 'qr') {\n const _qr = promify<string>();\n const timeout = setTimeout(() => _qr.reject('QR Timeout'), 60000);\n const QR = async ({ qr }) => {\n if (qr) {\n try {\n clearTimeout(timeout);\n await this.options['qr'](qr);\n _qr.resolve(qr);\n } catch (error) {\n _qr.reject(error);\n }\n }\n };\n this.socket.ev.on('connection.update', QR as any);\n await _qr.finally(() => {\n this.socket.ev.off('connection.update', QR as any);\n });\n }\n return promise;\n }\n}\n\nexport default WhatsApp;\nexport * from './static/Store';\nexport { default as Store } from './static/Store';\nexport { default as useCache } from './static/useCache';\n\nexport * from './model/chat';\nexport { default as Chat } from './model/chat';\n\nexport * from './model/message';\nexport { default as Message } from './model/message';\n"],
5
- "mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0EAAAE,EAAA,wCAAAC,EAAAH,GAAA,IAAAI,EAA4C,2BAE5CC,EAAsB,uBACtBC,EAAyB,sBACzBC,EAAyB,0BACzBC,EAAiB,2BACjBC,EAAoB,8BACpBC,EAA8B,6BAC9BC,EAAqB,gCAkRrBC,EAAAZ,EAAc,0BA1Rd,gBA2RA,IAAAU,EAAiC,6BACjCC,EAAoC,gCAEpCC,EAAAZ,EAAc,wBA9Rd,gBA+RA,IAAAQ,EAAgC,2BAEhCI,EAAAZ,EAAc,2BAjSd,gBAkSA,IAAAS,EAAmC,8BAvOnC,MAAMI,UAA0C,EAAAC,OAAuB,CAsBnE,YAAYC,EAAuB,CAC/B,MAAM,CAAE,kBAAmB,EAAK,CAAC,EAHrC,KAAmB,MAAQ,IAAI,QAI3B,KAAK,GAAG,QAAUC,GAAU,CACpB,KAAK,cAAc,OAAO,IAAM,GAChC,QAAQ,MAAMA,CAAK,CAE3B,CAAC,EACD,KAAK,QAAU,CACX,GAAGD,EACH,MAAOA,EAAQ,MAAM,QAAQ,MAAO,EAAE,CAC1C,EACA,KAAK,MAAQ,IA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5E,KAAK,QAAQ,YAAc,KAAM,CACxC,MAAMY,KAAM,WAAgB,EACtBC,EAAU,WAAW,IAAMD,EAAI,OAAO,YAAY,EAAG,GAAK,EAC1DE,EAAK,MAAO,CAAE,GAAAC,CAAG,IAAM,CACzB,GAAIA,EACA,GAAI,CACA,aAAaF,CAAO,EACpB,MAAM,KAAK,QAAQ,GAAME,CAAE,EAC3BH,EAAI,QAAQG,CAAE,CAClB,OAAS7B,EAAP,CACE0B,EAAI,OAAO1B,CAAK,CACpB,CAER,EACA,KAAK,OAAO,GAAG,GAAG,oBAAqB4B,CAAS,EAChD,MAAMF,EAAI,QAAQ,IAAM,CACpB,KAAK,OAAO,GAAG,IAAI,oBAAqBE,CAAS,CACrD,CAAC,EAEL,OAAOd,CACX,CACJ,CAEA,IAAO5B,EAAQW",
6
- "names": ["src_exports", "__export", "src_default", "__toCommonJS", "import_utils", "import_async_mutex", "Baileys", "import_node_events", "import_chat", "import_message", "import_Store", "import_useCache", "__reExport", "WhatsApp", "EventEmitter", "options", "error", "Store", "func", "event", "_", "store", "documents", "document", "chats", "chat", "Chat", "messages", "message", "Message", "promise", "state", "save", "useCache", "version", "key", "connection", "lastDisconnect", "update", "payload", "id", "u", "_qr", "timeout", "QR", "qr"]
4
+ "sourcesContent": ["import { merge, Noop, promify, sleep } from '@arcaelas/utils';\nimport { type Boom } from '@hapi/boom';\nimport { Mutex } from 'async-mutex';\nimport * as Baileys from 'baileys';\nimport EventEmitter from 'node:events';\nimport Chat from './model/chat';\nimport Message from './model/message';\nimport Store, { Engine } from './static/Store';\nimport useCache from './static/useCache';\n\n/**\n * @description Estructura de configuraci\u00F3n para iniciar sesi\u00F3n con WhatsApp.\n */\ninterface IWhatsApp {\n phone: string;\n store: Engine;\n onCode(code: string): void | Promise<void>;\n browser?: Baileys.WABrowserDescription | undefined;\n}\n\n/**\n * @description\n * Event map for WhatsApp.\n */\ninterface EventMap {\n error: [error: Error];\n open: [];\n close: [];\n qr: [qr: string];\n code: [code: string];\n 'chat:created': [chat: Chat];\n 'chat:updated': [chat: Chat];\n 'chat:deleted': [id: string];\n 'message:created': [message: Message];\n 'message:updated': [message: Message];\n 'message:deleted': [id: string];\n process: [event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store];\n}\n\n/**\n * @description\n * Client for WhatsApp Web.\n * @example\n * const client = new WhatsApp({\n * phone: '1234567890',\n * loginType: 'qr',\n * qr: (code) => console.log(code),\n * });\n */\nclass WhatsApp extends EventEmitter<EventMap> {\n /**\n * @description\n * Store for WhatsApp Web.\n */\n protected store: Store;\n /**\n * @description\n * Options for WhatsApp Web.\n */\n protected options: IWhatsApp;\n /**\n * @description\n * Socket for WhatsApp Web.\n */\n protected socket: Baileys.WASocket;\n /**\n * @description\n * Mutex, used to prevent concurrent access to the socket.\n */\n protected readonly mutex = new Mutex();\n\n constructor(options: IWhatsApp) {\n super({ captureRejections: true });\n this.on('error', (error) => {\n if (this.listenerCount('error') === 1) {\n console.error(error);\n }\n });\n this.options = {\n ...options,\n phone: options.phone.replace(/\\D/g, ''),\n };\n this.store = new Store(this.options.store);\n this.connect();\n }\n\n /**\n * @description\n * Execute a function with the socket and store, means that the function will be executed only when the socket is ready.\n * @param func Function to execute.\n * @returns Result of the function.\n */\n async tick<T extends Noop<[socket: Baileys.WASocket, store: Store], any>>(func: T): Promise<Awaited<ReturnType<T>>> {\n return this.mutex.acquire().then(() => func(this.socket, this.store));\n }\n\n /**\n * @description\n * Process events from the socket.\n * @param func Function to execute.\n * @returns Handler to remove the event listener.\n */\n process(func: Noop<[event: Partial<Baileys.BaileysEventMap>, socket: Baileys.WASocket, store: Store]>) {\n return this.on('process', (event) => {\n func(event, this.socket, this.store);\n });\n }\n\n /**\n * @description\n * Returns all documents in the store.\n * @returns Promise that resolves to an object containing all documents.\n */\n async documents(): Promise<Record<string, any>> {\n return await this.tick(async (_, store) => {\n const documents: Record<string, any> = {};\n for await (const document of store.document.values()) {\n documents[document.key] = document.value;\n }\n return documents;\n });\n }\n\n /**\n * @description\n * Returns all chats in the store.\n * @returns Promise that resolves to an array of chats.\n */\n async chats(): Promise<Chat[]> {\n return await this.tick(async (_, store) => {\n const chats: Chat[] = [];\n for await (const chat of store.chat.values()) {\n chats.push(new Chat(this, chat));\n }\n return chats;\n });\n }\n\n /**\n * @description\n * Returns all messages in the store.\n * @returns Promise that resolves to an array of messages.\n */\n async messages(): Promise<Message[]> {\n return await this.tick(async (_, store) => {\n const messages: Message[] = [];\n for await (const message of store.message.values()) {\n messages.push(new Message(this, message));\n }\n return messages;\n });\n }\n\n /**\n * @description\n * Connect to WhatsApp Web.\n * @returns Promise that resolves to the socket.\n */\n protected async connect() {\n const promise = promify<Baileys.WASocket>();\n const { state, save } = await useCache(this.store);\n const { version } = await Baileys.fetchLatestBaileysVersion();\n this.socket = Baileys.makeWASocket({\n version,\n syncFullHistory: true,\n ...(this.options.browser ? { browser: this.options.browser } : {}),\n auth: {\n creds: state.creds,\n keys: Baileys.makeCacheableSignalKeyStore(state.keys),\n },\n });\n\n await sleep(5000);\n if (this.socket.authState.creds.registered) {\n promise.resolve(this.socket);\n } else {\n await this.options['code'](await this.socket.requestPairingCode(this.options.phone));\n }\n\n this.socket.ev.process(async (event) => {\n if (event['creds.update']) {\n await save();\n }\n if (event['connection.update']) {\n const { connection, lastDisconnect } = event['connection.update'];\n if (connection === 'open') promise.resolve(this.socket);\n else if (connection === 'close' && (lastDisconnect?.error as Boom)?.output?.statusCode !== Baileys.DisconnectReason.loggedOut) {\n promise.resolve(await this.connect());\n }\n }\n // prettier-ignore\n await Promise.allSettled(\n [...event['messaging-history.set']?.chats || [], ...event['chats.upsert'] || []]\n .map(async chat => {\n await this.store.chat.set(chat);\n this.emit('chat:created', new Chat(this, chat));\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n [...event['messaging-history.set']?.messages || [], ...event['messages.upsert']?.messages || []]\n .map(async message=> {\n await this.store.message.set(message);\n this.emit('message:created', new Message(this, message));\n })\n )\n // prettier-ignore\n await Promise.allSettled(\n (event['chats.update'] || [])\n .map(async update => {\n const payload = await this.store.chat.get(update.id!);\n if (payload !== null) {\n const chat = merge(payload, update) as Baileys.Chat;\n await this.store.chat.set(chat);\n this.emit('chat:updated', new Chat(this, chat));\n }\n })\n );\n // prettier-ignore\n await Promise.allSettled(\n (event['messages.update'] || [])\n .map(async message => {\n const payload = await this.store.message.get(message.key.id!);\n if (payload !== null) {\n const chat = merge(payload, message) as Baileys.WAProto.WebMessageInfo;\n await this.store.message.set(chat);\n this.emit('message:updated', new Message(this, chat));\n }\n })\n );\n\n for (const { id } of event['messages.delete']?.['keys'] || []) {\n await this.store.message.unset(id);\n this.emit('message:deleted', id);\n }\n for (const key of event['chats.delete'] || []) {\n await this.store.chat.unset(key);\n this.emit('chat:deleted', key);\n }\n\n this.emit('process', event, this.socket, this.store);\n });\n return promise;\n }\n}\n\nexport default WhatsApp;\nexport * from './static/Store';\nexport { default as Store } from './static/Store';\nexport { default as useCache } from './static/useCache';\n\nexport * from './model/chat';\nexport { default as Chat } from './model/chat';\n\nexport * from './model/message';\nexport { default as Message } from './model/message';\n"],
5
+ "mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0EAAAE,EAAA,wCAAAC,EAAAH,GAAA,IAAAI,EAA4C,2BAE5CC,EAAsB,uBACtBC,EAAyB,sBACzBC,EAAyB,0BACzBC,EAAiB,2BACjBC,EAAoB,8BACpBC,EAA8B,6BAC9BC,EAAqB,gCA+OrBC,EAAAZ,EAAc,0BAvPd,gBAwPA,IAAAU,EAAiC,6BACjCC,EAAoC,gCAEpCC,EAAAZ,EAAc,wBA3Pd,gBA4PA,IAAAQ,EAAgC,2BAEhCI,EAAAZ,EAAc,2BA9Pd,gBA+PA,IAAAS,EAAmC,8BA9MnC,MAAMI,UAAiB,EAAAC,OAAuB,CAsB1C,YAAYC,EAAoB,CAC5B,MAAM,CAAE,kBAAmB,EAAK,CAAC,EAHrC,KAAmB,MAAQ,IAAI,QAI3B,KA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QW",
6
+ "names": ["src_exports", "__export", "src_default", "__toCommonJS", "import_utils", "import_async_mutex", "Baileys", "import_node_events", "import_chat", "import_message", "import_Store", "import_useCache", "__reExport", "WhatsApp", "EventEmitter", "options", "error", "Store", "func", "event", "_", "store", "documents", "document", "chats", "chat", "Chat", "messages", "message", "Message", "promise", "state", "save", "useCache", "version", "connection", "lastDisconnect", "update", "payload", "id", "key"]
7
7
  }
@@ -9,9 +9,9 @@ type Serialize<T> = {
9
9
  * Base class for WhatsApp entities.
10
10
  */
11
11
  export default class Base<T> {
12
- protected readonly $: WhatsApp<'code' | 'qr'>;
12
+ protected readonly $: WhatsApp;
13
13
  protected readonly _: Serialize<T>;
14
- constructor($: WhatsApp<'code' | 'qr'>, _: Serialize<T>);
14
+ constructor($: WhatsApp, _: Serialize<T>);
15
15
  /**
16
16
  * @description
17
17
  * Returns a JSON representation of this entity.
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/model/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AAKnC;;;;GAIG;AACH,MAAqB,IAAI;IACrB,YAA+B,CAA0B,EAAqB,CAAe;QAA9D,MAAC,GAAD,CAAC,CAAyB;QAAqB,MAAC,GAAD,CAAC,CAAc;IAAG,CAAC;IACjG;;;;OAIG;IACH,MAAM;QACF,MAAM,CAAC,GAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;gBAAE,SAAS;YAC5C,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IACD;;;;OAIG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACJ;AAvBD,uBAuBC"}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/model/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AAKnC;;;;GAIG;AACH,MAAqB,IAAI;IACrB,YAA+B,CAAW,EAAqB,CAAe;QAA/C,MAAC,GAAD,CAAC,CAAU;QAAqB,MAAC,GAAD,CAAC,CAAc;IAAG,CAAC;IAClF;;;;OAIG;IACH,MAAM;QACF,MAAM,CAAC,GAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;gBAAE,SAAS;YAC5C,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IACD;;;;OAIG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACJ;AAvBD,uBAuBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "license": "ISC",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "name": "@arcaelas/whatsapp",
5
5
  "homepage": "https://github.com/arcaelas/whatsapp",
6
6
  "description": "A small box of tools, which are implemented in different factions of the library.",