@vkontakte/calls-sdk 2.8.12-dev.dd6d67c5.0 → 2.8.12-dev.dfea6e89.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.
@@ -6,8 +6,11 @@ export interface HoldableConversation extends Conversation {
6
6
  }
7
7
  export declare class CallRegistry {
8
8
  private _conversations;
9
+ private _reserved;
9
10
  private _activeId;
10
11
  private _mutex;
12
+ private _pendingRemovals;
13
+ reserve(id: string): void;
11
14
  add(conversation: HoldableConversation): void;
12
15
  remove(id: string | null): void;
13
16
  get(id: string): HoldableConversation | undefined;
@@ -21,6 +24,7 @@ export declare class CallRegistry {
21
24
  setHold(id: string): Promise<void>;
22
25
  switchCall(id: string): Promise<void>;
23
26
  clear(): void;
27
+ private _flushPendingRemovals;
24
28
  }
25
29
  declare const callRegistry: CallRegistry;
26
30
  export { callRegistry };
@@ -19,7 +19,7 @@ import MediaModifiers from '../types/MediaModifiers';
19
19
  import MediaSettings, { IVideoDimentions } from '../types/MediaSettings';
20
20
  import { IAddMovieParams, IUpdateMovieData } from '../types/MovieShare';
21
21
  import MuteStates from '../types/MuteStates';
22
- import { CompositeUserId, IGetParticipantsParameters, ParticipantId, ParticipantStateData } from '../types/Participant';
22
+ import { CompositeUserId, IGetParticipantsParameters, OkUserId, ParticipantId, ParticipantStateData } from '../types/Participant';
23
23
  import { DisplayLayoutRequest, ParticipantLayout } from '../types/ParticipantLayout';
24
24
  import { ParticipantListChunkParameters } from '../types/ParticipantListChunk';
25
25
  import ParticipantPriority from '../types/ParticipantPriority';
@@ -57,9 +57,12 @@ export default class Conversation extends EventEmitter {
57
57
  private _serverSettings;
58
58
  private _serverTimeOffset;
59
59
  private _delayedHangup;
60
+ private _hangupEmitted;
61
+ private _hangupPromise;
60
62
  private _abortController;
61
63
  private _registeredPeerReceived;
62
64
  private _calleeUnavailableTimer;
65
+ private _reservedId;
63
66
  private readonly _onUnload;
64
67
  private readonly _audioOutput;
65
68
  private readonly _stats;
@@ -86,12 +89,13 @@ export default class Conversation extends EventEmitter {
86
89
  static debugMessageWithContext(type: DebugMessageType, conversationId: string, ...args: any[]): boolean;
87
90
  static getSyncedTime(): number;
88
91
  get debugSessionId(): string | null;
92
+ getCachedRawOkIdByExternalId(externalId: ExternalId): OkUserId | null;
89
93
  onStart({ opponentIds, opponentType, mediaOptions, payload, joiningAllowed, requireAuthToJoin, onlyAdminCanShareMovie, externalIds, onFastStart, conversationId, }: ConversationOnStartParams): Promise<ConversationData>;
90
94
  onJoin(joinArgs: ConversationOnJoinParams): Promise<ConversationData>;
91
95
  private _onJoinPart2;
92
96
  private _extractExternalRooms;
93
97
  private _extractExternalRoomsData;
94
- onPush(conversationId: string, type?: UserType, peerId?: number, conversationParams?: string, wsEndpoint?: string): Promise<void>;
98
+ onPush(conversationId: string, type?: UserType, peerId?: number, conversationParams?: string, wsEndpoint?: string, userId?: number): Promise<void>;
95
99
  private _isInWaitingHall;
96
100
  private _isWaitForAdmin;
97
101
  private _isRestricted;
@@ -110,6 +114,8 @@ export default class Conversation extends EventEmitter {
110
114
  updateStatisticsInterval(): void;
111
115
  private _openTransport;
112
116
  private _allocateParticipantTransport;
117
+ private _cleanupRegistry;
118
+ private _emitHangupOnce;
113
119
  private _close;
114
120
  destroy(): void;
115
121
  private _getConversationParams;
@@ -196,7 +202,7 @@ export default class Conversation extends EventEmitter {
196
202
  private _cleanupTransportForHold;
197
203
  private _cleanupSpeakerDetector;
198
204
  private _cleanupSpecListener;
199
- private _cleanupSignaling;
205
+ private _disposeSignaling;
200
206
  private _onAddParticipant;
201
207
  private _onRemoveParticipant;
202
208
  changeDevice(kind: MediaDeviceKind): Promise<void>;
@@ -229,7 +235,7 @@ export default class Conversation extends EventEmitter {
229
235
  private _getWaitingForPromotionStatus;
230
236
  putHandsDown(): Promise<void>;
231
237
  requestKeyFrame(participantStreamDescription: ParticipantStreamDescription): Promise<void | SignalingMessage>;
232
- requestTestMode(consumerCommand: string, producerCommand: string): Promise<void>;
238
+ requestTestMode(consumerCommand: string, producerCommand: string): Promise<void | SignalingMessage>;
233
239
  updateDisplayLayout(layouts: ParticipantLayout[]): Promise<void>;
234
240
  requestDisplayLayout(requests: DisplayLayoutRequest[]): Promise<void>;
235
241
  feedback(key: string): Promise<SignalingMessage>;
@@ -1,6 +1,7 @@
1
1
  import { ExternalId, ExternalParticipantId } from '../types/ExternalId';
2
2
  import { CompositeUserId, OkUserId, ParticipantId } from '../types/Participant';
3
3
  export declare class ExternalIdCache {
4
+ private static _normalizeType;
4
5
  private _okIdToExternalId;
5
6
  private _externalIdToOkId;
6
7
  private _decorativeIdToInitialId;
@@ -0,0 +1,11 @@
1
+ export type SemanticCallFinishReason = 'hangup' | 'canceled' | 'rejected' | 'busy' | 'missed' | 'timeout' | 'another_device' | 'removed' | 'banned' | 'initially_closed' | 'call_timeout' | 'socket_closed' | 'killed' | 'killed_without_delete' | 'obsolete_client' | 'unavailable';
2
+ export type ClassifiedCallFinish = {
3
+ reason: SemanticCallFinishReason;
4
+ string_value?: string;
5
+ } | {
6
+ reason: 'error';
7
+ string_value: string;
8
+ } | {
9
+ reason: 'failed';
10
+ };
11
+ export declare function classifyCallFinish(error: unknown): ClassifiedCallFinish;
@@ -1,4 +1,3 @@
1
- import HangupReason from '../HangupReason';
2
1
  import StatsLogger from '../StatsLogger';
3
2
  export type CallLifecycleSource = 'outgoing' | 'incoming' | 'join' | 'anonym_join';
4
3
  export interface CallLifecycleInitializationParams {
@@ -34,7 +33,7 @@ export declare class CallLifecycleStats {
34
33
  markOutgoingAccepted(): void;
35
34
  markIncomingAccepted(concurrent: boolean): void;
36
35
  markFirstMediaSent(): void;
37
- markFinished(reason: HangupReason): void;
36
+ markFinished(reason: unknown): void;
38
37
  markTerminated(): void;
39
38
  destroy(): void;
40
39
  private _canRecord;
package/default/Api.d.ts CHANGED
@@ -7,11 +7,10 @@ import { ExternalId, ExternalParticipantId, ExternalUserId } from '../types/Exte
7
7
  import { CompositeUserId, OkUserId, ParticipantId } from '../types/Participant';
8
8
  import PushData from '../types/PushData';
9
9
  export default class Api extends BaseApi {
10
- private _userId;
11
10
  private _uuid;
12
11
  private _idCache;
13
12
  private _callUnsafe;
14
- protected _call(method: string, data?: any, noSession?: boolean): Promise<any>;
13
+ protected _call(method: string, data?: any, noSession?: boolean, allowReauthorize?: boolean): Promise<any>;
15
14
  userId(participantId: ParticipantId): ExternalParticipantId;
16
15
  authorize(): Promise<void>;
17
16
  private _getAnonymLoginCacheKey;
@@ -1,15 +1,15 @@
1
1
  import BaseSignaling, { AddParticipantParams } from '../abstract/BaseSignaling';
2
- import StatsLogger from '../classes/StatsLogger';
3
2
  import { ParticipantIdRegistry } from '../classes/ParticipantIdRegistry';
4
3
  import { SharingStatReport } from '../classes/screenshare/SharingStatReport';
5
4
  import { StatAggregator } from '../classes/stat/StatAggregator';
6
5
  import { StatPings } from '../classes/stat/StatPings';
7
6
  import { StatSignalingCommands } from '../classes/stat/StatSignalingCommands';
8
- import TransportTopology from '../enums/TransportTopology';
7
+ import StatsLogger from '../classes/StatsLogger';
9
8
  import ConversationFeature from '../enums/ConversationFeature';
10
9
  import ConversationOption from '../enums/ConversationOption';
11
10
  import MediaOption from '../enums/MediaOption';
12
11
  import SignalingConnectionType from '../enums/SignalingConnectionType';
12
+ import TransportTopology from '../enums/TransportTopology';
13
13
  import UserRole from '../enums/UserRole';
14
14
  import { type DebugLogger } from '../static/Debug';
15
15
  import { JSONObject } from '../static/Json';
@@ -35,13 +35,13 @@ export default class Signaling extends BaseSignaling {
35
35
  private datachannelCommandsQueue;
36
36
  private incomingCache;
37
37
  private responseHandlers;
38
+ private disposed;
38
39
  private connectionType;
39
40
  private conversationResolve;
40
41
  private conversationReject;
41
42
  private connected;
42
43
  private listenersReady;
43
44
  private peerId;
44
- private conversationId;
45
45
  private connectionMessageWaitTimer;
46
46
  private participantIdRegistry;
47
47
  private producerNotificationDataChannel;
@@ -60,21 +60,16 @@ export default class Signaling extends BaseSignaling {
60
60
  setAbortSignal(signal: AbortSignal | undefined): void;
61
61
  setEndpoint(endpoint: string): void;
62
62
  setWebTransportEndpoint(endpoint: string | null): void;
63
- setConversationId(conversationId: string): void;
64
63
  setParticipantIdRegistry(participantIdRegistry: ParticipantIdRegistry): void;
65
64
  setProducerNotificationDataChannel(dataChannel: RTCDataChannel): void;
66
65
  setProducerCommandDataChannel(dataChannel: RTCDataChannel): void;
67
66
  useCommandDataChannel(status: boolean): void;
68
- /**
69
- * Free used resources
70
- */
71
- cleanup(): void;
72
67
  /**
73
68
  * Open a connection with a signaling server
74
69
  */
75
70
  connect(connectionType: SignalingConnectionType): Promise<SignalingMessage.Connection>;
76
71
  getNextCommandSequenceNumber(): number;
77
- hangup(reason: string): Promise<SignalingMessage | void>;
72
+ hangup(reason: string): Promise<SignalingMessage>;
78
73
  sendCandidate(participantId: ParticipantId, candidate: RTCIceCandidate): Promise<SignalingMessage>;
79
74
  requestTestMode(consumerCommand: string, producerCommand: string | null): Promise<SignalingMessage>;
80
75
  sendSdp(participantId: ParticipantId, sdp: RTCSessionDescriptionInit, extraPayload?: Record<string, any>): Promise<SignalingMessage>;
@@ -138,10 +133,7 @@ export default class Signaling extends BaseSignaling {
138
133
  acceptPromotion(reject?: boolean): Promise<SignalingMessage>;
139
134
  feedback(key: string): Promise<SignalingMessage>;
140
135
  getHandQueue(): Promise<SignalingMessage>;
141
- /**
142
- * Close a connection with a signaling server
143
- */
144
- close(): void;
136
+ dispose(cause?: Error): void;
145
137
  /**
146
138
  * Этот метод нужен т.к. после получения сообщения "connected" устанавливается транспорт
147
139
  * и подписывается на сигналинг. Данные приходят очень быстро и транспорт пропускает
@@ -173,7 +165,8 @@ export default class Signaling extends BaseSignaling {
173
165
  private _onError;
174
166
  private _serializeErrorEvent;
175
167
  private _onClose;
176
- private _closeSocket;
168
+ private _terminate;
169
+ private _fail;
177
170
  private _isRecordCommand;
178
171
  private _resolvePendingRecordCommands;
179
172
  private _handleCommandResponse;
@@ -187,6 +180,8 @@ export default class Signaling extends BaseSignaling {
187
180
  private _onTransportFailed;
188
181
  private _onTransportReconnectScheduled;
189
182
  private _onTransportConnectionDead;
183
+ private _attachNotificationCallError;
184
+ private _createSignalingCallError;
190
185
  private _getSocketType;
191
186
  private _markTransportStat;
192
187
  private _logTransportStat;
@@ -9,6 +9,7 @@ export declare enum SignalingTransportFailure {
9
9
  export type SignalingTransportFailedEvent = {
10
10
  failure: SignalingTransportFailure;
11
11
  message: string;
12
+ source: SignalingTransportType;
12
13
  remote?: boolean;
13
14
  };
14
15
  export type SignalingTransportReconnectEvent = {
@@ -20,7 +20,6 @@ declare enum HangupType {
20
20
  CALLER_IS_REJECTED = "CALLER_IS_REJECTED",
21
21
  UNKNOWN_ERROR = "UNKNOWN_ERROR",
22
22
  UNSUPPORTED = "UNSUPPORTED",
23
- OLD_VERSION = "OLD_VERSION",
24
23
  SERVICE_DISABLED = "SERVICE_DISABLED",
25
24
  SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
26
25
  EXTERNAL_API_ERROR = "EXTERNAL_API_ERROR",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/calls-sdk",
3
- "version": "2.8.12-dev.dd6d67c5.0",
3
+ "version": "2.8.12-dev.dfea6e89.0",
4
4
  "author": "vk.com",
5
5
  "description": "Library for video calls based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -1,12 +1,22 @@
1
+ import type { OkUserId } from '../types/Participant';
1
2
  export default abstract class AuthData {
2
3
  private static _sessionKey;
3
4
  private static _sessionSecretKey;
4
5
  private static _accessToken;
6
+ private static _userId;
7
+ private static _reauthorizePromise;
5
8
  static get sessionKey(): string | undefined;
6
9
  static set sessionKey(value: string | undefined);
7
10
  static get sessionSecretKey(): string | undefined;
8
11
  static set sessionSecretKey(value: string | undefined);
9
12
  static get accessToken(): string | undefined;
10
13
  static set accessToken(value: string | undefined);
14
+ static get userId(): OkUserId | null;
15
+ static set userId(value: OkUserId | null);
11
16
  static isEmpty(): boolean;
17
+ /**
18
+ * Дедуплицирует одновременные попытки реавторизации из разных инстансов Api.
19
+ * Первый вызов выполняет authorizeFn, остальные ждут того же промиса.
20
+ */
21
+ static reauthorize(authorizeFn: () => Promise<void>): Promise<void>;
12
22
  }
@@ -637,6 +637,6 @@ declare namespace External {
637
637
  /**
638
638
  * Собеседник подключился к сигналлингу
639
639
  */
640
- function onPeerRegistered(conversationId?: string): void;
640
+ function onPeerRegistered(conversationId?: string, externalIds?: ExternalId[]): void;
641
641
  }
642
642
  export default External;
@@ -892,7 +892,7 @@ export type ParamsObject = {
892
892
  /**
893
893
  * Собеседник подключился к сигналлингу
894
894
  */
895
- onPeerRegistered?: (conversationId?: string) => void;
895
+ onPeerRegistered?: (conversationId?: string, externalIds?: ExternalId[]) => void;
896
896
  };
897
897
  export default abstract class Params {
898
898
  private static _params;
@@ -122,6 +122,10 @@ declare namespace WebRTCUtils {
122
122
  * Проверяет поддержку WebRTC браузером
123
123
  */
124
124
  function isBrowserSupported(): boolean;
125
+ /**
126
+ * Возвращает первую отсутствующую capability в стабильном порядке.
127
+ */
128
+ function getBrowserSupportFailure(): BrowserSupportFailure | null;
125
129
  /**
126
130
  * Проверяет поддержку шаринга экрана браузером
127
131
  */
@@ -1,5 +1,4 @@
1
1
  import MediaOption from '../enums/MediaOption';
2
- import UserType from '../enums/UserType';
3
2
  import UserRole from '../enums/UserRole';
4
3
  import { ParticipantStatus } from '../static/External';
5
4
  import MediaSettings from './MediaSettings';
@@ -20,7 +19,7 @@ export declare namespace ExternalIdUtils {
20
19
  function fromIds(ids: ExternalUserId[] | ExternalId[]): ExternalId[];
21
20
  function fromId(id: ExternalUserId, type?: ExternalIdType, deviceIdx?: number): ExternalParticipantId;
22
21
  function fromSignalingParticipant(participant: SignalingMessage.Participant, useDecorative?: boolean, fallbackToNonDecorative?: boolean): ExternalParticipantId | undefined;
23
- function fromSignaling(signalingId: SignalingMessage.ExternalId, deviceIdx?: number, idType?: UserType): ExternalParticipantId;
22
+ function fromSignaling(signalingId: SignalingMessage.ExternalId, deviceIdx?: number): ExternalParticipantId;
24
23
  function toSignaling(externalId: ExternalId): string;
25
24
  function toString(externalId: ExternalId): ExternalIdString;
26
25
  function fromIdToString(id: ExternalUserId, type?: ExternalIdType, deviceIdx?: number): ExternalIdString;
@@ -34,8 +34,11 @@ export type RecordInfo = {
34
34
  recordExternalOwnerId?: string;
35
35
  };
36
36
  export interface SignalingResponse extends SignalingMessage {
37
- response?: SignalingCommandType;
38
37
  error?: string;
38
+ errorCode?: string;
39
+ errorMessage?: string;
40
+ message?: string;
41
+ response?: SignalingCommandType;
39
42
  reason?: HangupType | FatalError;
40
43
  sequence?: number;
41
44
  type: 'response' | 'error' | 'timeout';
@@ -1,33 +1,32 @@
1
1
  import { WebTransportOptions } from '@fails-components/webtransport';
2
2
  import { DebugLogger } from '../static/Debug';
3
3
  declare class WebTransportEventual {
4
+ static isBrowserSupported(): boolean;
5
+ onopen: ((this: WebTransportEventual, ev: Event) => any) | null;
6
+ onmessage: ((this: WebTransportEventual, ev: MessageEvent) => any) | null;
7
+ onerror: ((this: WebTransportEventual, ev: Event) => any) | null;
8
+ onclose: ((this: WebTransportEventual, ev: CloseEvent) => any) | null;
9
+ readyState: number;
4
10
  private webTransport;
5
- private stream;
6
11
  private writer;
7
- private reader;
8
12
  private readonly url;
9
13
  private readonly options;
10
14
  private readonly compression;
11
- private closeRequested;
12
- private closeEventEmitted;
13
15
  private encoder;
14
16
  private decoder;
15
17
  private readonly _debug;
16
- onopen: ((this: WebTransportEventual, ev: Event) => any) | null;
17
- onmessage: ((this: WebTransportEventual, ev: MessageEvent) => any) | null;
18
- onerror: ((this: WebTransportEventual, ev: Event) => any) | null;
19
- onclose: ((this: WebTransportEventual, ev: CloseEvent) => any) | null;
20
- readyState: number;
21
18
  constructor(url: string, options?: WebTransportOptions, debug?: DebugLogger);
19
+ send(data: string): Promise<void>;
20
+ close(code?: number, reason?: string): void;
22
21
  private getCompressionTypeFromUrl;
23
22
  private connect;
24
- private readChunks;
23
+ private observeClosed;
25
24
  private readLoop;
26
- send(data: string): Promise<void>;
25
+ private fail;
26
+ private handleStreamError;
27
+ private requestNativeClose;
28
+ private finishClose;
29
+ private emitEvent;
27
30
  private createErrorEvent;
28
- close(code?: number, reason?: string): void;
29
- private closeConnectedTransport;
30
- private emitClose;
31
- static isBrowserSupported(): boolean;
32
31
  }
33
32
  export { WebTransportEventual as WebTransport };