@vex-chat/libvex 7.3.0 → 8.0.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/Client.d.ts +59 -43
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +244 -657
- package/dist/Client.js.map +1 -1
- package/dist/codecs.d.ts +18 -0
- package/dist/codecs.d.ts.map +1 -1
- package/dist/codecs.js +4 -1
- package/dist/codecs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Client.ts +366 -859
- package/src/__tests__/harness/shared-suite.ts +1 -80
- package/src/codecs.ts +8 -0
- package/src/index.ts +9 -0
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* - `LIBVEX_DEBUG_DM=1` — logs DM/X3dh paths in `Client` to stderr (remove / gate off when done).
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import type {
|
|
30
|
+
import type { ClientOptions, Message } from "../../index.js";
|
|
31
31
|
import type { Storage } from "../../Storage.js";
|
|
32
32
|
|
|
33
33
|
import { getCryptoProfile, setCryptoProfile } from "@vex-chat/crypto";
|
|
@@ -117,64 +117,6 @@ export function platformSuite(
|
|
|
117
117
|
expect(msg.extra).toBe(extra);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
test("encrypted call invite arrives as call event", async () => {
|
|
121
|
-
class NativeIceCandidate {
|
|
122
|
-
toJSON() {
|
|
123
|
-
return {
|
|
124
|
-
candidate: "candidate-test",
|
|
125
|
-
sdpMid: "0",
|
|
126
|
-
sdpMLineIndex: 0,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
class NativeSessionDescription {
|
|
131
|
-
toJSON() {
|
|
132
|
-
return { sdp: "test-offer", type: "offer" };
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const me = client.me.user();
|
|
137
|
-
let unexpectedMessages = 0;
|
|
138
|
-
const onMessage = (_msg: Message) => {
|
|
139
|
-
unexpectedMessages += 1;
|
|
140
|
-
};
|
|
141
|
-
client.on("message", onMessage);
|
|
142
|
-
try {
|
|
143
|
-
const callPromise = waitForCall(
|
|
144
|
-
client,
|
|
145
|
-
(event) =>
|
|
146
|
-
event.action === "invite" &&
|
|
147
|
-
event.fromDeviceID === client.me.device().deviceID,
|
|
148
|
-
`[${platformName}] encrypted self-call invite`,
|
|
149
|
-
);
|
|
150
|
-
const returned = await client.calls.startDM(me.userID, {
|
|
151
|
-
candidate: new NativeIceCandidate(),
|
|
152
|
-
description: new NativeSessionDescription(),
|
|
153
|
-
kind: "offer",
|
|
154
|
-
});
|
|
155
|
-
const incoming = await callPromise;
|
|
156
|
-
expect(returned.call.callID).toBe(incoming.call.callID);
|
|
157
|
-
expect(incoming.signal?.kind).toBe("offer");
|
|
158
|
-
expect(incoming.signal?.candidate).toEqual({
|
|
159
|
-
candidate: "candidate-test",
|
|
160
|
-
sdpMid: "0",
|
|
161
|
-
sdpMLineIndex: 0,
|
|
162
|
-
});
|
|
163
|
-
expect(incoming.signal?.description).toEqual({
|
|
164
|
-
sdp: "test-offer",
|
|
165
|
-
type: "offer",
|
|
166
|
-
});
|
|
167
|
-
expect(unexpectedMessages).toBe(0);
|
|
168
|
-
|
|
169
|
-
const active = await client.calls.active();
|
|
170
|
-
expect(
|
|
171
|
-
active.some((call) => call.callID === incoming.call.callID),
|
|
172
|
-
).toBe(true);
|
|
173
|
-
} finally {
|
|
174
|
-
client.off("message", onMessage);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
120
|
test("message history retrieve + delete", async () => {
|
|
179
121
|
const me = client.me.user();
|
|
180
122
|
const body = "history-test";
|
|
@@ -779,27 +721,6 @@ async function e2eWaitForPeerDeviceCount(
|
|
|
779
721
|
}
|
|
780
722
|
*/
|
|
781
723
|
|
|
782
|
-
async function waitForCall(
|
|
783
|
-
c: Client,
|
|
784
|
-
predicate: (event: CallEvent) => boolean,
|
|
785
|
-
label: string,
|
|
786
|
-
timeout = 10_000,
|
|
787
|
-
): Promise<CallEvent> {
|
|
788
|
-
return new Promise((resolve, reject) => {
|
|
789
|
-
const timer = setTimeout(() => {
|
|
790
|
-
reject(new Error(`${label} call timed out`));
|
|
791
|
-
}, timeout);
|
|
792
|
-
const onCall = (event: CallEvent) => {
|
|
793
|
-
if (predicate(event)) {
|
|
794
|
-
clearTimeout(timer);
|
|
795
|
-
c.off("call", onCall);
|
|
796
|
-
resolve(event);
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
c.on("call", onCall);
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
|
|
803
724
|
async function waitForMessage(
|
|
804
725
|
c: Client,
|
|
805
726
|
predicate: (m: Message) => boolean,
|
package/src/codecs.ts
CHANGED
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* For trust boundary validation, use codec.decodeSafe() directly.
|
|
15
15
|
*/
|
|
16
16
|
import {
|
|
17
|
+
AccountEntitlementsSchema,
|
|
17
18
|
ActionTokenSchema,
|
|
19
|
+
BillingAccountStateSchema,
|
|
20
|
+
BillingProductSchema,
|
|
18
21
|
ChannelSchema,
|
|
19
22
|
DeviceSchema,
|
|
20
23
|
EmojiSchema,
|
|
@@ -43,6 +46,8 @@ export const InviteCodec = createCodec(InviteSchema);
|
|
|
43
46
|
export const EmojiCodec = createCodec(EmojiSchema);
|
|
44
47
|
export const FileSQLCodec = createCodec(FileSQLSchema);
|
|
45
48
|
export const ActionTokenCodec = createCodec(ActionTokenSchema);
|
|
49
|
+
export const AccountEntitlementsCodec = createCodec(AccountEntitlementsSchema);
|
|
50
|
+
export const BillingAccountStateCodec = createCodec(BillingAccountStateSchema);
|
|
46
51
|
export const KeyBundleCodec = createCodec(KeyBundleSchema);
|
|
47
52
|
|
|
48
53
|
// ── Array codecs ────────────────────────────────────────────────────────────
|
|
@@ -57,6 +62,9 @@ export const EmojiArrayCodec = createCodec(z.array(EmojiSchema));
|
|
|
57
62
|
export const ServerChannelBootstrapCodec = createCodec(
|
|
58
63
|
ServerChannelBootstrapSchema,
|
|
59
64
|
);
|
|
65
|
+
export const BillingProductArrayCodec = createCodec(
|
|
66
|
+
z.array(BillingProductSchema),
|
|
67
|
+
);
|
|
60
68
|
|
|
61
69
|
// ── Inline ad-hoc response codecs ───────────────────────────────────────────
|
|
62
70
|
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type {
|
|
|
15
15
|
DeviceRegistrationResult,
|
|
16
16
|
Devices,
|
|
17
17
|
Emojis,
|
|
18
|
+
Entitlements,
|
|
18
19
|
FileProgress,
|
|
19
20
|
FileRes,
|
|
20
21
|
Files,
|
|
@@ -98,11 +99,19 @@ export type {
|
|
|
98
99
|
} from "./types/index.js";
|
|
99
100
|
// Re-export app-facing types
|
|
100
101
|
export type {
|
|
102
|
+
AccountEntitlements,
|
|
103
|
+
AccountTier,
|
|
104
|
+
AppleTransactionVerificationRequest,
|
|
105
|
+
BillingAccountState,
|
|
106
|
+
BillingProduct,
|
|
107
|
+
BillingSubscription,
|
|
108
|
+
BillingSubscriptionStatus,
|
|
101
109
|
CallAction,
|
|
102
110
|
CallEvent,
|
|
103
111
|
CallParticipant,
|
|
104
112
|
CallSession,
|
|
105
113
|
CallSignalPayload,
|
|
114
|
+
GooglePurchaseVerificationRequest,
|
|
106
115
|
IceServerConfig,
|
|
107
116
|
Invite,
|
|
108
117
|
Passkey,
|