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.
Files changed (216) hide show
  1. package/Example/connection.cjs +4 -0
  2. package/README.MD +4726 -48
  3. package/WAProto/WAProto.proto +3395 -415
  4. package/WAProto/compat.cjs +12 -0
  5. package/WAProto/index.d.ts +47104 -19888
  6. package/WAProto/index.js +131979 -57361
  7. package/lib/Addon/http-error.js +43 -0
  8. package/lib/Addon/index.js +32 -0
  9. package/lib/Addon/keyed-db.js +250 -0
  10. package/lib/Addon/link-preview.js +82 -0
  11. package/lib/Defaults/baileys-version.json +3 -0
  12. package/lib/Defaults/connection.js +110 -0
  13. package/lib/Defaults/constants.js +156 -0
  14. package/lib/Defaults/history.js +46 -0
  15. package/lib/Defaults/index.js +230 -0
  16. package/lib/Defaults/media.js +104 -0
  17. package/lib/Defaults/phonenumber-mcc.json +223 -0
  18. package/lib/Defaults/prefix.js +44 -0
  19. package/lib/Extensions/business-advanced.js +382 -0
  20. package/lib/Extensions/business.js +159 -0
  21. package/lib/Extensions/chats-advanced.js +1106 -0
  22. package/lib/Extensions/chats.js +349 -0
  23. package/lib/Extensions/communities-advanced.js +430 -0
  24. package/lib/Extensions/community.js +94 -0
  25. package/lib/Extensions/groups-advanced.js +343 -0
  26. package/lib/Extensions/index.js +30 -0
  27. package/lib/Extensions/messages-recv-advanced.js +1690 -0
  28. package/lib/Extensions/messages-send-advanced.js +622 -0
  29. package/lib/Extensions/messages-send.js +1380 -0
  30. package/lib/Extensions/newsletter-advanced.js +228 -0
  31. package/lib/Extensions/newsletter.js +72 -0
  32. package/lib/Extensions/socket.js +389 -0
  33. package/lib/Modded/message_builder.js +2084 -4
  34. package/lib/Signal/Group/ciphertext-message.js +54 -0
  35. package/lib/Signal/Group/group-session-builder.js +124 -0
  36. package/lib/Signal/Group/group_cipher.js +216 -0
  37. package/lib/Signal/Group/index.js +124 -0
  38. package/lib/Signal/Group/keyhelper.js +108 -0
  39. package/lib/Signal/Group/sender-chain-key.js +83 -0
  40. package/lib/Signal/Group/sender-key-distribution-message.js +157 -0
  41. package/lib/Signal/Group/sender-key-message.js +166 -0
  42. package/lib/Signal/Group/sender-key-name.js +130 -0
  43. package/lib/Signal/Group/sender-key-record.js +113 -0
  44. package/lib/Signal/Group/sender-key-state.js +208 -0
  45. package/lib/Signal/Group/sender-message-key.js +82 -0
  46. package/lib/Signal/libsignal.js +935 -0
  47. package/lib/Signal/lid-mapping.js +545 -1
  48. package/lib/Socket/Client/index.js +60 -0
  49. package/lib/Socket/Client/types.js +51 -0
  50. package/lib/Socket/Client/websocket.js +152 -0
  51. package/lib/Socket/business.js +831 -0
  52. package/lib/Socket/chats.js +2535 -49
  53. package/lib/Socket/communities.js +450 -1
  54. package/lib/Socket/community.js +1022 -0
  55. package/lib/Socket/dugong.js +1 -1
  56. package/lib/Socket/groups.js +747 -0
  57. package/lib/Socket/index.js +60 -2
  58. package/lib/Socket/messages-recv.js +3450 -5
  59. package/lib/Socket/messages-send.js +3123 -0
  60. package/lib/Socket/mex.js +126 -1
  61. package/lib/Socket/newsletter.js +465 -0
  62. package/lib/Socket/socket.js +2217 -1
  63. package/lib/Store/index.js +79 -0
  64. package/lib/Store/make-cache-manager-store.js +186 -0
  65. package/lib/Store/make-in-memory-store.js +878 -0
  66. package/lib/Store/make-ordered-dictionary.js +187 -0
  67. package/lib/Store/object-repository.js +78 -0
  68. package/lib/Types/Auth.js +25 -0
  69. package/lib/Types/Bussines.js +25 -1
  70. package/lib/Types/Call.js +25 -0
  71. package/lib/Types/Chat.js +39 -0
  72. package/lib/Types/Contact.js +25 -0
  73. package/lib/Types/Events.js +25 -0
  74. package/lib/Types/GroupMetadata.js +25 -0
  75. package/lib/Types/Label.js +76 -0
  76. package/lib/Types/LabelAssociation.js +40 -0
  77. package/lib/Types/Message.js +57 -0
  78. package/lib/Types/Mex.js +56 -1
  79. package/lib/Types/MexUpdates.js +46 -0
  80. package/lib/Types/Newsletter.js +56 -0
  81. package/lib/Types/Product.js +25 -0
  82. package/lib/Types/RichType.js +23 -0
  83. package/lib/Types/Signal.js +25 -0
  84. package/lib/Types/Socket.js +25 -0
  85. package/lib/Types/State.js +92 -0
  86. package/lib/Types/USync.js +25 -0
  87. package/lib/Types/index.js +133 -0
  88. package/lib/Utils/auth-utils.js +703 -0
  89. package/lib/Utils/automation-tools.js +51 -16
  90. package/lib/Utils/baileys-event-stream.js +146 -0
  91. package/lib/Utils/browser-utils.js +95 -0
  92. package/lib/Utils/business.js +525 -0
  93. package/lib/Utils/chat-utils.js +1861 -0
  94. package/lib/Utils/companion-reg-client-utils.js +55 -1
  95. package/lib/Utils/crypto.js +355 -0
  96. package/lib/Utils/decode-wa-message.js +709 -0
  97. package/lib/Utils/event-buffer.js +1323 -8
  98. package/lib/Utils/generics.js +945 -1
  99. package/lib/Utils/history.js +266 -0
  100. package/lib/Utils/identity-change-handler.js +62 -1
  101. package/lib/Utils/index.js +114 -0
  102. package/lib/Utils/link-preview.js +179 -0
  103. package/lib/Utils/logger.js +42 -0
  104. package/lib/Utils/lt-hash.js +73 -0
  105. package/lib/Utils/make-mutex.js +104 -0
  106. package/lib/Utils/message-inspector.js +110 -0
  107. package/lib/Utils/message-retry-manager.js +507 -2
  108. package/lib/Utils/messages-media.js +1931 -1
  109. package/lib/Utils/messages.js +3748 -0
  110. package/lib/Utils/noise-handler.js +423 -0
  111. package/lib/Utils/offline-node-processor.js +53 -1
  112. package/lib/Utils/pre-key-manager.js +255 -1
  113. package/lib/Utils/process-message.js +1592 -0
  114. package/lib/Utils/reporting-utils.js +272 -1
  115. package/lib/Utils/rich-message-utils.js +377 -0
  116. package/lib/Utils/rich-messages.js +1 -1
  117. package/lib/Utils/signal.js +437 -0
  118. package/lib/Utils/stanza-ack.js +51 -1
  119. package/lib/Utils/status-refresh.js +37 -0
  120. package/lib/Utils/status-tools.js +4 -2
  121. package/lib/Utils/sync-action-utils.js +63 -1
  122. package/lib/Utils/tc-token-utils.js +185 -1
  123. package/lib/Utils/terminal-banner.js +31 -0
  124. package/lib/Utils/use-multi-file-auth-state.js +271 -0
  125. package/lib/Utils/use-single-file-auth-state.js +108 -0
  126. package/lib/Utils/use-sqlite-auth-state.js +142 -0
  127. package/lib/Utils/validate-connection.js +497 -1
  128. package/lib/Utils/view-once-compat.js +13 -5
  129. package/lib/VoIP/audio-feeder.js +150 -0
  130. package/lib/VoIP/index.js +289 -0
  131. package/lib/VoIP/relay-transport.js +608 -0
  132. package/lib/VoIP/signaling.js +583 -0
  133. package/lib/VoIP/types.js +30 -0
  134. package/lib/VoIP/wasm-engine.js +1261 -2
  135. package/lib/VoIP/worker-bootstrap.js +1090 -2
  136. package/lib/WABinary/constants.js +2805 -0
  137. package/lib/WABinary/decode.js +649 -2
  138. package/lib/WABinary/encode.js +564 -2
  139. package/lib/WABinary/generic-utils.js +401 -0
  140. package/lib/WABinary/index.js +82 -0
  141. package/lib/WABinary/jid-utils.js +290 -0
  142. package/lib/WABinary/types.js +25 -0
  143. package/lib/WAM/BinaryInfo.js +50 -0
  144. package/lib/WAM/constants.js +45747 -0
  145. package/lib/WAM/encode.js +393 -0
  146. package/lib/WAM/index.js +78 -0
  147. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +135 -0
  148. package/lib/WAUSync/Protocols/USyncContactProtocol.js +110 -0
  149. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +142 -0
  150. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +85 -0
  151. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +69 -0
  152. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +107 -0
  153. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +38 -1
  154. package/lib/WAUSync/Protocols/index.js +83 -0
  155. package/lib/WAUSync/USyncQuery.js +241 -2
  156. package/lib/WAUSync/USyncUser.js +86 -0
  157. package/lib/WAUSync/index.js +78 -0
  158. package/lib/assets/wasm/loader.js +1875 -1
  159. package/lib/assets/wasm/worker-modules.js +11047 -1
  160. package/lib/index.d.ts +126 -0
  161. package/lib/index.js +53 -21
  162. package/lib/index.mjs +437 -0
  163. package/licenses/upstream-MIT.txt +22 -0
  164. package/maintenance/api-coverage.json +1642 -0
  165. package/maintenance/archivos-sha256.json +207 -0
  166. package/maintenance/consumer-validation.log +3 -0
  167. package/maintenance/dependency-audit.json +4 -4
  168. package/maintenance/extension-inventory.json +57 -0
  169. package/maintenance/protocol-update.json +1101 -0
  170. package/maintenance/protocol-wire-audit.json +4 -0
  171. package/maintenance/reference-socket-surface.json +209 -0
  172. package/maintenance/resumen-validacion.json +50 -0
  173. package/maintenance/validation.log +2725 -0
  174. package/maintenance/verification.json +566 -0
  175. package/package.json +107 -9
  176. package/scripts/check-imports.cjs +10 -0
  177. package/scripts/check-package.cjs +40 -0
  178. package/scripts/check-syntax.cjs +1 -1
  179. package/scripts/generate-protobuf.cjs +6 -1
  180. package/scripts/generate-public-types.cjs +9 -0
  181. package/scripts/kage-base64-fix.cjs +45 -0
  182. package/scripts/maintenance.cjs +10 -0
  183. package/test/advanced.test.cjs +24 -0
  184. package/test/base64-fix.test.cjs +49 -0
  185. package/test/maintenance.test.cjs +1 -1
  186. package/test/npm-publication.test.cjs +141 -0
  187. package/test/recepcion-reparada.test.cjs +98 -0
  188. package/test/resilience-binary.test.cjs +69 -0
  189. package/test/resilience-transport.test.cjs +34 -0
  190. package/test/types.test.ts +5 -0
  191. package/test/upgrade.test.cjs +104 -0
  192. package/tsconfig.json +20 -0
  193. package/WAProto/p.html +0 -1
  194. package/lib/KageExtra/Modded/message_builder.js +0 -2330
  195. package/lib/KageExtra/VoIP/audio-feeder.js +0 -136
  196. package/lib/KageExtra/VoIP/index.js +0 -282
  197. package/lib/KageExtra/VoIP/relay-transport.js +0 -559
  198. package/lib/KageExtra/VoIP/signaling.js +0 -603
  199. package/lib/KageExtra/VoIP/types.js +0 -17
  200. package/lib/KageExtra/VoIP/wasm-engine.js +0 -1214
  201. package/lib/KageExtra/VoIP/worker-bootstrap.js +0 -1042
  202. package/lib/KageExtra/assets/wasm/loader.js +0 -5
  203. package/lib/KageExtra/assets/wasm/whatsapp.wasm +0 -0
  204. package/lib/KageExtra/assets/wasm/worker-modules.js +0 -273
  205. package/lib/KageExtra/index.js +0 -3
  206. package/lib/KageExtra/package.json +0 -1
  207. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
  208. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -24
  209. package/maintenance/revision-full-check.txt +0 -1097
  210. package/maintenance/revision-library-tests.tap +0 -1088
  211. package/maintenance/revision-protobuf.txt +0 -5
  212. package/maintenance/revision-syntax.txt +0 -5
  213. package/maintenance/schema-coverage.json +0 -23
  214. package/maintenance/schema-merge.json +0 -30
  215. package/maintenance/validation-node20.txt +0 -191
  216. package/maintenance/validation-node22.txt +0 -237
