@massalabs/gossip-sdk 0.0.2-dev.20260128173936 → 0.0.2-dev.20260129143909

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/dist/gossipSdk.js CHANGED
@@ -281,6 +281,8 @@ class GossipSdkImpl {
281
281
  this._discussion = new DiscussionService(db, this._announcement, session, serviceEvents);
282
282
  this._message = new MessageService(db, messageProtocol, session, this._discussion, serviceEvents, config);
283
283
  this._refresh = new RefreshService(db, this._message, session, serviceEvents);
284
+ // Publish gossip ID (public key) on messageProtocol so the user is discoverable
285
+ await this._auth.ensurePublicKeyPublished(session.ourPk, session.userIdEncoded);
284
286
  // Reset any messages stuck in SENDING status to FAILED
285
287
  // This handles app crash/close during message send
286
288
  await this.resetStuckSendingMessages(db);
@@ -23,7 +23,8 @@ export declare class AuthService {
23
23
  */
24
24
  fetchPublicKeyByUserId(userId: string): Promise<PublicKeyResult>;
25
25
  /**
26
- * Ensure public key is published (check first, then publish if needed)
26
+ * Ensure public key is published (check first, then publish if needed).
27
+ * If no user profile exists, the key is still published so the gossip ID is discoverable.
27
28
  * @param publicKeys - UserPublicKeys instance
28
29
  * @param userId - Bech32-encoded userId (e.g., "gossip1...")
29
30
  */
@@ -39,20 +39,25 @@ export class AuthService {
39
39
  }
40
40
  }
41
41
  /**
42
- * Ensure public key is published (check first, then publish if needed)
42
+ * Ensure public key is published (check first, then publish if needed).
43
+ * If no user profile exists, the key is still published so the gossip ID is discoverable.
43
44
  * @param publicKeys - UserPublicKeys instance
44
45
  * @param userId - Bech32-encoded userId (e.g., "gossip1...")
45
46
  */
46
47
  async ensurePublicKeyPublished(publicKeys, userId) {
47
48
  const profile = await this.db.userProfile.get(userId);
48
- if (!profile)
49
- throw new Error('User profile not found');
50
- const lastPush = profile.lastPublicKeyPush;
51
- if (lastPush && !moreThanOneWeekAgo(lastPush)) {
52
- return;
49
+ if (profile) {
50
+ const lastPush = profile.lastPublicKeyPush;
51
+ if (lastPush && !moreThanOneWeekAgo(lastPush)) {
52
+ return;
53
+ }
53
54
  }
54
55
  await this.messageProtocol.postPublicKey(encodeToBase64(publicKeys.to_bytes()));
55
- await this.db.userProfile.update(userId, { lastPublicKeyPush: new Date() });
56
+ if (profile) {
57
+ await this.db.userProfile.update(userId, {
58
+ lastPublicKeyPush: new Date(),
59
+ });
60
+ }
56
61
  }
57
62
  }
58
63
  const ONE_WEEK_IN_MILLIS = 7 * 24 * 60 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/gossip-sdk",
3
- "version": "0.0.2-dev.20260128173936",
3
+ "version": "0.0.2-dev.20260129143909",
4
4
  "description": "Gossip SDK for automation, chatbot, and integration use cases",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",