@msssystems/mss-link-sdk 0.2.8 → 0.2.11

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.
@@ -4,6 +4,9 @@ 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
6
  deleteSession(targetUserId: string): Promise<void>;
7
+ getSenderKeyDistribution(groupId: string): Promise<any>;
8
+ storeReceivedSenderKeyDistribution(distJson: any): Promise<void>;
9
+ rotateGroupSenderKey(groupId: string): Promise<any>;
7
10
  }
8
11
  export type WasmMssClientConstructor = new (userId: string, deviceId: number, apiBaseUrl: string) => MssLinkWasmClient;
9
12
  export interface MssCryptoWasmModule {
@@ -2,7 +2,9 @@ import { WasmCryptoEngine } from '../../core/wasm-crypto-engine';
2
2
  import type { DecryptedMessage } from './message.contracts';
3
3
  export declare class MessagesCryptoClient {
4
4
  private readonly engine;
5
+ private groupChatIds;
5
6
  constructor(engine: WasmCryptoEngine);
7
+ setGroupChatIds(chatIds: string[]): void;
6
8
  sendMessage(params: {
7
9
  chatId: string;
8
10
  targetUserId: string;
@@ -12,4 +14,7 @@ export declare class MessagesCryptoClient {
12
14
  syncMessages(): Promise<void>;
13
15
  private handleSessionHealing;
14
16
  getLocalMessages(chatId: string): Promise<DecryptedMessage[]>;
17
+ getSenderKeyDistribution(groupId: string): Promise<any>;
18
+ storeReceivedSenderKeyDistribution(distJson: any): Promise<void>;
19
+ rotateGroupSenderKey(groupId: string): Promise<any>;
15
20
  }
@@ -2,9 +2,13 @@ import { normalizeLocalCryptoError } from '../../errors/decryption-errors';
2
2
  import { mapLocalSdkMessage } from './message.mapper';
3
3
  export class MessagesCryptoClient {
4
4
  engine;
5
+ groupChatIds = new Set();
5
6
  constructor(engine) {
6
7
  this.engine = engine;
7
8
  }
9
+ setGroupChatIds(chatIds) {
10
+ this.groupChatIds = new Set(chatIds);
11
+ }
8
12
  async sendMessage(params) {
9
13
  try {
10
14
  await this.engine.ensureReady();
@@ -33,6 +37,8 @@ export class MessagesCryptoClient {
33
37
  message.plaintext === '[Ошибка дешифровки]')) {
34
38
  if (message.kind === 'SYSTEM')
35
39
  continue;
40
+ if (this.groupChatIds.has(message.chatId))
41
+ continue;
36
42
  console.warn(`[E2EE] Decryption failed for message ${message.messageId} from ${message.senderId}. Triggering auto-heal...`);
37
43
  try {
38
44
  await client.healSession(message.chatId, message.senderId);
@@ -65,4 +71,31 @@ export class MessagesCryptoClient {
65
71
  throw normalizeLocalCryptoError(error);
66
72
  }
67
73
  }
74
+ async getSenderKeyDistribution(groupId) {
75
+ try {
76
+ await this.engine.ensureReady();
77
+ return this.engine.runWithClient((client) => client.getSenderKeyDistribution(groupId));
78
+ }
79
+ catch (error) {
80
+ throw normalizeLocalCryptoError(error);
81
+ }
82
+ }
83
+ async storeReceivedSenderKeyDistribution(distJson) {
84
+ try {
85
+ await this.engine.ensureReady();
86
+ return this.engine.runWithClient((client) => client.storeReceivedSenderKeyDistribution(distJson));
87
+ }
88
+ catch (error) {
89
+ throw normalizeLocalCryptoError(error);
90
+ }
91
+ }
92
+ async rotateGroupSenderKey(groupId) {
93
+ try {
94
+ await this.engine.ensureReady();
95
+ return this.engine.runWithClient((client) => client.rotateGroupSenderKey(groupId));
96
+ }
97
+ catch (error) {
98
+ throw normalizeLocalCryptoError(error);
99
+ }
100
+ }
68
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@msssystems/mss-link-sdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.11",
4
4
  "description": "Official managed application SDK for MSS ecosystem",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,7 +53,7 @@
53
53
  "registry": "https://registry.npmjs.org/"
54
54
  },
55
55
  "peerDependencies": {
56
- "@msssystems/mss-crypto-wasm": "^0.1.17",
56
+ "@msssystems/mss-crypto-wasm": "^0.1.25",
57
57
  "@nestjs/common": "^10.0.0 || ^11.0.0",
58
58
  "@nestjs/core": "^10.0.0 || ^11.0.0",
59
59
  "express": "^4.0.0 || ^5.0.0",
@@ -77,7 +77,7 @@
77
77
  }
78
78
  },
79
79
  "devDependencies": {
80
- "@msssystems/mss-crypto-wasm": "^0.1.21",
80
+ "@msssystems/mss-crypto-wasm": "^0.1.25",
81
81
  "@nestjs/common": "^11.0.1",
82
82
  "@nestjs/core": "^11.0.1",
83
83
  "@types/express": "^5.0.0",
@@ -90,8 +90,5 @@
90
90
  "engines": {
91
91
  "node": ">=20.0.0"
92
92
  },
93
- "packageManager": "yarn@4.14.1",
94
- "dependencies": {
95
- "repomix": "^1.14.1"
96
- }
93
+ "packageManager": "yarn@4.14.1"
97
94
  }