@@ -453,3 +453,881 @@ exports.default = (config = {}) => {
453
453
  }
454
454
  };
455
455
  };
456
+
457
+ // Kage: compatibilidad de API.
458
+ const __kageModule36 = (() => {
459
+ const module = { exports: {} }; const exports = module.exports;
460
+ "use strict"
461
+
462
+ Object.defineProperty(exports, "__esModule", { value: true })
463
+
464
+ const { proto } = require("../../WAProto")
465
+ const { DEFAULT_CONNECTION_CONFIG } = require("../Defaults/connection")
466
+ const { LabelAssociationType } = require("../Types/LabelAssociation")
467
+ const {
468
+ md5,
469
+ toNumber,
470
+ updateMessageWithReceipt,
471
+ updateMessageWithReaction
472
+ } = require("../Utils")
473
+ const {
474
+ jidDecode,
475
+ jidNormalizedUser
476
+ } = require("../WABinary")
477
+ const { makeOrderedDictionary } = require("./make-ordered-dictionary")
478
+ const { ObjectRepository } = require("./object-repository")
479
+
480
+ const waChatKey = (pin) => ({
481
+ key: (c) => (pin ? (c.pinned ? '1' : '0') : '') + (c.archived ? '0' : '1') + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, '0') : '') + c.id,
482
+ compare: (k1, k2) => k2.localeCompare(k1)
483
+ })
484
+
485
+ const waMessageID = (m) => m.key.id || ''
486
+
487
+ const waLabelAssociationKey = {
488
+ key: (la) => (la.type === LabelAssociationType.Chat ? la.chatId + la.labelId : la.chatId + la.messageId + la.labelId),
489
+ compare: (k1, k2) => k2.localeCompare(k1)
490
+ }
491
+
492
+ const makeMessagesDictionary = () => makeOrderedDictionary(waMessageID)
493
+
494
+ const makeInMemoryStore = (config) => {
495
+ const socket = config.socket
496
+ const chatKey = config.chatKey || waChatKey(true)
497
+ const labelAssociationKey = config.labelAssociationKey || waLabelAssociationKey
498
+ const logger = config.logger || DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' })
499
+ const KeyedDB = require('@adiwajshing/keyed-db').default
500
+ const chats = new KeyedDB(chatKey, c => c.id)
501
+ const messages = {}
502
+ const contacts = {}
503
+ const groupMetadata = {}
504
+ const presences = {}
505
+ const state = { connection: 'close' }
506
+ const labels = new ObjectRepository()
507
+ const labelAssociations = new KeyedDB(labelAssociationKey, labelAssociationKey.key)
508
+ const assertMessageList = (jid) => {
509
+ if (!messages[jid]) {
510
+ messages[jid] = makeMessagesDictionary()
511
+ }
512
+ return messages[jid]
513
+ }
514
+ const contactsUpsert = (newContacts) => {
515
+ const oldContacts = new Set(Object.keys(contacts))
516
+ for (const contact of newContacts) {
517
+ oldContacts.delete(contact.id)
518
+ contacts[contact.id] = Object.assign(contacts[contact.id] || {}, contact)
519
+ }
520
+ return oldContacts
521
+ }
522
+ const labelsUpsert = (newLabels) => {
523
+ for (const label of newLabels) {
524
+ labels.upsertById(label.id, label)
525
+ }
526
+ }
527
+ /**
528
+ * binds to a BaileysEventEmitter.
529
+ * It listens to all events and constructs a state that you can query accurate data from.
530
+ * Eg. can use the store to fetch chats, contacts, messages etc.
531
+ * @param ev typically the event emitter from the socket connection
532
+ */
533
+ const bind = (ev) => {
534
+ ev.on('connection.update', update => {
535
+ Object.assign(state, update)
536
+ })
537
+ ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
538
+ if (syncType === proto.HistorySync.HistorySyncType.ON_DEMAND) {
539
+ return // FOR NOW,
540
+ //TODO: HANDLE
541
+ }
542
+ if (isLatest) {
543
+ chats.clear()
544
+ for (const id in messages) {
545
+ delete messages[id]
546
+ }
547
+ }
548
+ const chatsAdded = chats.insertIfAbsent(...newChats).length
549
+ logger.debug({ chatsAdded }, 'synced chats')
550
+ const oldContacts = contactsUpsert(newContacts)
551
+ if (isLatest) {
552
+ for (const jid of oldContacts) {
553
+ delete contacts[jid]
554
+ }
555
+ }
556
+ logger.debug({ deletedContacts: isLatest ? oldContacts.size : 0, newContacts }, 'synced contacts')
557
+ for (const msg of newMessages) {
558
+ const jid = msg.key.remoteJid
559
+ const list = assertMessageList(jid)
560
+ list.upsert(msg, 'prepend')
561
+ }
562
+ logger.debug({ messages: newMessages.length }, 'synced messages')
563
+ })
564
+ ev.on('contacts.upsert', contacts => {
565
+ contactsUpsert(contacts)
566
+ })
567
+ ev.on('contacts.update', async (updates) => {
568
+ for (const update of updates) {
569
+ let contact
570
+ if (contacts[update.id]) {
571
+ contact = contacts[update.id]
572
+ }
573
+ else {
574
+ const contactHashes = await Promise.all(Object.keys(contacts).map(async (contactId) => {
575
+ const { user } = jidDecode(contactId)
576
+ return [contactId, (await md5(Buffer.from(user + 'WA_ADD_NOTIF', 'utf8'))).toString('base64').slice(0, 3)]
577
+ }))
578
+ contact = contacts[contactHashes.find(([, b]) => b === update.id?.[0]) || ''] // find contact by attrs.hash, when user is not saved as a contact
579
+ }
580
+ if (contact) {
581
+ if (update.imgUrl === 'changed') {
582
+ contact.imgUrl = socket ? await socket.profilePictureUrl(contact.id) : undefined
583
+ }
584
+ else if (update.imgUrl === 'removed') {
585
+ delete contact.imgUrl
586
+ }
587
+ }
588
+ else {
589
+ return logger.debug({ update }, 'got update for non-existant contact')
590
+ }
591
+ Object.assign(contacts[contact.id], contact)
592
+ }
593
+ })
594
+ ev.on('chats.upsert', newChats => {
595
+ chats.upsert(...newChats)
596
+ })
597
+ ev.on('chats.update', updates => {
598
+ for (let update of updates) {
599
+ const result = chats.update(update.id, chat => {
600
+ if (update.unreadCount > 0) {
601
+ update = { ...update }
602
+ update.unreadCount = (chat.unreadCount || 0) + update.unreadCount
603
+ }
604
+ Object.assign(chat, update)
605
+ })
606
+ if (!result) {
607
+ logger.debug({ update }, 'got update for non-existant chat')
608
+ }
609
+ }
610
+ })
611
+ ev.on('labels.edit', (label) => {
612
+ if (label.deleted) {
613
+ return labels.deleteById(label.id)
614
+ }
615
+ // WhatsApp can store only up to 20 labels
616
+ if (labels.count() < 20) {
617
+ return labels.upsertById(label.id, label)
618
+ }
619
+ logger.error('Labels count exceed')
620
+ })
621
+ ev.on('labels.association', ({ type, association }) => {
622
+ switch (type) {
623
+ case 'add':
624
+ labelAssociations.upsert(association)
625
+ break
626
+ case 'remove':
627
+ labelAssociations.delete(association)
628
+ break
629
+ default:
630
+ console.error(`unknown operation type [${type}]`)
631
+ }
632
+ })
633
+ ev.on('presence.update', ({ id, presences: update }) => {
634
+ presences[id] = presences[id] || {}
635
+ Object.assign(presences[id], update)
636
+ })
637
+ ev.on('chats.delete', deletions => {
638
+ for (const item of deletions) {
639
+ if (chats.get(item)) {
640
+ chats.deleteById(item)
641
+ }
642
+ }
643
+ })
644
+ ev.on('messages.upsert', ({ messages: newMessages, type }) => {
645
+ switch (type) {
646
+ case 'append':
647
+ case 'notify':
648
+ for (const msg of newMessages) {
649
+ const jid = jidNormalizedUser(msg.key.remoteJid)
650
+ const list = assertMessageList(jid)
651
+ list.upsert(msg, 'append')
652
+ if (type === 'notify' && !chats.get(jid)) {
653
+ ev.emit('chats.upsert', [
654
+ {
655
+ id: jid,
656
+ conversationTimestamp: toNumber(msg.messageTimestamp),
657
+ unreadCount: 1
658
+ }
659
+ ])
660
+ }
661
+ }
662
+ break
663
+ }
664
+ })
665
+ ev.on('messages.update', updates => {
666
+ for (const { update, key } of updates) {
667
+ const list = assertMessageList(jidNormalizedUser(key.remoteJid))
668
+ if (update?.status) {
669
+ const listStatus = list.get(key.id)?.status
670
+ if (listStatus && update?.status <= listStatus) {
671
+ logger.debug({ update, storedStatus: listStatus }, 'status stored newer then update')
672
+ delete update.status
673
+ logger.debug({ update }, 'new update object')
674
+ }
675
+ }
676
+ const result = list.updateAssign(key.id, update)
677
+ if (!result) {
678
+ logger.debug({ update }, 'got update for non-existent message')
679
+ }
680
+ }
681
+ })
682
+ ev.on('messages.delete', item => {
683
+ if ('all' in item) {
684
+ const list = messages[item.jid]
685
+ list?.clear()
686
+ }
687
+ else {
688
+ const jid = item.keys[0].remoteJid
689
+ const list = messages[jid]
690
+ if (list) {
691
+ const idSet = new Set(item.keys.map(k => k.id))
692
+ list.filter(m => !idSet.has(m.key.id))
693
+ }
694
+ }
695
+ })
696
+ ev.on('groups.update', updates => {
697
+ for (const update of updates) {
698
+ const id = update.id
699
+ if (groupMetadata[id]) {
700
+ Object.assign(groupMetadata[id], update)
701
+ }
702
+ else {
703
+ logger.debug({ update }, 'got update for non-existant group metadata')
704
+ }
705
+ }
706
+ })
707
+ ev.on('group-participants.update', ({ id, participants, action }) => {
708
+ const metadata = groupMetadata[id]
709
+ if (metadata) {
710
+ switch (action) {
711
+ case 'add':
712
+ metadata.participants.push(...participants.map(id => ({ id, isAdmin: false, isSuperAdmin: false })))
713
+ break
714
+ case 'demote':
715
+ case 'promote':
716
+ for (const participant of metadata.participants) {
717
+ if (participants.includes(participant.id)) {
718
+ participant.isAdmin = action === 'promote'
719
+ }
720
+ }
721
+ break
722
+ case 'remove':
723
+ metadata.participants = metadata.participants.filter(p => !participants.includes(p.id))
724
+ break
725
+ }
726
+ }
727
+ })
728
+ ev.on('message-receipt.update', updates => {
729
+ for (const { key, receipt } of updates) {
730
+ const obj = messages[key.remoteJid]
731
+ const msg = obj?.get(key.id)
732
+ if (msg) {
733
+ updateMessageWithReceipt(msg, receipt)
734
+ }
735
+ }
736
+ })
737
+ ev.on('messages.reaction', (reactions) => {
738
+ for (const { key, reaction } of reactions) {
739
+ const obj = messages[key.remoteJid]
740
+ const msg = obj?.get(key.id)
741
+ if (msg) {
742
+ updateMessageWithReaction(msg, reaction)
743
+ }
744
+ }
745
+ })
746
+ }
747
+ const toJSON = () => ({
748
+ chats,
749
+ contacts,
750
+ messages,
751
+ labels,
752
+ labelAssociations
753
+ })
754
+ const fromJSON = (json) => {
755
+ chats.upsert(...json.chats)
756
+ labelAssociations.upsert(...json.labelAssociations || [])
757
+ contactsUpsert(Object.values(json.contacts))
758
+ labelsUpsert(Object.values(json.labels || {}))
759
+ for (const jid in json.messages) {
760
+ const list = assertMessageList(jid)
761
+ for (const msg of json.messages[jid]) {
762
+ list.upsert(proto.WebMessageInfo.fromObject(msg), 'append')
763
+ }
764
+ }
765
+ }
766
+ return {
767
+ chats,
768
+ contacts,
769
+ messages,
770
+ groupMetadata,
771
+ state,
772
+ presences,
773
+ labels,
774
+ labelAssociations,
775
+ bind,
776
+ /** loads messages from the store, if not found -- uses the legacy connection */
777
+ loadMessages: async (jid, count, cursor) => {
778
+ const list = assertMessageList(jid)
779
+ const mode = !cursor || 'before' in cursor ? 'before' : 'after'
780
+ const cursorKey = !!cursor ? ('before' in cursor ? cursor.before : cursor.after) : undefined
781
+ const cursorValue = cursorKey ? list.get(cursorKey.id) : undefined
782
+ let messages
783
+ if (list && mode === 'before' && (!cursorKey || cursorValue)) {
784
+ if (cursorValue) {
785
+ const msgIdx = list.array.findIndex(m => m.key.id === cursorKey?.id)
786
+ messages = list.array.slice(0, msgIdx)
787
+ }
788
+ else {
789
+ messages = list.array
790
+ }
791
+ const diff = count - messages.length
792
+ if (diff < 0) {
793
+ messages = messages.slice(-count) // get the last X messages
794
+ }
795
+ }
796
+ else {
797
+ messages = []
798
+ }
799
+ return messages
800
+ },
801
+ /**
802
+ * Get all available labels for profile
803
+ *
804
+ * Keep in mind that the list is formed from predefined tags and tags
805
+ * that were "caught" during their editing.
806
+ */
807
+ getLabels: () => {
808
+ return labels
809
+ },
810
+ /**
811
+ * Get labels for chat
812
+ *
813
+ * @returns Label IDs
814
+ **/
815
+ getChatLabels: (chatId) => {
816
+ return labelAssociations.filter((la) => la.chatId === chatId).all()
817
+ },
818
+ /**
819
+ * Get labels for message
820
+ *
821
+ * @returns Label IDs
822
+ **/
823
+ getMessageLabels: (messageId) => {
824
+ const associations = labelAssociations
825
+ .filter((la) => la.messageId === messageId)
826
+ .all()
827
+ return associations.map(({ labelId }) => labelId)
828
+ },
829
+ loadMessage: async (jid, id) => messages[jid]?.get(id),
830
+ mostRecentMessage: async (jid) => {
831
+ const message = messages[jid]?.array.slice(-1)[0]
832
+ return message
833
+ },
834
+ fetchImageUrl: async (jid, suki) => {
835
+ const contact = contacts[jid]
836
+ if (!contact) {
837
+ return suki?.profilePictureUrl(jid)
838
+ }
839
+ if (typeof contact.imgUrl === 'undefined') {
840
+ contact.imgUrl = await suki?.profilePictureUrl(jid)
841
+ }
842
+ return contact.imgUrl
843
+ },
844
+ fetchGroupMetadata: async (jid, suki) => {
845
+ if (!groupMetadata[jid]) {
846
+ const metadata = await suki?.groupMetadata(jid)
847
+ if (metadata) {
848
+ groupMetadata[jid] = metadata
849
+ }
850
+ }
851
+ return groupMetadata[jid]
852
+ },
853
+ // fetchBroadcastListInfo: async(jid: string, sock: WASocket | undefined) => {
854
+ // if(!groupMetadata[jid]) {
855
+ // const metadata = await sock?.getBroadcastListInfo(jid)
856
+ // if(metadata) {
857
+ // groupMetadata[jid] = metadata
858
+ // }
859
+ // }
860
+ // return groupMetadata[jid]
861
+ // },
862
+ fetchMessageReceipts: async ({ remoteJid, id }) => {
863
+ const list = messages[remoteJid]
864
+ const msg = list?.get(id)
865
+ return msg?.userReceipt
866
+ },
867
+ toJSON,
868
+ fromJSON,
869
+ writeToFile: (path) => {
870
+ // require fs here so that in case "fs" is not available -- the app does not crash
871
+ const { writeFileSync } = require('fs')
872
+ writeFileSync(path, JSON.stringify(toJSON()))
873
+ },
874
+ readFromFile: (path) => {
875
+ // require fs here so that in case "fs" is not available -- the app does not crash
876
+ const { readFileSync, existsSync } = require('fs')
877
+ if (existsSync(path)) {
878
+ logger.debug({ path }, 'reading from file')
879
+ const jsonStr = readFileSync(path, { encoding: 'utf-8' })
880
+ const json = JSON.parse(jsonStr)
881
+ fromJSON(json)
882
+ }
883
+ }
884
+ }
885
+ }
886
+
887
+ module.exports = {
888
+ waChatKey,
889
+ waMessageID,
890
+ waLabelAssociationKey,
891
+ makeInMemoryStore
892
+ }
893
+ return module.exports;
894
+ })();
895
+ for (const key of Object.keys(__kageModule36)) {
896
+ if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule36[key]});
897
+ }
898
+
899
+ // Kage: funciones avanzadas.
900
+ const __kageModule141 = (() => {
901
+ const module = { exports: {} }; const exports = module.exports;
902
+ "use strict";
903
+ Object.defineProperty(exports, "__esModule", { value: true });
904
+ exports.makeInMemoryStore = exports.waLabelAssociationKey = exports.waMessageID = exports.waChatKey = void 0;
905
+ /**
906
+ * Kage: nota de compatibilidad.
907
+ * Manually converted to ESM and modified by me
908
+ * Originally based on @whiskeysockets/baileys v6.7.16
909
+ * Minor adjustments for compatibility with baileys v7 (⁠つ⁠≧⁠▽⁠≦⁠)⁠つ
910
+ */
911
+ const node_fs_1 = require("node:fs");
912
+ const index_js_1 = require("../Addon/index.js");
913
+ const index_js_2 = require("../Types/index.js");
914
+ const LabelAssociation_js_1 = require("../Types/LabelAssociation.js");
915
+ const index_js_3 = require("../Defaults/index.js");
916
+ const index_js_4 = require("../Utils/index.js");
917
+ const index_js_5 = require("../WABinary/index.js");
918
+ const make_ordered_dictionary_js_1 = require("./make-ordered-dictionary.js");
919
+ const object_repository_js_1 = require("./object-repository.js");
920
+ const waChatKey = (pin) => ({
921
+ key: (c) => (pin ? (c.pinned ? '1' : '0') : '') + (c.archived ? '0' : '1') + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, '0') : '') + c.id,
922
+ compare: (k1, k2) => k2.localeCompare(k1)
923
+ });
924
+ exports.waChatKey = waChatKey;
925
+ const waMessageID = (m) => m.key.id || '';
926
+ exports.waMessageID = waMessageID;
927
+ exports.waLabelAssociationKey = {
928
+ key: (la) => (la.type === LabelAssociation_js_1.LabelAssociationType.Chat ? la.chatId + la.labelId : la.chatId + la.messageId + la.labelId),
929
+ compare: (k1, k2) => k2.localeCompare(k1)
930
+ };
931
+ const makeMessagesDictionary = () => (0, make_ordered_dictionary_js_1.makeOrderedDictionary)(exports.waMessageID);
932
+ const makeInMemoryStore = (config = {}) => {
933
+ const socket = config.socket;
934
+ const chatKey = config.chatKey || (0, exports.waChatKey)(true);
935
+ const labelAssociationKey = config.labelAssociationKey || exports.waLabelAssociationKey;
936
+ const logger = config.logger || index_js_3.DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' });
937
+ const chats = new index_js_1.KeyedDB(chatKey, c => c.id);
938
+ const messages = {};
939
+ const contacts = {};
940
+ const groupMetadata = {};
941
+ const presences = {};
942
+ const state = { connection: 'close' };
943
+ const labels = new object_repository_js_1.ObjectRepository();
944
+ const labelAssociations = new index_js_1.KeyedDB(labelAssociationKey, labelAssociationKey.key);
945
+ const assertMessageList = (jid) => {
946
+ if (!messages[jid]) {
947
+ messages[jid] = makeMessagesDictionary();
948
+ }
949
+ return messages[jid];
950
+ };
951
+ const contactsUpsert = (newContacts) => {
952
+ const oldContacts = new Set(Object.keys(contacts));
953
+ for (const contact of newContacts) {
954
+ oldContacts.delete(contact.id);
955
+ contacts[contact.id] = Object.assign(contacts[contact.id] || {}, contact);
956
+ }
957
+ return oldContacts;
958
+ };
959
+ const labelsUpsert = (newLabels) => {
960
+ for (const label of newLabels) {
961
+ labels.upsertById(label.id, label);
962
+ }
963
+ };
964
+ /**
965
+ * binds to a BaileysEventEmitter.
966
+ * It listens to all events and constructs a state that you can query accurate data from.
967
+ * Eg. can use the store to fetch chats, contacts, messages etc.
968
+ * @param ev typically the event emitter from the socket connection
969
+ */
970
+ const bind = (ev) => {
971
+ ev.on('connection.update', update => {
972
+ Object.assign(state, update);
973
+ });
974
+ ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
975
+ if (syncType === index_js_2.WAProto.HistorySync.HistorySyncType.ON_DEMAND) {
976
+ return; // FOR NOW,
977
+ //TODO: HANDLE
978
+ }
979
+ if (isLatest) {
980
+ chats.clear();
981
+ for (const id in messages) {
982
+ delete messages[id];
983
+ }
984
+ }
985
+ const chatsAdded = chats.insertIfAbsent(...newChats).length;
986
+ logger.debug({ chatsAdded }, 'synced chats');
987
+ const oldContacts = contactsUpsert(newContacts);
988
+ if (isLatest) {
989
+ for (const jid of oldContacts) {
990
+ delete contacts[jid];
991
+ }
992
+ }
993
+ logger.debug({ deletedContacts: isLatest ? oldContacts.size : 0, newContacts }, 'synced contacts');
994
+ for (const msg of newMessages) {
995
+ const jid = msg.key.remoteJidAlt || msg.key.remoteJid;
996
+ const list = assertMessageList(jid);
997
+ list.upsert(msg, 'prepend');
998
+ }
999
+ logger.debug({ messages: newMessages.length }, 'synced messages');
1000
+ });
1001
+ ev.on('contacts.upsert', contacts => {
1002
+ contactsUpsert(contacts);
1003
+ });
1004
+ ev.on('contacts.update', async (updates) => {
1005
+ var _a;
1006
+ for (const update of updates) {
1007
+ let contact;
1008
+ if (contacts[update.id]) {
1009
+ contact = contacts[update.id];
1010
+ }
1011
+ else {
1012
+ const contactHashes = await Promise.all(Object.keys(contacts).map(async (contactId) => {
1013
+ const { user } = (0, index_js_5.jidDecode)(contactId);
1014
+ return [contactId, (await (0, index_js_4.md5)(Buffer.from(user + 'WA_ADD_NOTIF', 'utf8'))).toString('base64').slice(0, 3)];
1015
+ }));
1016
+ contact = contacts[((_a = contactHashes.find(([, b]) => b === update.id)) === null || _a === void 0 ? void 0 : _a[0]) || '']; // find contact by attrs.hash, when user is not saved as a contact
1017
+ }
1018
+ if (contact) {
1019
+ if (update.imgUrl === 'changed') {
1020
+ contact.imgUrl = socket ? await (socket === null || socket === void 0 ? void 0 : socket.profilePictureUrl(contact.id)) : undefined;
1021
+ }
1022
+ else if (update.imgUrl === 'removed') {
1023
+ delete contact.imgUrl;
1024
+ }
1025
+ }
1026
+ else {
1027
+ return logger.debug({ update }, 'got update for non-existant contact');
1028
+ }
1029
+ Object.assign(contacts[contact.id], contact);
1030
+ }
1031
+ });
1032
+ ev.on('chats.upsert', newChats => {
1033
+ chats.upsert(...newChats);
1034
+ });
1035
+ ev.on('chats.update', updates => {
1036
+ for (let update of updates) {
1037
+ const result = chats.update(update.id, chat => {
1038
+ if (update.unreadCount > 0) {
1039
+ update = { ...update };
1040
+ update.unreadCount = (chat.unreadCount || 0) + update.unreadCount;
1041
+ }
1042
+ Object.assign(chat, update);
1043
+ });
1044
+ if (!result) {
1045
+ logger.debug({ update }, 'got update for non-existant chat');
1046
+ }
1047
+ }
1048
+ });
1049
+ ev.on('labels.edit', (label) => {
1050
+ if (label.deleted) {
1051
+ return labels.deleteById(label.id);
1052
+ }
1053
+ // WhatsApp can store only up to 20 labels
1054
+ if (labels.count() < 20) {
1055
+ return labels.upsertById(label.id, label);
1056
+ }
1057
+ logger.error('Labels count exceed');
1058
+ });
1059
+ ev.on('labels.association', ({ type, association }) => {
1060
+ switch (type) {
1061
+ case 'add':
1062
+ labelAssociations.upsert(association);
1063
+ break;
1064
+ case 'remove':
1065
+ labelAssociations.delete(association);
1066
+ break;
1067
+ default:
1068
+ console.error(`unknown operation type [${type}]`);
1069
+ }
1070
+ });
1071
+ ev.on('presence.update', ({ id, presences: update }) => {
1072
+ presences[id] = presences[id] || {};
1073
+ Object.assign(presences[id], update);
1074
+ });
1075
+ ev.on('chats.delete', deletions => {
1076
+ for (const item of deletions) {
1077
+ if (chats.get(item)) {
1078
+ chats.deleteById(item);
1079
+ }
1080
+ }
1081
+ });
1082
+ ev.on('messages.upsert', ({ messages: newMessages, type }) => {
1083
+ switch (type) {
1084
+ case 'append':
1085
+ case 'notify':
1086
+ for (const msg of newMessages) {
1087
+ const jid = (0, index_js_5.jidNormalizedUser)(msg.key.remoteJidAlt || msg.key.remoteJid);
1088
+ const list = assertMessageList(jid);
1089
+ list.upsert(msg, 'append');
1090
+ if (type === 'notify' && !chats.get(jid)) {
1091
+ ev.emit('chats.upsert', [
1092
+ {
1093
+ id: jid,
1094
+ conversationTimestamp: (0, index_js_4.toNumber)(msg.messageTimestamp),
1095
+ unreadCount: 1
1096
+ }
1097
+ ]);
1098
+ }
1099
+ }
1100
+ break;
1101
+ }
1102
+ });
1103
+ ev.on('messages.update', updates => {
1104
+ var _a;
1105
+ for (const { update, key } of updates) {
1106
+ const list = assertMessageList((0, index_js_5.jidNormalizedUser)(key.remoteJid));
1107
+ if (update === null || update === void 0 ? void 0 : update.status) {
1108
+ const listStatus = (_a = list.get(key.id)) === null || _a === void 0 ? void 0 : _a.status;
1109
+ if (listStatus && (update === null || update === void 0 ? void 0 : update.status) <= listStatus) {
1110
+ logger.debug({ update, storedStatus: listStatus }, 'status stored newer then update');
1111
+ delete update.status;
1112
+ logger.debug({ update }, 'new update object');
1113
+ }
1114
+ }
1115
+ const result = list.updateAssign(key.id, update);
1116
+ if (!result) {
1117
+ logger.debug({ update }, 'got update for non-existent message');
1118
+ }
1119
+ }
1120
+ });
1121
+ ev.on('messages.delete', item => {
1122
+ if ('all' in item) {
1123
+ const list = messages[item.jid];
1124
+ list === null || list === void 0 ? void 0 : list.clear();
1125
+ }
1126
+ else {
1127
+ const jid = item.keys[0].remoteJidAlt || item.keys[0].remoteJid;
1128
+ const list = messages[jid];
1129
+ if (list) {
1130
+ const idSet = new Set(item.keys.map(k => k.id));
1131
+ list.filter(m => !idSet.has(m.key.id));
1132
+ }
1133
+ }
1134
+ });
1135
+ ev.on('groups.update', updates => {
1136
+ for (const update of updates) {
1137
+ const id = update.id;
1138
+ if (groupMetadata[id]) {
1139
+ Object.assign(groupMetadata[id], update);
1140
+ }
1141
+ else {
1142
+ logger.debug({ update }, 'got update for non-existant group metadata');
1143
+ }
1144
+ }
1145
+ });
1146
+ ev.on('group-participants.update', ({ id, participants, action }) => {
1147
+ const metadata = groupMetadata[id];
1148
+ if (metadata) {
1149
+ switch (action) {
1150
+ case 'add':
1151
+ metadata.participants.push(...participants.map(participant => ({ id: participant.id, phoneNumber: participant.phoneNumber, admin: participant.admin })));
1152
+ break;
1153
+ case 'demote':
1154
+ case 'promote':
1155
+ for (const participant of metadata.participants) {
1156
+ for (const participantData of participants) {
1157
+ if (participantData.id === participant.id || participantData.phoneNumber === participant.phoneNumber) {
1158
+ participant.admin = action === 'promote' && 'admin';
1159
+ }
1160
+ }
1161
+ }
1162
+ break;
1163
+ case 'remove':
1164
+ const removeSet = new Set();
1165
+ for (const p of participants) {
1166
+ if (p.id)
1167
+ removeSet.add(p.id);
1168
+ if (p.phoneNumber)
1169
+ removeSet.add(p.phoneNumber);
1170
+ }
1171
+ metadata.participants = metadata.participants.reduce((acc, p) => {
1172
+ if (!removeSet.has(p.id) && !removeSet.has(p.phoneNumber))
1173
+ acc.push(p);
1174
+ return acc;
1175
+ }, []);
1176
+ break;
1177
+ }
1178
+ }
1179
+ });
1180
+ ev.on('message-receipt.update', updates => {
1181
+ for (const { key, receipt } of updates) {
1182
+ const obj = messages[key.remoteJidAlt || key.remoteJid];
1183
+ const msg = obj === null || obj === void 0 ? void 0 : obj.get(key.id);
1184
+ if (msg) {
1185
+ (0, index_js_4.updateMessageWithReceipt)(msg, receipt);
1186
+ }
1187
+ }
1188
+ });
1189
+ ev.on('messages.reaction', (reactions) => {
1190
+ for (const { key, reaction } of reactions) {
1191
+ const obj = messages[key.remoteJidAlt || key.remoteJid];
1192
+ const msg = obj === null || obj === void 0 ? void 0 : obj.get(key.id);
1193
+ if (msg) {
1194
+ (0, index_js_4.updateMessageWithReaction)(msg, reaction);
1195
+ }
1196
+ }
1197
+ });
1198
+ };
1199
+ const toJSON = () => ({
1200
+ chats,
1201
+ contacts,
1202
+ messages,
1203
+ labels,
1204
+ labelAssociations
1205
+ });
1206
+ const fromJSON = (json) => {
1207
+ chats.upsert(...json.chats);
1208
+ labelAssociations.upsert(...json.labelAssociations || []);
1209
+ contactsUpsert(Object.values(json.contacts));
1210
+ labelsUpsert(Object.values(json.labels || {}));
1211
+ for (const jid in json.messages) {
1212
+ const list = assertMessageList(jid);
1213
+ for (const msg of json.messages[jid]) {
1214
+ list.upsert(index_js_2.WAProto.WebMessageInfo.fromObject(msg), 'append');
1215
+ }
1216
+ }
1217
+ };
1218
+ return {
1219
+ chats,
1220
+ contacts,
1221
+ messages,
1222
+ groupMetadata,
1223
+ state,
1224
+ presences,
1225
+ labels,
1226
+ labelAssociations,
1227
+ bind,
1228
+ /** loads messages from the store, if not found -- uses the legacy connection */
1229
+ loadMessages: async (jid, count, cursor) => {
1230
+ const list = assertMessageList(jid);
1231
+ const mode = !cursor || 'before' in cursor ? 'before' : 'after';
1232
+ const cursorKey = !!cursor ? ('before' in cursor ? cursor.before : cursor.after) : undefined;
1233
+ const cursorValue = cursorKey ? list.get(cursorKey.id) : undefined;
1234
+ let messages;
1235
+ if (list && mode === 'before' && (!cursorKey || cursorValue)) {
1236
+ if (cursorValue) {
1237
+ const msgIdx = list.array.findIndex(m => m.key.id === (cursorKey === null || cursorKey === void 0 ? void 0 : cursorKey.id));
1238
+ messages = list.array.slice(0, msgIdx);
1239
+ }
1240
+ else {
1241
+ messages = list.array;
1242
+ }
1243
+ const diff = count - messages.length;
1244
+ if (diff < 0) {
1245
+ messages = messages.slice(-count); // get the last X messages
1246
+ }
1247
+ }
1248
+ else {
1249
+ messages = [];
1250
+ }
1251
+ return messages;
1252
+ },
1253
+ /**
1254
+ * Get all available labels for profile
1255
+ *
1256
+ * Keep in mind that the list is formed from predefined tags and tags
1257
+ * that were "caught" during their editing.
1258
+ */
1259
+ getLabels: () => {
1260
+ return labels;
1261
+ },
1262
+ /**
1263
+ * Get labels for chat
1264
+ *
1265
+ * @returns Label IDs
1266
+ **/
1267
+ getChatLabels: (chatId) => {
1268
+ return labelAssociations.filter((la) => la.chatId === chatId).all();
1269
+ },
1270
+ /**
1271
+ * Get labels for message
1272
+ *
1273
+ * @returns Label IDs
1274
+ **/
1275
+ getMessageLabels: (messageId) => {
1276
+ const associations = labelAssociations
1277
+ .filter((la) => la.messageId === messageId)
1278
+ .all();
1279
+ return associations.map(({ labelId }) => labelId);
1280
+ },
1281
+ loadMessage: async (jid, id) => { var _a; return (_a = messages[jid]) === null || _a === void 0 ? void 0 : _a.get(id); },
1282
+ mostRecentMessage: async (jid) => {
1283
+ var _a;
1284
+ const message = (_a = messages[jid]) === null || _a === void 0 ? void 0 : _a.array.slice(-1)[0];
1285
+ return message;
1286
+ },
1287
+ fetchImageUrl: async (jid, sock) => {
1288
+ const contact = contacts[jid];
1289
+ if (!contact) {
1290
+ return sock === null || sock === void 0 ? void 0 : sock.profilePictureUrl(jid);
1291
+ }
1292
+ if (typeof contact.imgUrl === 'undefined') {
1293
+ contact.imgUrl = await (sock === null || sock === void 0 ? void 0 : sock.profilePictureUrl(jid));
1294
+ }
1295
+ return contact.imgUrl;
1296
+ },
1297
+ fetchGroupMetadata: async (jid, sock) => {
1298
+ if (!groupMetadata[jid]) {
1299
+ const metadata = await (sock === null || sock === void 0 ? void 0 : sock.groupMetadata(jid));
1300
+ if (metadata) {
1301
+ groupMetadata[jid] = metadata;
1302
+ }
1303
+ }
1304
+ return groupMetadata[jid];
1305
+ },
1306
+ fetchMessageReceipts: async ({ remoteJid, id }) => {
1307
+ const list = messages[remoteJid];
1308
+ const msg = list === null || list === void 0 ? void 0 : list.get(id);
1309
+ return msg === null || msg === void 0 ? void 0 : msg.userReceipt;
1310
+ },
1311
+ toJSON,
1312
+ fromJSON,
1313
+ writeToFile: (path) => {
1314
+ (0, node_fs_1.writeFileSync)(path, JSON.stringify(toJSON()));
1315
+ },
1316
+ readFromFile: (path) => {
1317
+ if ((0, node_fs_1.existsSync)(path)) {
1318
+ logger.debug({ path }, 'reading from file');
1319
+ const jsonStr = (0, node_fs_1.readFileSync)(path, { encoding: 'utf-8' });
1320
+ const json = JSON.parse(jsonStr);
1321
+ fromJSON(json);
1322
+ }
1323
+ }
1324
+ };
1325
+ };
1326
+ exports.makeInMemoryStore = makeInMemoryStore;
1327
+
1328
+ return module.exports;
1329
+ })();
1330
+ for (const key of Object.keys(__kageModule141)) {
1331
+ if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule141[key]});
1332
+ }
1333
+ Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule141, configurable:true});