@agora-sdk/secure-chat-core 0.3.0 → 0.4.0
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/cjs/contract/index.d.ts +2 -150
- package/dist/cjs/contract/index.js +11 -10
- package/dist/cjs/contract/index.js.map +1 -1
- package/dist/cjs/transport/socket.d.ts +15 -3
- package/dist/cjs/transport/socket.js +4 -2
- package/dist/cjs/transport/socket.js.map +1 -1
- package/dist/esm/contract/index.d.ts +2 -150
- package/dist/esm/contract/index.js +11 -10
- package/dist/esm/contract/index.js.map +1 -1
- package/dist/esm/transport/socket.d.ts +15 -3
- package/dist/esm/transport/socket.js +4 -2
- package/dist/esm/transport/socket.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,150 +1,2 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
3
|
-
export type SecureHandshakeKind = "welcome" | "commit" | "proposal";
|
|
4
|
-
/** A Welcome targeted at the ONE device whose claimed KeyPackage was consumed. */
|
|
5
|
-
export interface WelcomeEnvelope {
|
|
6
|
-
targetDeviceId: string;
|
|
7
|
-
payload: string;
|
|
8
|
-
epoch: string;
|
|
9
|
-
}
|
|
10
|
-
/** A Commit/Proposal broadcast to the whole group (no target device). */
|
|
11
|
-
export interface HandshakeBlob {
|
|
12
|
-
payload: string;
|
|
13
|
-
epoch: string;
|
|
14
|
-
}
|
|
15
|
-
export interface RegisterDeviceBody {
|
|
16
|
-
deviceId: string;
|
|
17
|
-
displayName?: string | null;
|
|
18
|
-
signaturePublicKey: string;
|
|
19
|
-
credential: string;
|
|
20
|
-
ciphersuite: number;
|
|
21
|
-
}
|
|
22
|
-
export interface PublishKeyPackagesBody {
|
|
23
|
-
keyPackages: {
|
|
24
|
-
keyPackageRef: string;
|
|
25
|
-
keyPackage: string;
|
|
26
|
-
ciphersuite: number;
|
|
27
|
-
expiresAt?: string | null;
|
|
28
|
-
}[];
|
|
29
|
-
}
|
|
30
|
-
export interface CreateSecureConversationBody {
|
|
31
|
-
type: SecureConversationType;
|
|
32
|
-
mlsGroupId: string;
|
|
33
|
-
spaceId?: string | null;
|
|
34
|
-
name?: string | null;
|
|
35
|
-
memberUserIds?: string[];
|
|
36
|
-
welcomes?: WelcomeEnvelope[];
|
|
37
|
-
}
|
|
38
|
-
export interface AddSecureMemberBody {
|
|
39
|
-
userId: string;
|
|
40
|
-
commit: HandshakeBlob;
|
|
41
|
-
welcomes: WelcomeEnvelope[];
|
|
42
|
-
}
|
|
43
|
-
export interface RemoveSecureMemberBody {
|
|
44
|
-
commit: HandshakeBlob;
|
|
45
|
-
}
|
|
46
|
-
export interface SendSecureMessageBody {
|
|
47
|
-
ciphertext: string;
|
|
48
|
-
epoch: string;
|
|
49
|
-
senderDeviceId: string;
|
|
50
|
-
contentType?: string | null;
|
|
51
|
-
}
|
|
52
|
-
export interface UploadKeyBackupBody {
|
|
53
|
-
deviceId?: string | null;
|
|
54
|
-
blob: string;
|
|
55
|
-
nonce: string;
|
|
56
|
-
kdf: "argon2id" | "pbkdf2";
|
|
57
|
-
kdfParams: Record<string, unknown>;
|
|
58
|
-
cipher: "xchacha20poly1305" | "aes-256-gcm";
|
|
59
|
-
version: number;
|
|
60
|
-
}
|
|
61
|
-
export interface SecureDeviceModel {
|
|
62
|
-
id: string;
|
|
63
|
-
projectId: string;
|
|
64
|
-
userId: string;
|
|
65
|
-
deviceId: string;
|
|
66
|
-
displayName: string | null;
|
|
67
|
-
signaturePublicKey: string;
|
|
68
|
-
credential: string;
|
|
69
|
-
ciphersuite: number;
|
|
70
|
-
revokedAt: string | null;
|
|
71
|
-
lastSeenAt: string | null;
|
|
72
|
-
createdAt: string;
|
|
73
|
-
updatedAt: string;
|
|
74
|
-
}
|
|
75
|
-
export interface SecureKeyPackageClaim {
|
|
76
|
-
deviceId: string;
|
|
77
|
-
keyPackageRef: string;
|
|
78
|
-
keyPackage: string;
|
|
79
|
-
ciphersuite: number;
|
|
80
|
-
}
|
|
81
|
-
export interface SecureConversationMemberModel {
|
|
82
|
-
id: string;
|
|
83
|
-
projectId: string;
|
|
84
|
-
conversationId: string;
|
|
85
|
-
userId: string;
|
|
86
|
-
role: SecureMemberRole;
|
|
87
|
-
isActive: boolean;
|
|
88
|
-
joinedAtEpoch: string | null;
|
|
89
|
-
lastReadAt: string | null;
|
|
90
|
-
leftAt: string | null;
|
|
91
|
-
createdAt: string;
|
|
92
|
-
updatedAt: string;
|
|
93
|
-
}
|
|
94
|
-
export interface SecureConversationModel {
|
|
95
|
-
id: string;
|
|
96
|
-
projectId: string;
|
|
97
|
-
type: SecureConversationType;
|
|
98
|
-
mlsGroupId: string;
|
|
99
|
-
spaceId: string | null;
|
|
100
|
-
currentEpoch: string;
|
|
101
|
-
name: string | null;
|
|
102
|
-
createdById: string | null;
|
|
103
|
-
lastMessageAt: string | null;
|
|
104
|
-
memberCount?: number;
|
|
105
|
-
unreadCount?: number;
|
|
106
|
-
currentMember?: SecureConversationMemberModel;
|
|
107
|
-
createdAt: string;
|
|
108
|
-
updatedAt: string;
|
|
109
|
-
}
|
|
110
|
-
export interface SecureMessageModel {
|
|
111
|
-
id: string;
|
|
112
|
-
projectId: string;
|
|
113
|
-
conversationId: string;
|
|
114
|
-
senderUserId: string | null;
|
|
115
|
-
senderDeviceId: string | null;
|
|
116
|
-
epoch: string;
|
|
117
|
-
ciphertext: string;
|
|
118
|
-
contentType: string;
|
|
119
|
-
createdAt: string;
|
|
120
|
-
}
|
|
121
|
-
export interface SecureHandshakeModel {
|
|
122
|
-
id: string;
|
|
123
|
-
seq: string;
|
|
124
|
-
kind: SecureHandshakeKind;
|
|
125
|
-
conversationId: string;
|
|
126
|
-
epoch: string;
|
|
127
|
-
payload: string;
|
|
128
|
-
senderDeviceId: string | null;
|
|
129
|
-
targetDeviceId: string | null;
|
|
130
|
-
}
|
|
131
|
-
export interface SecureKeyBackupModel {
|
|
132
|
-
id: string;
|
|
133
|
-
projectId: string;
|
|
134
|
-
userId: string;
|
|
135
|
-
deviceId: string | null;
|
|
136
|
-
blob: string;
|
|
137
|
-
nonce: string;
|
|
138
|
-
kdf: string;
|
|
139
|
-
kdfParams: Record<string, unknown>;
|
|
140
|
-
cipher: string;
|
|
141
|
-
version: number;
|
|
142
|
-
createdAt: string;
|
|
143
|
-
updatedAt: string;
|
|
144
|
-
}
|
|
145
|
-
/** Standard error envelope: `{ error, code, field? }` with `secure-chat/*` codes. */
|
|
146
|
-
export interface SecureChatErrorBody {
|
|
147
|
-
error: string;
|
|
148
|
-
code: string;
|
|
149
|
-
field?: string;
|
|
150
|
-
}
|
|
1
|
+
export type { SecureDeviceModel, SecureKeyPackageClaim, SecureConversationMemberModel, SecureConversationModel, SecureMessageModel, SecureHandshakeModel, SecureKeyBackupModel, } from "@agora-server/contract";
|
|
2
|
+
export type { RegisterDeviceBody, PublishKeyPackagesBody, CreateSecureConversationBody, AddSecureMemberBody, RemoveSecureMemberBody, SendSecureMessageBody, UploadKeyBackupBody, WelcomeEnvelope, HandshakeBlob, } from "@agora-server/contract";
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Secure-chat wire
|
|
2
|
+
// Secure-chat wire types — re-exported from the published `@agora-server/contract` (Apache-2.0).
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// The dependency arrow is **SDK → contract**: agora-server owns the wire contract, this SDK depends
|
|
5
|
+
// on it. This module used to hold a byte-faithful *copy* of the types (a stand-in until the contract
|
|
6
|
+
// published); now that `@agora-server/contract` is published, it is a thin **type-only re-export** so
|
|
7
|
+
// there is exactly one source of truth and zero drift. The internal import path
|
|
8
|
+
// (`../contract/index.js`) is kept stable so call sites don't churn, and the re-export is scoped to
|
|
9
|
+
// the secure-chat surface (not the contract's reactions/pagination/etc.).
|
|
7
10
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// Do NOT publish a separate `@agora-sdk/secure-chat-contract` (that would invert the dependency —
|
|
11
|
-
// see STATUS.md). Do not let this copy drift in the meantime.
|
|
11
|
+
// Type-only on purpose: `@agora-server/contract` is ESM-only, but these `export type` re-exports are
|
|
12
|
+
// erased from the emitted JS, so core's dual ESM/CJS build never `require()`s it at runtime.
|
|
12
13
|
//
|
|
13
|
-
// Wire conventions: every binary value is **base64
|
|
14
|
-
//
|
|
14
|
+
// Wire conventions (owned by the contract): every binary value is **base64**; MLS epochs are
|
|
15
|
+
// **decimal strings** (u64 exceeds JS safe-int range).
|
|
15
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":";AAAA,iGAAiG;AACjG,EAAE;AACF,oGAAoG;AACpG,qGAAqG;AACrG,sGAAsG;AACtG,gFAAgF;AAChF,oGAAoG;AACpG,0EAA0E;AAC1E,EAAE;AACF,qGAAqG;AACrG,6FAA6F;AAC7F,EAAE;AACF,6FAA6F;AAC7F,uDAAuD"}
|
|
@@ -26,10 +26,22 @@ export interface SecureServerEvents {
|
|
|
26
26
|
userId: string;
|
|
27
27
|
}) => void;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Client → server events.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Payloads are **objects**, not bare ids — the server destructures `{ conversationId }` /
|
|
34
|
+
* `{ deviceId }` off the first argument (agora-server `realtime/secure-socket.ts`). Emitting a bare
|
|
35
|
+
* string lands as `undefined` after destructuring (and, on a `null` payload, throws server-side), so
|
|
36
|
+
* the join silently fails. Keep these shapes in lockstep with the server's `SecureClientToServerEvents`.
|
|
37
|
+
*/
|
|
30
38
|
export interface SecureClientEvents {
|
|
31
|
-
"join:secure-conversation": (
|
|
32
|
-
|
|
39
|
+
"join:secure-conversation": (payload: {
|
|
40
|
+
conversationId: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
"join:secure-device": (payload: {
|
|
43
|
+
deviceId: string;
|
|
44
|
+
}) => void;
|
|
33
45
|
}
|
|
34
46
|
/** A socket.io `Socket` typed with the secure-chat event maps in both directions. */
|
|
35
47
|
export type SecureSocket = Socket<SecureServerEvents, SecureClientEvents>;
|
|
@@ -46,11 +46,13 @@ class SecureChatSocketClient {
|
|
|
46
46
|
}
|
|
47
47
|
/** Join a conversation room (membership-gated server-side) to receive its broadcasts. */
|
|
48
48
|
joinConversation(conversationId) {
|
|
49
|
-
|
|
49
|
+
// Object payload — the server destructures `{ conversationId }`; a bare string would arrive as
|
|
50
|
+
// `undefined` and the join would silently no-op (see SecureClientEvents).
|
|
51
|
+
this.connect().emit("join:secure-conversation", { conversationId });
|
|
50
52
|
}
|
|
51
53
|
/** Explicitly join a device room (ownership-verified). Owned devices auto-join on connect. */
|
|
52
54
|
joinDevice(deviceId) {
|
|
53
|
-
this.connect().emit("join:secure-device", deviceId);
|
|
55
|
+
this.connect().emit("join:secure-device", { deviceId });
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Subscribe to a server → client event, auto-connecting if needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/transport/socket.ts"],"names":[],"mappings":";AAAA,8FAA8F;AAC9F,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,8FAA8F;AAC9F,kCAAkC;;;AAElC,uDAA8C;
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/transport/socket.ts"],"names":[],"mappings":";AAAA,8FAA8F;AAC9F,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,8FAA8F;AAC9F,kCAAkC;;;AAElC,uDAA8C;AA6C9C;;;;GAIG;AACH,MAAa,sBAAsB;IAGjC,YAA6B,MAA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;QAC7E,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QACzB,4FAA4F;QAC5F,CAAC,CAAC,EAAE,CAAC,KAAc,EAAE,OAAgB,CAAC,CAAC;QACvC,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAc,EAAE,OAAgB,CAAC,CAAC;IACvD,CAAC;CACF;AA1DD,wDA0DC"}
|
|
@@ -1,150 +1,2 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
3
|
-
export type SecureHandshakeKind = "welcome" | "commit" | "proposal";
|
|
4
|
-
/** A Welcome targeted at the ONE device whose claimed KeyPackage was consumed. */
|
|
5
|
-
export interface WelcomeEnvelope {
|
|
6
|
-
targetDeviceId: string;
|
|
7
|
-
payload: string;
|
|
8
|
-
epoch: string;
|
|
9
|
-
}
|
|
10
|
-
/** A Commit/Proposal broadcast to the whole group (no target device). */
|
|
11
|
-
export interface HandshakeBlob {
|
|
12
|
-
payload: string;
|
|
13
|
-
epoch: string;
|
|
14
|
-
}
|
|
15
|
-
export interface RegisterDeviceBody {
|
|
16
|
-
deviceId: string;
|
|
17
|
-
displayName?: string | null;
|
|
18
|
-
signaturePublicKey: string;
|
|
19
|
-
credential: string;
|
|
20
|
-
ciphersuite: number;
|
|
21
|
-
}
|
|
22
|
-
export interface PublishKeyPackagesBody {
|
|
23
|
-
keyPackages: {
|
|
24
|
-
keyPackageRef: string;
|
|
25
|
-
keyPackage: string;
|
|
26
|
-
ciphersuite: number;
|
|
27
|
-
expiresAt?: string | null;
|
|
28
|
-
}[];
|
|
29
|
-
}
|
|
30
|
-
export interface CreateSecureConversationBody {
|
|
31
|
-
type: SecureConversationType;
|
|
32
|
-
mlsGroupId: string;
|
|
33
|
-
spaceId?: string | null;
|
|
34
|
-
name?: string | null;
|
|
35
|
-
memberUserIds?: string[];
|
|
36
|
-
welcomes?: WelcomeEnvelope[];
|
|
37
|
-
}
|
|
38
|
-
export interface AddSecureMemberBody {
|
|
39
|
-
userId: string;
|
|
40
|
-
commit: HandshakeBlob;
|
|
41
|
-
welcomes: WelcomeEnvelope[];
|
|
42
|
-
}
|
|
43
|
-
export interface RemoveSecureMemberBody {
|
|
44
|
-
commit: HandshakeBlob;
|
|
45
|
-
}
|
|
46
|
-
export interface SendSecureMessageBody {
|
|
47
|
-
ciphertext: string;
|
|
48
|
-
epoch: string;
|
|
49
|
-
senderDeviceId: string;
|
|
50
|
-
contentType?: string | null;
|
|
51
|
-
}
|
|
52
|
-
export interface UploadKeyBackupBody {
|
|
53
|
-
deviceId?: string | null;
|
|
54
|
-
blob: string;
|
|
55
|
-
nonce: string;
|
|
56
|
-
kdf: "argon2id" | "pbkdf2";
|
|
57
|
-
kdfParams: Record<string, unknown>;
|
|
58
|
-
cipher: "xchacha20poly1305" | "aes-256-gcm";
|
|
59
|
-
version: number;
|
|
60
|
-
}
|
|
61
|
-
export interface SecureDeviceModel {
|
|
62
|
-
id: string;
|
|
63
|
-
projectId: string;
|
|
64
|
-
userId: string;
|
|
65
|
-
deviceId: string;
|
|
66
|
-
displayName: string | null;
|
|
67
|
-
signaturePublicKey: string;
|
|
68
|
-
credential: string;
|
|
69
|
-
ciphersuite: number;
|
|
70
|
-
revokedAt: string | null;
|
|
71
|
-
lastSeenAt: string | null;
|
|
72
|
-
createdAt: string;
|
|
73
|
-
updatedAt: string;
|
|
74
|
-
}
|
|
75
|
-
export interface SecureKeyPackageClaim {
|
|
76
|
-
deviceId: string;
|
|
77
|
-
keyPackageRef: string;
|
|
78
|
-
keyPackage: string;
|
|
79
|
-
ciphersuite: number;
|
|
80
|
-
}
|
|
81
|
-
export interface SecureConversationMemberModel {
|
|
82
|
-
id: string;
|
|
83
|
-
projectId: string;
|
|
84
|
-
conversationId: string;
|
|
85
|
-
userId: string;
|
|
86
|
-
role: SecureMemberRole;
|
|
87
|
-
isActive: boolean;
|
|
88
|
-
joinedAtEpoch: string | null;
|
|
89
|
-
lastReadAt: string | null;
|
|
90
|
-
leftAt: string | null;
|
|
91
|
-
createdAt: string;
|
|
92
|
-
updatedAt: string;
|
|
93
|
-
}
|
|
94
|
-
export interface SecureConversationModel {
|
|
95
|
-
id: string;
|
|
96
|
-
projectId: string;
|
|
97
|
-
type: SecureConversationType;
|
|
98
|
-
mlsGroupId: string;
|
|
99
|
-
spaceId: string | null;
|
|
100
|
-
currentEpoch: string;
|
|
101
|
-
name: string | null;
|
|
102
|
-
createdById: string | null;
|
|
103
|
-
lastMessageAt: string | null;
|
|
104
|
-
memberCount?: number;
|
|
105
|
-
unreadCount?: number;
|
|
106
|
-
currentMember?: SecureConversationMemberModel;
|
|
107
|
-
createdAt: string;
|
|
108
|
-
updatedAt: string;
|
|
109
|
-
}
|
|
110
|
-
export interface SecureMessageModel {
|
|
111
|
-
id: string;
|
|
112
|
-
projectId: string;
|
|
113
|
-
conversationId: string;
|
|
114
|
-
senderUserId: string | null;
|
|
115
|
-
senderDeviceId: string | null;
|
|
116
|
-
epoch: string;
|
|
117
|
-
ciphertext: string;
|
|
118
|
-
contentType: string;
|
|
119
|
-
createdAt: string;
|
|
120
|
-
}
|
|
121
|
-
export interface SecureHandshakeModel {
|
|
122
|
-
id: string;
|
|
123
|
-
seq: string;
|
|
124
|
-
kind: SecureHandshakeKind;
|
|
125
|
-
conversationId: string;
|
|
126
|
-
epoch: string;
|
|
127
|
-
payload: string;
|
|
128
|
-
senderDeviceId: string | null;
|
|
129
|
-
targetDeviceId: string | null;
|
|
130
|
-
}
|
|
131
|
-
export interface SecureKeyBackupModel {
|
|
132
|
-
id: string;
|
|
133
|
-
projectId: string;
|
|
134
|
-
userId: string;
|
|
135
|
-
deviceId: string | null;
|
|
136
|
-
blob: string;
|
|
137
|
-
nonce: string;
|
|
138
|
-
kdf: string;
|
|
139
|
-
kdfParams: Record<string, unknown>;
|
|
140
|
-
cipher: string;
|
|
141
|
-
version: number;
|
|
142
|
-
createdAt: string;
|
|
143
|
-
updatedAt: string;
|
|
144
|
-
}
|
|
145
|
-
/** Standard error envelope: `{ error, code, field? }` with `secure-chat/*` codes. */
|
|
146
|
-
export interface SecureChatErrorBody {
|
|
147
|
-
error: string;
|
|
148
|
-
code: string;
|
|
149
|
-
field?: string;
|
|
150
|
-
}
|
|
1
|
+
export type { SecureDeviceModel, SecureKeyPackageClaim, SecureConversationMemberModel, SecureConversationModel, SecureMessageModel, SecureHandshakeModel, SecureKeyBackupModel, } from "@agora-server/contract";
|
|
2
|
+
export type { RegisterDeviceBody, PublishKeyPackagesBody, CreateSecureConversationBody, AddSecureMemberBody, RemoveSecureMemberBody, SendSecureMessageBody, UploadKeyBackupBody, WelcomeEnvelope, HandshakeBlob, } from "@agora-server/contract";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
// Secure-chat wire
|
|
1
|
+
// Secure-chat wire types — re-exported from the published `@agora-server/contract` (Apache-2.0).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// The dependency arrow is **SDK → contract**: agora-server owns the wire contract, this SDK depends
|
|
4
|
+
// on it. This module used to hold a byte-faithful *copy* of the types (a stand-in until the contract
|
|
5
|
+
// published); now that `@agora-server/contract` is published, it is a thin **type-only re-export** so
|
|
6
|
+
// there is exactly one source of truth and zero drift. The internal import path
|
|
7
|
+
// (`../contract/index.js`) is kept stable so call sites don't churn, and the re-export is scoped to
|
|
8
|
+
// the secure-chat surface (not the contract's reactions/pagination/etc.).
|
|
6
9
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// Do NOT publish a separate `@agora-sdk/secure-chat-contract` (that would invert the dependency —
|
|
10
|
-
// see STATUS.md). Do not let this copy drift in the meantime.
|
|
10
|
+
// Type-only on purpose: `@agora-server/contract` is ESM-only, but these `export type` re-exports are
|
|
11
|
+
// erased from the emitted JS, so core's dual ESM/CJS build never `require()`s it at runtime.
|
|
11
12
|
//
|
|
12
|
-
// Wire conventions: every binary value is **base64
|
|
13
|
-
//
|
|
13
|
+
// Wire conventions (owned by the contract): every binary value is **base64**; MLS epochs are
|
|
14
|
+
// **decimal strings** (u64 exceeds JS safe-int range).
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,EAAE;AACF,oGAAoG;AACpG,qGAAqG;AACrG,sGAAsG;AACtG,gFAAgF;AAChF,oGAAoG;AACpG,0EAA0E;AAC1E,EAAE;AACF,qGAAqG;AACrG,6FAA6F;AAC7F,EAAE;AACF,6FAA6F;AAC7F,uDAAuD"}
|
|
@@ -26,10 +26,22 @@ export interface SecureServerEvents {
|
|
|
26
26
|
userId: string;
|
|
27
27
|
}) => void;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Client → server events.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Payloads are **objects**, not bare ids — the server destructures `{ conversationId }` /
|
|
34
|
+
* `{ deviceId }` off the first argument (agora-server `realtime/secure-socket.ts`). Emitting a bare
|
|
35
|
+
* string lands as `undefined` after destructuring (and, on a `null` payload, throws server-side), so
|
|
36
|
+
* the join silently fails. Keep these shapes in lockstep with the server's `SecureClientToServerEvents`.
|
|
37
|
+
*/
|
|
30
38
|
export interface SecureClientEvents {
|
|
31
|
-
"join:secure-conversation": (
|
|
32
|
-
|
|
39
|
+
"join:secure-conversation": (payload: {
|
|
40
|
+
conversationId: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
"join:secure-device": (payload: {
|
|
43
|
+
deviceId: string;
|
|
44
|
+
}) => void;
|
|
33
45
|
}
|
|
34
46
|
/** A socket.io `Socket` typed with the secure-chat event maps in both directions. */
|
|
35
47
|
export type SecureSocket = Socket<SecureServerEvents, SecureClientEvents>;
|
|
@@ -43,11 +43,13 @@ export class SecureChatSocketClient {
|
|
|
43
43
|
}
|
|
44
44
|
/** Join a conversation room (membership-gated server-side) to receive its broadcasts. */
|
|
45
45
|
joinConversation(conversationId) {
|
|
46
|
-
|
|
46
|
+
// Object payload — the server destructures `{ conversationId }`; a bare string would arrive as
|
|
47
|
+
// `undefined` and the join would silently no-op (see SecureClientEvents).
|
|
48
|
+
this.connect().emit("join:secure-conversation", { conversationId });
|
|
47
49
|
}
|
|
48
50
|
/** Explicitly join a device room (ownership-verified). Owned devices auto-join on connect. */
|
|
49
51
|
joinDevice(deviceId) {
|
|
50
|
-
this.connect().emit("join:secure-device", deviceId);
|
|
52
|
+
this.connect().emit("join:secure-device", { deviceId });
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* Subscribe to a server → client event, auto-connecting if needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/transport/socket.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,8FAA8F;AAC9F,kCAAkC;AAElC,OAAO,EAAE,EAAE,EAAU,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../../src/transport/socket.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,8FAA8F;AAC9F,kCAAkC;AAElC,OAAO,EAAE,EAAE,EAAU,MAAM,kBAAkB,CAAC;AA6C9C;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YAA6B,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;QAFnD,WAAM,GAAwB,IAAI,CAAC;IAEmB,CAAC;IAE/D;;;;OAIG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,MAAM,EAAE,SAAS;YAAE,OAAO,IAAI,CAAC,MAAM,CAAC;Q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AAE,OAAgB,CAAC,CAAC;IACvD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agora-sdk/secure-chat-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Agora SDK Plus, maintained by Jenova Marie",
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@agora-server/contract": "^0.9.3",
|
|
38
39
|
"axios": "^1.4.0",
|
|
39
40
|
"socket.io-client": "^4.8.1",
|
|
40
|
-
"@agora-sdk/secure-chat-crypto": "0.
|
|
41
|
+
"@agora-sdk/secure-chat-crypto": "0.4.0"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@agora-sdk/core": "^1.2.2",
|