@msssystems/mss-link-sdk 0.2.6 → 0.2.8

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.
@@ -3,6 +3,7 @@ import type { WasmEncryptedMediaBytes } from '../modules/media/media-crypto.cont
3
3
  export interface MssLinkWasmClient extends WasmMssClient {
4
4
  sendMediaMessage(chatId: string, targetUserId: string, metadataJson: string, mediaAssetIds: string[]): Promise<string>;
5
5
  healSession(chatId: string, targetUserId: string): Promise<string>;
6
+ deleteSession(targetUserId: string): Promise<void>;
6
7
  }
7
8
  export type WasmMssClientConstructor = new (userId: string, deviceId: number, apiBaseUrl: string) => MssLinkWasmClient;
8
9
  export interface MssCryptoWasmModule {
@@ -9,4 +9,5 @@ export declare class ChatsClient {
9
9
  searchUsers(query: string): Promise<any>;
10
10
  archive(chatId: string): Promise<any>;
11
11
  hide(chatId: string): Promise<any>;
12
+ delete(chatId: string): Promise<any>;
12
13
  }
@@ -26,4 +26,7 @@ export class ChatsClient {
26
26
  async hide(chatId) {
27
27
  return this.http.post(`/link/v1/chats/${chatId}/hide`);
28
28
  }
29
+ async delete(chatId) {
30
+ return this.http.delete(`/link/v1/chats/${chatId}`);
31
+ }
29
32
  }
@@ -27,6 +27,7 @@ export class MessagesCryptoClient {
27
27
  }
28
28
  async handleSessionHealing(client, messages) {
29
29
  for (const message of messages) {
30
+ // Case 1: Decryption failed -> request peer to reset session
30
31
  if (message.deliveryState === 'FAILED' &&
31
32
  (message.plaintext === '[Ошибка дешифровки]' ||
32
33
  message.plaintext === '[Ошибка дешифровки]')) {
@@ -40,6 +41,17 @@ export class MessagesCryptoClient {
40
41
  console.error('[E2EE] Failed to heal session:', e);
41
42
  }
42
43
  }
44
+ // Case 2: Received SESSION_RESET request from peer -> clear local session state
45
+ if (message.kind === 'SYSTEM' &&
46
+ message.plaintext.includes('SESSION_RESET')) {
47
+ console.warn(`[E2EE] Received SESSION_RESET request from ${message.senderId}. Clearing local session state...`);
48
+ try {
49
+ await client.deleteSession(message.senderId);
50
+ }
51
+ catch (e) {
52
+ console.error('[E2EE] Failed to handle incoming SESSION_RESET:', e);
53
+ }
54
+ }
43
55
  }
44
56
  }
45
57
  async getLocalMessages(chatId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@msssystems/mss-link-sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Official managed application SDK for MSS ecosystem",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -77,7 +77,7 @@
77
77
  }
78
78
  },
79
79
  "devDependencies": {
80
- "@msssystems/mss-crypto-wasm": "^0.1.17",
80
+ "@msssystems/mss-crypto-wasm": "^0.1.21",
81
81
  "@nestjs/common": "^11.0.1",
82
82
  "@nestjs/core": "^11.0.1",
83
83
  "@types/express": "^5.0.0",