chuvsu-js 5.5.0 → 5.5.2
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/README.md +3 -2
- package/dist/lk/webinars.d.ts +1 -1
- package/dist/lk/webinars.js +10 -14
- package/dist/webinar/chat-subscription.d.ts +5 -0
- package/dist/webinar/chat-subscription.js +19 -0
- package/dist/webinar/client.d.ts +5 -1
- package/dist/webinar/client.js +18 -4
- package/dist/webinar/ddp.js +6 -2
- package/dist/webinar/gateway.d.ts +3 -1
- package/dist/webinar/gateway.js +6 -0
- package/dist/webinar/media-protocol.d.ts +1 -1
- package/dist/webinar/media-protocol.js +1 -1
- package/dist/webinar/media.js +1 -1
- package/dist/webinar/parse.js +0 -3
- package/dist/webinar/types.d.ts +2 -1
- package/dist/webinar/types.js +3 -1
- package/docs/student-portal.md +4 -4
- package/docs/webinar.md +23 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -280,8 +280,9 @@ if (active?.id) {
|
|
|
280
280
|
Webinar methods belong to `StudentPortalClient`; removed from `TimetableClient`.
|
|
281
281
|
`id` is `null` when LK exposes no join button. `title` is the topic;
|
|
282
282
|
`subject` is the discipline. Completed and not-yet-started rows remain in the list.
|
|
283
|
-
`findWebinar` attaches only a unique match by actual date,
|
|
284
|
-
|
|
283
|
+
`findWebinar` attaches only a unique match by actual date, lesson slot (exact
|
|
284
|
+
time when a slot is unavailable), and known group/subgroup. Descriptive subject,
|
|
285
|
+
type and teacher labels do not block a match. `findWebinars` returns ambiguous
|
|
285
286
|
candidates for manual selection. Missing dates never match. Join URLs are resolved
|
|
286
287
|
on demand through LK; no webinar window opens automatically.
|
|
287
288
|
|
package/dist/lk/webinars.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export type LessonWithWebinar = LessonOccurrence & {
|
|
|
4
4
|
webinar?: Webinar;
|
|
5
5
|
};
|
|
6
6
|
export declare function findWebinar(lesson: LessonOccurrence, webinars: Webinar[]): Webinar | undefined;
|
|
7
|
-
/**
|
|
7
|
+
/** Match scheduled date, slot (time when unavailable), and known group/subgroup. */
|
|
8
8
|
export declare function findWebinars(lesson: LessonOccurrence, webinars: Webinar[]): Webinar[];
|
|
9
9
|
export declare function attachWebinars(lessons: LessonOccurrence[], webinars: Webinar[]): LessonWithWebinar[];
|
package/dist/lk/webinars.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LessonType } from "../common/lesson-type.js";
|
|
2
1
|
function normalize(value) {
|
|
3
2
|
return value
|
|
4
3
|
.toLocaleLowerCase("ru-RU")
|
|
@@ -10,7 +9,7 @@ export function findWebinar(lesson, webinars) {
|
|
|
10
9
|
const matches = findWebinars(lesson, webinars);
|
|
11
10
|
return matches.length === 1 ? matches[0] : undefined;
|
|
12
11
|
}
|
|
13
|
-
/**
|
|
12
|
+
/** Match scheduled date, slot (time when unavailable), and known group/subgroup. */
|
|
14
13
|
export function findWebinars(lesson, webinars) {
|
|
15
14
|
if (lesson.status === "cancelled")
|
|
16
15
|
return [];
|
|
@@ -19,27 +18,24 @@ export function findWebinars(lesson, webinars) {
|
|
|
19
18
|
return false;
|
|
20
19
|
if (webinar.scheduledDate !== lesson.scheduledDate)
|
|
21
20
|
return false;
|
|
22
|
-
if (webinar.slotNumber != null &&
|
|
23
|
-
webinar.slotNumber !== lesson.slotNumber)
|
|
24
|
-
|
|
21
|
+
if (webinar.slotNumber != null && lesson.slotNumber != null) {
|
|
22
|
+
if (webinar.slotNumber !== lesson.slotNumber)
|
|
23
|
+
return false;
|
|
25
24
|
}
|
|
26
|
-
if (!lesson.time ||
|
|
25
|
+
else if (!lesson.time ||
|
|
27
26
|
webinar.time.start.hours !== lesson.time.start.hours ||
|
|
28
27
|
webinar.time.start.minutes !== lesson.time.start.minutes ||
|
|
29
28
|
webinar.time.end.hours !== lesson.time.end.hours ||
|
|
30
29
|
webinar.time.end.minutes !== lesson.time.end.minutes) {
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
|
-
if (normalize(webinar.subject) !== normalize(lesson.subject))
|
|
34
|
-
return false;
|
|
35
|
-
if (webinar.type !== LessonType.Unknown && lesson.type !== LessonType.Unknown && webinar.type !== lesson.type)
|
|
36
|
-
return false;
|
|
37
32
|
const groups = lesson.groups.values;
|
|
38
|
-
|
|
39
|
-
(
|
|
33
|
+
const attendance = webinar.groups.length
|
|
34
|
+
? groups.filter((entry) => webinar.groups.some((group) => normalize(group) === normalize(entry.group.name)))
|
|
35
|
+
: groups;
|
|
36
|
+
if (groups.length && !attendance.length)
|
|
40
37
|
return false;
|
|
41
|
-
|
|
42
|
-
if (teachers.length && webinar.teacher.name.trim() && !teachers.some((teacher) => normalize(teacher.name) === normalize(webinar.teacher.name)))
|
|
38
|
+
if (webinar.subgroup != null && attendance.length && !attendance.some((entry) => entry.subgroup == null || entry.subgroup === webinar.subgroup))
|
|
43
39
|
return false;
|
|
44
40
|
return true;
|
|
45
41
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type WebinarChatSubscriptionFormat = "ids" | "count";
|
|
2
|
+
/** Negotiate the subscription signature, then retain it for this participant. */
|
|
3
|
+
export declare function subscribeToWebinarChat(transport: {
|
|
4
|
+
subscribe(name: string, params: unknown[]): Promise<void>;
|
|
5
|
+
}, chatIds: string[], format: WebinarChatSubscriptionFormat | null): Promise<WebinarChatSubscriptionFormat>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WebinarProtocolError } from "./types.js";
|
|
2
|
+
/** Negotiate the subscription signature, then retain it for this participant. */
|
|
3
|
+
export async function subscribeToWebinarChat(transport, chatIds, format) {
|
|
4
|
+
if (format !== null) {
|
|
5
|
+
await transport.subscribe("group-chat-msg", format === "ids" ? [chatIds] : [chatIds.length]);
|
|
6
|
+
return format;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
await transport.subscribe("group-chat-msg", [chatIds]);
|
|
10
|
+
return "ids";
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
// Only a signature mismatch permits another signature, never an auth/transport failure.
|
|
14
|
+
if (!(error instanceof WebinarProtocolError) || (error.code !== 400 && error.code !== "400"))
|
|
15
|
+
throw error;
|
|
16
|
+
await transport.subscribe("group-chat-msg", [chatIds.length]);
|
|
17
|
+
return "count";
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/webinar/client.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export declare class WebinarClient {
|
|
|
7
7
|
private listeners;
|
|
8
8
|
private ready;
|
|
9
9
|
private started;
|
|
10
|
+
private chatSubscriptionFormat;
|
|
11
|
+
private leaving;
|
|
10
12
|
constructor(session: WebinarSession, opts?: WebinarClientOptions);
|
|
11
13
|
connect(): Promise<void>;
|
|
12
14
|
private assertConnected;
|
|
@@ -47,6 +49,8 @@ export declare class WebinarClient {
|
|
|
47
49
|
text: string;
|
|
48
50
|
}): Promise<void>;
|
|
49
51
|
setMuted(muted: boolean): Promise<void>;
|
|
50
|
-
/**
|
|
52
|
+
/** Explicitly leaves this participant, then closes transport even if BBB rejects the request. */
|
|
53
|
+
leave(): Promise<void>;
|
|
54
|
+
/** Closes local transport; use leave() for an explicit room exit. */
|
|
51
55
|
close(): void;
|
|
52
56
|
}
|
package/dist/webinar/client.js
CHANGED
|
@@ -3,6 +3,7 @@ import { WebinarDdp } from "./ddp.js";
|
|
|
3
3
|
import { webinarEvents } from "./events.js";
|
|
4
4
|
import { record, string } from "./parse.js";
|
|
5
5
|
import { browserWebinarSocket } from "./socket.js";
|
|
6
|
+
import { subscribeToWebinarChat } from "./chat-subscription.js";
|
|
6
7
|
import { buildWebinarSnapshot, normalizeWebinarMessage } from "./state.js";
|
|
7
8
|
import { WebinarPermissionError, WebinarProtocolError, } from "./types.js";
|
|
8
9
|
/** Live participant state and explicit actions; never auto-connects media. */
|
|
@@ -13,8 +14,10 @@ export class WebinarClient {
|
|
|
13
14
|
listeners = new Set();
|
|
14
15
|
ready = false;
|
|
15
16
|
started = false;
|
|
17
|
+
chatSubscriptionFormat = null;
|
|
18
|
+
leaving = null;
|
|
16
19
|
constructor(session, opts = {}) {
|
|
17
|
-
if (session.protocol !== "ddp"
|
|
20
|
+
if (session.protocol !== "ddp") {
|
|
18
21
|
throw new WebinarProtocolError("Unsupported webinar participant protocol");
|
|
19
22
|
}
|
|
20
23
|
this.session = structuredClone(session);
|
|
@@ -47,7 +50,7 @@ export class WebinarClient {
|
|
|
47
50
|
"presentations", "slides", "slide-positions", "presentation-pods", "video-streams", "screenshare", "note", "group-chat",
|
|
48
51
|
].map((name) => this.ddp.subscribe(name)));
|
|
49
52
|
const chatIds = this.ddp.documents("group-chat").map((chat) => string(chat.chatId));
|
|
50
|
-
await this.ddp
|
|
53
|
+
this.chatSubscriptionFormat = await subscribeToWebinarChat(this.ddp, chatIds, this.chatSubscriptionFormat);
|
|
51
54
|
this.ready = true;
|
|
52
55
|
if (this.session.features.chat)
|
|
53
56
|
await this.loadMessages();
|
|
@@ -157,7 +160,7 @@ export class WebinarClient {
|
|
|
157
160
|
await this.ddp.waitFor("group-chat", (chat) => chat.access === "PRIVATE_ACCESS"
|
|
158
161
|
&& Array.isArray(chat.users) && chat.users.includes(user.id) && chat.users.includes(this.session.user.id));
|
|
159
162
|
const chat = this.getChats().find((chat) => chat.private && chat.userIds.includes(user.id));
|
|
160
|
-
await this.ddp
|
|
163
|
+
this.chatSubscriptionFormat = await subscribeToWebinarChat(this.ddp, this.getChats().map((chat) => chat.id), this.chatSubscriptionFormat);
|
|
161
164
|
return chat;
|
|
162
165
|
}
|
|
163
166
|
async sendPrivateMessage(opts) {
|
|
@@ -175,7 +178,18 @@ export class WebinarClient {
|
|
|
175
178
|
throw new WebinarPermissionError("Microphone audio is not connected");
|
|
176
179
|
await this.ddp.call("muteToggle", [this.session.user.id, muted]);
|
|
177
180
|
}
|
|
178
|
-
/**
|
|
181
|
+
/** Explicitly leaves this participant, then closes transport even if BBB rejects the request. */
|
|
182
|
+
leave() {
|
|
183
|
+
if (this.leaving)
|
|
184
|
+
return this.leaving;
|
|
185
|
+
if (!this.ready) {
|
|
186
|
+
this.close();
|
|
187
|
+
return Promise.resolve();
|
|
188
|
+
}
|
|
189
|
+
this.leaving = this.ddp.call("userLeftMeeting").then(() => undefined).finally(() => this.close());
|
|
190
|
+
return this.leaving;
|
|
191
|
+
}
|
|
192
|
+
/** Closes local transport; use leave() for an explicit room exit. */
|
|
179
193
|
close() {
|
|
180
194
|
this.ready = false;
|
|
181
195
|
this.ddp.close();
|
package/dist/webinar/ddp.js
CHANGED
|
@@ -155,11 +155,15 @@ export class WebinarDdp {
|
|
|
155
155
|
this.settle(String(id), undefined);
|
|
156
156
|
break;
|
|
157
157
|
case "nosub":
|
|
158
|
-
case "result":
|
|
158
|
+
case "result": {
|
|
159
|
+
const error = data.error !== null && typeof data.error === "object"
|
|
160
|
+
? data.error : {};
|
|
161
|
+
const code = typeof error.error === "number" || typeof error.error === "string" ? error.error : undefined;
|
|
159
162
|
this.settle(String(data.id), data.result, data.error
|
|
160
|
-
? new WebinarProtocolError(`Webinar ${data.msg === "nosub" ? "subscription" : "method"} rejected
|
|
163
|
+
? new WebinarProtocolError(`Webinar ${data.msg === "nosub" ? "subscription" : "method"} rejected`, code)
|
|
161
164
|
: undefined);
|
|
162
165
|
break;
|
|
166
|
+
}
|
|
163
167
|
case "added":
|
|
164
168
|
case "changed":
|
|
165
169
|
case "removed": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WebinarSession, type WebinarSlide } from "./types.js";
|
|
1
|
+
import { type WebinarSession, type WebinarSlide, type WebinarSocket } from "./types.js";
|
|
2
2
|
import { WebinarClient } from "./client.js";
|
|
3
3
|
/** Backend-only LK/BBB bootstrap and same-server presentation HTTP access. */
|
|
4
4
|
export declare class WebinarGateway {
|
|
@@ -6,6 +6,8 @@ export declare class WebinarGateway {
|
|
|
6
6
|
private session;
|
|
7
7
|
private client;
|
|
8
8
|
getSession(): WebinarSession;
|
|
9
|
+
/** Cookie-authenticated signaling socket; audio/video WebRTC stays in the browser. */
|
|
10
|
+
createMediaSocket(): WebinarSocket;
|
|
9
11
|
openSession(opts: {
|
|
10
12
|
joinUrl: string;
|
|
11
13
|
}): Promise<WebinarSession>;
|
package/dist/webinar/gateway.js
CHANGED
|
@@ -13,6 +13,12 @@ export class WebinarGateway {
|
|
|
13
13
|
throw new AuthError("Open a webinar session first");
|
|
14
14
|
return structuredClone(this.session);
|
|
15
15
|
}
|
|
16
|
+
/** Cookie-authenticated signaling socket; audio/video WebRTC stays in the browser. */
|
|
17
|
+
createMediaSocket() {
|
|
18
|
+
if (!this.session)
|
|
19
|
+
throw new AuthError("Open a webinar session first");
|
|
20
|
+
return this.http.createWebSocket(this.session.connections.media);
|
|
21
|
+
}
|
|
16
22
|
async openSession(opts) {
|
|
17
23
|
if (this.session)
|
|
18
24
|
throw new Error("Create a new gateway for each webinar session");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { WebinarDocument } from "./ddp.js";
|
|
2
2
|
import type { WebinarPlaybackKind } from "./media-types.js";
|
|
3
3
|
import type { WebinarSession } from "./types.js";
|
|
4
|
-
/** BBB 2.3 SFU messages. One playback per socket; no publish commands. */
|
|
4
|
+
/** BBB 2.3/2.4 SFU messages. One playback per socket; no publish commands. */
|
|
5
5
|
export declare function webinarMediaMessages(session: WebinarSession, kind: WebinarPlaybackKind, streamId?: string, hasAudio?: boolean): {
|
|
6
6
|
start(sdpOffer: string): WebinarDocument;
|
|
7
7
|
candidate(candidate: RTCIceCandidateInit): WebinarDocument;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** BBB 2.3 SFU messages. One playback per socket; no publish commands. */
|
|
1
|
+
/** BBB 2.3/2.4 SFU messages. One playback per socket; no publish commands. */
|
|
2
2
|
export function webinarMediaMessages(session, kind, streamId, hasAudio = false) {
|
|
3
3
|
const type = kind === "camera" ? "video" : kind === "screen" ? "screenshare" : "audio";
|
|
4
4
|
const role = kind === "camera" ? "viewer" : "recv";
|
package/dist/webinar/media.js
CHANGED
|
@@ -12,7 +12,7 @@ export class WebinarMediaClient {
|
|
|
12
12
|
constructor(session, room, opts = {}) {
|
|
13
13
|
this.room = room;
|
|
14
14
|
this.opts = opts;
|
|
15
|
-
if (session.mediaBackend !== "kurento"
|
|
15
|
+
if (session.mediaBackend !== "kurento") {
|
|
16
16
|
throw new WebinarProtocolError("Unsupported webinar media backend");
|
|
17
17
|
}
|
|
18
18
|
this.session = structuredClone(session);
|
package/dist/webinar/parse.js
CHANGED
|
@@ -43,9 +43,6 @@ export function parseWebinarSession(opts) {
|
|
|
43
43
|
const kurento = record(opts.config.kurento);
|
|
44
44
|
const chat = record(opts.config.chat);
|
|
45
45
|
const version = String(app.bbbServerVersion ?? "");
|
|
46
|
-
if (!/^2\.3(?:\.|$)/u.test(version)) {
|
|
47
|
-
throw new WebinarProtocolError(`Unsupported webinar version: ${version || "unknown"}`);
|
|
48
|
-
}
|
|
49
46
|
const token = url.searchParams.get("sessionToken");
|
|
50
47
|
const required = [token, response.authToken, response.internalUserID, response.meetingID,
|
|
51
48
|
response.fullname, response.voicebridge];
|
package/dist/webinar/types.d.ts
CHANGED
|
@@ -141,7 +141,8 @@ export interface WebinarClientOptions {
|
|
|
141
141
|
timeout?: number;
|
|
142
142
|
}
|
|
143
143
|
export declare class WebinarProtocolError extends Error {
|
|
144
|
-
|
|
144
|
+
readonly code?: string | number | undefined;
|
|
145
|
+
constructor(message: string, code?: string | number | undefined);
|
|
145
146
|
}
|
|
146
147
|
export declare class WebinarPermissionError extends Error {
|
|
147
148
|
constructor(message: string);
|
package/dist/webinar/types.js
CHANGED
package/docs/student-portal.md
CHANGED
|
@@ -72,10 +72,10 @@ in LK JavaScript and verified with mocked responses and live URL retrieval.
|
|
|
72
72
|
|
|
73
73
|
`findWebinar(lesson, webinars)` returns a unique compatible row.
|
|
74
74
|
`findWebinars` returns all candidates. Matching checks actual scheduled date,
|
|
75
|
-
slot when
|
|
76
|
-
group/subgroup
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
slot when both sides expose it, otherwise the exact time range, and known
|
|
76
|
+
group/subgroup data. Discipline, type and teacher labels do not affect matching;
|
|
77
|
+
LK and timetable can describe the same lesson differently. Cancelled lessons
|
|
78
|
+
never match. Ambiguous rows require caller selection.
|
|
79
79
|
`attachWebinars` preserves lesson IDs and never changes repository records.
|
|
80
80
|
|
|
81
81
|
## Portfolio
|
package/docs/webinar.md
CHANGED
|
@@ -30,6 +30,14 @@ same participant can interfere with each other. Do not log, persist in shared
|
|
|
30
30
|
caches, or expose participant session credentials to other users. The session
|
|
31
31
|
contains BBB credentials, never LK email/password or cookies.
|
|
32
32
|
|
|
33
|
+
Some servers require their HttpOnly BBB session cookie for the media signaling
|
|
34
|
+
handshake. A frontend on another site cannot receive that backend cookie through
|
|
35
|
+
`getSession()`. Use `gateway.createMediaSocket()` behind an authenticated,
|
|
36
|
+
owner-scoped WebSocket signaling relay and provide its browser endpoint through
|
|
37
|
+
`WebinarMediaClient`'s `socketFactory` option. This relays signaling only; peer
|
|
38
|
+
connections and audio/video remain directly between the browser and BBB. Never
|
|
39
|
+
serialize the gateway cookie jar or share a relay with another participant.
|
|
40
|
+
|
|
33
41
|
## State and events
|
|
34
42
|
|
|
35
43
|
- `getUsers()`, `getPresenter()`, `getModerators()` distinguish participant roles.
|
|
@@ -65,6 +73,10 @@ Streams are bounded. Overflow raises an error; refresh the snapshot and resubscr
|
|
|
65
73
|
Connection failures, rejected methods/subscriptions and unsupported versions fail
|
|
66
74
|
explicitly. `close()` releases the connection; create a new session/client to
|
|
67
75
|
reconnect. No automatic reconnect, replay of writes, or settings changes.
|
|
76
|
+
For an explicit room exit, use `await room.leave()`: it calls BBB's
|
|
77
|
+
`userLeftMeeting` for this authenticated participant and closes the transport
|
|
78
|
+
even if the request fails. It is idempotent and never removes another participant.
|
|
79
|
+
`close()` remains transport-only for disconnects and failed connections.
|
|
68
80
|
|
|
69
81
|
## Explicit actions
|
|
70
82
|
|
|
@@ -134,12 +146,19 @@ initial API; `setMuted()` only controls an already connected microphone session.
|
|
|
134
146
|
|
|
135
147
|
## Server versions
|
|
136
148
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
Compatibility follows the participant protocol, not a version allowlist. The
|
|
150
|
+
bootstrap decodes Meteor's public runtime configuration and validates participant
|
|
151
|
+
credentials and endpoints. The DDP client negotiates the chat subscription's
|
|
152
|
+
IDs/count signature and retains the accepted format per participant. Only a
|
|
153
|
+
signature mismatch permits this fallback; authentication and transport failures
|
|
154
|
+
remain errors. Server version/build stay informational.
|
|
155
|
+
|
|
156
|
+
Meteor/DDP state and legacy SFU signaling are implemented. The 2.3 contracts are
|
|
157
|
+
covered by fixtures; 2.4 bootstrap and live participant state were verified
|
|
158
|
+
against the university server. Incompatible protocols fail explicitly. No shared
|
|
141
159
|
BBB integration secret is required or used.
|
|
142
160
|
|
|
143
161
|
Protocol references: [Meteor DDP](https://github.com/meteor/meteor/blob/devel/packages/ddp/DDP.md),
|
|
144
162
|
[BBB 2.3 participant source](https://github.com/bigbluebutton/bigbluebutton/tree/v2.3.0/bigbluebutton-html5/imports/api),
|
|
163
|
+
[BBB 2.4 participant source](https://github.com/bigbluebutton/bigbluebutton/tree/v2.4.0/bigbluebutton-html5/imports/api),
|
|
145
164
|
[external UI configuration](https://docs.bigbluebutton.org/administration/cluster-proxy/).
|