shogun-core 3.2.1 → 3.2.2

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.
@@ -259,7 +259,7 @@ class SHIP_01 {
259
259
  messageId: messageId
260
260
  };
261
261
  // Salva sul nodo globale 'messages' per permettere il listener
262
- await this.shogun.db.gun.get('messages').get(messageId).put(messageData).then();
262
+ await this.shogun.db.gun.get(SHIP_01.NODES.MESSAGES).get(messageId).put(messageData).then();
263
263
  console.log(`✅ Messaggio salvato: ${messageId}`);
264
264
  return {
265
265
  success: true,
@@ -323,7 +323,7 @@ class SHIP_01 {
323
323
  const receivedMessages = new Set();
324
324
  // Ascolta messaggi in tempo reale su GunDB
325
325
  this.shogun.db.gun
326
- .get(`messages`)
326
+ .get(SHIP_01.NODES.MESSAGES)
327
327
  .map()
328
328
  .on(async (data, key) => {
329
329
  // Filtra solo i messaggi destinati a questo utente (per username)
@@ -417,7 +417,7 @@ class SHIP_01 {
417
417
  return new Promise((resolve) => {
418
418
  const messages = [];
419
419
  let messageCount = 0;
420
- this.shogun.db.gun.get('messages').map().once(async (msgData, messageId) => {
420
+ this.shogun.db.gun.get(SHIP_01.NODES.MESSAGES).map().once(async (msgData, messageId) => {
421
421
  // Skip metadata fields
422
422
  if (!msgData || typeof msgData !== 'object' || messageId === '_') {
423
423
  return;
@@ -430,8 +430,9 @@ class SHIP_01 {
430
430
  });
431
431
  try {
432
432
  // Check if message is part of this conversation
433
- const isSentToTarget = msgData.from === userPub && msgData.to === withUsername;
434
- const isReceivedFromTarget = msgData.to === username && msgData.from === otherUserPub;
433
+ // Fixed: Handle both username and userPub in matching
434
+ const isSentToTarget = msgData.from === userPub && (msgData.to === withUsername || msgData.to === otherUserPub);
435
+ const isReceivedFromTarget = (msgData.to === username || msgData.to === userPub) && msgData.from === otherUserPub;
435
436
  console.log(`[SHIP-01] Message ${messageId} match:`, {
436
437
  isSentToTarget,
437
438
  isReceivedFromTarget,
@@ -508,6 +509,12 @@ class SHIP_01 {
508
509
  }
509
510
  }
510
511
  exports.SHIP_01 = SHIP_01;
512
+ // GunDB Node Names - Constants for clarity
513
+ SHIP_01.NODES = {
514
+ MESSAGES: 'messages',
515
+ USERS: 'users',
516
+ PUBLIC_KEYS: 'publicKeys'
517
+ };
511
518
  // ============================================================================
512
519
  // 8. ESEMPIO D'USO COMPLETO
513
520
  // ============================================================================
@@ -29,6 +29,7 @@ import { ISEAPair } from "../../src/types/shogun";
29
29
  */
30
30
  declare class SHIP_01 implements ISHIP_01 {
31
31
  private shogun;
32
+ private static readonly NODES;
32
33
  constructor(shogunConfig: ShogunCoreConfig);
33
34
  /**
34
35
  * Registra un nuovo utente
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shogun-core",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "SHOGUN CORE - Core library for Shogun Ecosystem",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",