@msssystems/mss-link-sdk 0.2.14 → 0.2.16
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.
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { WasmMssClient } from '@msssystems/mss-crypto-wasm';
|
|
2
2
|
import type { WasmEncryptedMediaBytes } from '../modules/media/media-crypto.contracts';
|
|
3
|
+
import type { SenderKeyDistribution } from '../modules/messages/message.contracts';
|
|
3
4
|
export interface MssLinkWasmClient extends WasmMssClient {
|
|
4
5
|
sendMediaMessage(chatId: string, targetUserId: string, metadataJson: string, mediaAssetIds: string[]): Promise<string>;
|
|
5
6
|
healSession(chatId: string, targetUserId: string): Promise<string>;
|
|
6
7
|
deleteSession(targetUserId: string): Promise<void>;
|
|
7
|
-
getSenderKeyDistribution(groupId: string): Promise<
|
|
8
|
-
storeReceivedSenderKeyDistribution(distJson:
|
|
9
|
-
rotateGroupSenderKey(groupId: string): Promise<
|
|
8
|
+
getSenderKeyDistribution(groupId: string): Promise<SenderKeyDistribution | undefined>;
|
|
9
|
+
storeReceivedSenderKeyDistribution(distJson: SenderKeyDistribution): Promise<void>;
|
|
10
|
+
rotateGroupSenderKey(groupId: string): Promise<SenderKeyDistribution>;
|
|
11
|
+
hasReceivedSenderKey(groupId: string, senderId: string): Promise<boolean>;
|
|
12
|
+
encryptSenderKeyDistribution(recipientId: string, distJson: SenderKeyDistribution): Promise<string>;
|
|
13
|
+
decryptSenderKeyDistribution(senderId: string, encryptedBlob: string): Promise<SenderKeyDistribution>;
|
|
10
14
|
}
|
|
11
15
|
export type WasmMssClientConstructor = new (userId: string, deviceId: number, apiBaseUrl: string) => MssLinkWasmClient;
|
|
12
16
|
export interface MssCryptoWasmModule {
|
|
@@ -25,3 +25,29 @@ export interface DecryptedMessage {
|
|
|
25
25
|
createdAt: string;
|
|
26
26
|
updatedAt: string;
|
|
27
27
|
}
|
|
28
|
+
export interface SenderKeyState {
|
|
29
|
+
chain_key_b64: string;
|
|
30
|
+
signing_key_b64: string;
|
|
31
|
+
verifying_key_b64: string;
|
|
32
|
+
iteration: number;
|
|
33
|
+
}
|
|
34
|
+
export interface SenderKeyDistribution {
|
|
35
|
+
group_id: string;
|
|
36
|
+
sender_id: string;
|
|
37
|
+
chain_key_b64: string;
|
|
38
|
+
verifying_key_b64: string;
|
|
39
|
+
iteration: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ReceivedSenderKey {
|
|
42
|
+
group_id: string;
|
|
43
|
+
sender_id: string;
|
|
44
|
+
chain_key_b64: string;
|
|
45
|
+
verifying_key_b64: string;
|
|
46
|
+
iteration: number;
|
|
47
|
+
}
|
|
48
|
+
export interface SenderKeyMessage {
|
|
49
|
+
sender_id: string;
|
|
50
|
+
iteration: number;
|
|
51
|
+
ciphertext_b64: string;
|
|
52
|
+
signature_b64: string;
|
|
53
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WasmCryptoEngine } from '../../core/wasm-crypto-engine';
|
|
2
|
-
import type { DecryptedMessage } from './message.contracts';
|
|
2
|
+
import type { DecryptedMessage, SenderKeyDistribution } from './message.contracts';
|
|
3
3
|
export declare class MessagesCryptoClient {
|
|
4
4
|
private readonly engine;
|
|
5
5
|
private groupChatIds;
|
|
@@ -14,7 +14,10 @@ export declare class MessagesCryptoClient {
|
|
|
14
14
|
syncMessages(): Promise<void>;
|
|
15
15
|
private handleSessionHealing;
|
|
16
16
|
getLocalMessages(chatId: string): Promise<DecryptedMessage[]>;
|
|
17
|
-
getSenderKeyDistribution(groupId: string): Promise<
|
|
18
|
-
storeReceivedSenderKeyDistribution(distJson:
|
|
19
|
-
rotateGroupSenderKey(groupId: string): Promise<
|
|
17
|
+
getSenderKeyDistribution(groupId: string): Promise<SenderKeyDistribution | undefined>;
|
|
18
|
+
storeReceivedSenderKeyDistribution(distJson: SenderKeyDistribution): Promise<void>;
|
|
19
|
+
rotateGroupSenderKey(groupId: string): Promise<SenderKeyDistribution>;
|
|
20
|
+
hasReceivedSenderKey(groupId: string, senderId: string): Promise<boolean>;
|
|
21
|
+
encryptSenderKeyDistribution(recipientId: string, distJson: SenderKeyDistribution): Promise<string>;
|
|
22
|
+
decryptSenderKeyDistribution(senderId: string, encryptedBlob: string): Promise<SenderKeyDistribution>;
|
|
20
23
|
}
|
|
@@ -98,4 +98,31 @@ export class MessagesCryptoClient {
|
|
|
98
98
|
throw normalizeLocalCryptoError(error);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
async hasReceivedSenderKey(groupId, senderId) {
|
|
102
|
+
try {
|
|
103
|
+
await this.engine.ensureReady();
|
|
104
|
+
return this.engine.runWithClient((client) => client.hasReceivedSenderKey(groupId, senderId));
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw normalizeLocalCryptoError(error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async encryptSenderKeyDistribution(recipientId, distJson) {
|
|
111
|
+
try {
|
|
112
|
+
await this.engine.ensureReady();
|
|
113
|
+
return this.engine.runWithClient((client) => client.encryptSenderKeyDistribution(recipientId, distJson));
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw normalizeLocalCryptoError(error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async decryptSenderKeyDistribution(senderId, encryptedBlob) {
|
|
120
|
+
try {
|
|
121
|
+
await this.engine.ensureReady();
|
|
122
|
+
return this.engine.runWithClient((client) => client.decryptSenderKeyDistribution(senderId, encryptedBlob));
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw normalizeLocalCryptoError(error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
101
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@msssystems/mss-link-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
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.
|
|
80
|
+
"@msssystems/mss-crypto-wasm": "^0.1.29",
|
|
81
81
|
"@nestjs/common": "^11.0.1",
|
|
82
82
|
"@nestjs/core": "^11.0.1",
|
|
83
83
|
"@types/express": "^5.0.0",
|