@whereby.com/browser-sdk 2.0.0-beta3 → 2.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.
@@ -1,117 +1,27 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import _whereby_jslib_media_src_utils_ServerSocket, { ChatMessage as ChatMessage$2 } from '@whereby/jslib-media/src/utils/ServerSocket';
4
+ import * as redux_thunk from 'redux-thunk';
5
+ import { AxiosRequestConfig } from 'axios';
6
+ import EventEmitter from 'events';
7
+ import * as _reduxjs_toolkit from '@reduxjs/toolkit';
8
+ import * as redux from 'redux';
9
+ import RtcManagerDispatcher from '@whereby/jslib-media/src/webrtc/RtcManagerDispatcher';
2
10
  import RtcManager from '@whereby/jslib-media/src/webrtc/RtcManager';
3
- import { ChatMessage as ChatMessage$1 } from '@whereby/jslib-media/src/utils/ServerSocket';
4
11
 
5
12
  interface VideoViewSelfProps {
6
13
  stream: MediaStream;
7
14
  muted?: boolean;
8
15
  mirror?: boolean;
9
- style?: React.CSSProperties;
16
+ style?: React__default.CSSProperties;
10
17
  onResize?: ({ width, height, stream }: {
11
18
  width: number;
12
19
  height: number;
13
20
  stream: MediaStream;
14
21
  }) => void;
15
22
  }
16
- type VideoViewProps = VideoViewSelfProps & React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
17
- declare const _default: ({ muted, mirror, stream, onResize, ...rest }: VideoViewProps) => React.JSX.Element;
18
-
19
- type CameraEnabledEvent = {
20
- enabled: boolean;
21
- };
22
- type MicrophoneEnabledEvent = {
23
- enabled: boolean;
24
- };
25
- type DeviceListUpdatedEvent = {
26
- cameraDevices: MediaDeviceInfo[];
27
- microphoneDevices: MediaDeviceInfo[];
28
- speakerDevices: MediaDeviceInfo[];
29
- };
30
- type DeviceListUpdateErrorEvent = {
31
- error: unknown;
32
- };
33
- type StreamUpdatedEvent = {
34
- stream: MediaStream;
35
- };
36
- type StopResumeVideoEvent = {
37
- track: MediaStreamTrack;
38
- enable: boolean;
39
- };
40
- interface LocalMediaEventsMap {
41
- camera_enabled: CustomEvent<CameraEnabledEvent>;
42
- device_list_updated: CustomEvent<DeviceListUpdatedEvent>;
43
- device_list_update_error: CustomEvent<DeviceListUpdateErrorEvent>;
44
- microphone_enabled: CustomEvent<MicrophoneEnabledEvent>;
45
- stream_updated: CustomEvent<StreamUpdatedEvent>;
46
- stopresumevideo: CustomEvent<StopResumeVideoEvent>;
47
- }
48
- interface LocalMediaEventTarget extends EventTarget {
49
- addEventListener<K extends keyof LocalMediaEventsMap>(type: K, listener: (ev: LocalMediaEventsMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
50
- addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
51
- }
52
- declare const TypedLocalMediaEventTarget: new () => LocalMediaEventTarget;
53
- interface LocalMediaOptions {
54
- audio: boolean;
55
- video: boolean;
56
- }
57
- declare class LocalMedia extends TypedLocalMediaEventTarget {
58
- private _options;
59
- _rtcManagers: RtcManager[];
60
- private _devices;
61
- stream: MediaStream;
62
- screenshareStream?: MediaStream;
63
- private _cameraEnabled;
64
- private _currentCameraDeviceId;
65
- private _isTogglingCameraEnabled;
66
- private _microphoneEnabled;
67
- private _currentMicrophoneDeviceId;
68
- constructor(optionsOrStream: LocalMediaOptions | MediaStream);
69
- addRtcManager(rtcManager: RtcManager): void;
70
- removeRtcManager(rtcManager: RtcManager): void;
71
- getCameraDeviceId(): string | undefined;
72
- getMicrophoneDeviceId(): string | undefined;
73
- isCameraEnabled(): boolean;
74
- isMicrophoneEnabled(): boolean;
75
- toggleCameraEnabled(enabled?: boolean): Promise<void>;
76
- toggleMichrophoneEnabled(enabled?: boolean): void;
77
- startScreenshare(): Promise<MediaStream>;
78
- stopScreenshare(): void;
79
- private _getConstraintsOptions;
80
- private _setDevice;
81
- setCameraDevice(deviceId: string): Promise<void>;
82
- setMicrophoneDevice(deviceId: string): Promise<void>;
83
- private _updateDeviceList;
84
- start(): Promise<MediaStream>;
85
- stop(): void;
86
- }
87
-
88
- interface LocalMediaState {
89
- currentCameraDeviceId?: string;
90
- currentMicrophoneDeviceId?: string;
91
- cameraDeviceError: unknown;
92
- cameraDevices: MediaDeviceInfo[];
93
- isSettingCameraDevice: boolean;
94
- isSettingMicrophoneDevice: boolean;
95
- isStarting: boolean;
96
- localStream?: MediaStream;
97
- microphoneDeviceError: unknown;
98
- microphoneDevices: MediaDeviceInfo[];
99
- speakerDevices: MediaDeviceInfo[];
100
- startError: unknown;
101
- }
102
- interface LocalMediaActions {
103
- setCameraDevice: InstanceType<typeof LocalMedia>["setCameraDevice"];
104
- setMicrophoneDevice: InstanceType<typeof LocalMedia>["setMicrophoneDevice"];
105
- toggleCameraEnabled: InstanceType<typeof LocalMedia>["toggleCameraEnabled"];
106
- toggleMicrophoneEnabled: InstanceType<typeof LocalMedia>["toggleMichrophoneEnabled"];
107
- }
108
- type LocalMediaRef = {
109
- state: LocalMediaState;
110
- actions: LocalMediaActions;
111
- _ref: LocalMedia;
112
- };
113
- type UseLocalMediaOptions = LocalMediaOptions;
114
- declare function useLocalMedia(optionsOrStream?: UseLocalMediaOptions | MediaStream): LocalMediaRef;
23
+ type VideoViewProps = VideoViewSelfProps & React__default.DetailedHTMLProps<React__default.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
24
+ declare const _default: ({ muted, mirror, stream, onResize, ...rest }: VideoViewProps) => React__default.JSX.Element;
115
25
 
116
26
  interface RoomParticipantData {
117
27
  displayName: string;
@@ -129,22 +39,25 @@ declare class RoomParticipant {
129
39
  readonly isVideoEnabled: boolean;
130
40
  constructor({ displayName, id, stream, isAudioEnabled, isVideoEnabled }: RoomParticipantData);
131
41
  }
132
- interface RemoteParticipantData {
133
- newJoiner: boolean;
134
- streams: string[];
135
- }
136
42
  type StreamState = "new_accept" | "to_accept" | "old_accept" | "done_accept" | "to_unaccept" | "done_unaccept" | "auto";
137
43
  interface Stream {
138
44
  id: string;
139
45
  state: StreamState;
140
46
  }
141
- declare class RemoteParticipant extends RoomParticipant {
142
- readonly newJoiner: boolean;
143
- readonly streams: Stream[];
144
- constructor({ displayName, id, newJoiner, streams, isAudioEnabled, isVideoEnabled, }: RoomParticipantData & RemoteParticipantData);
145
- addStream(streamId: string, state: StreamState): void;
146
- removeStream(streamId: string): void;
147
- updateStreamState(streamId: string, state: StreamState): void;
47
+ interface RemoteParticipant {
48
+ id: string;
49
+ displayName: string;
50
+ isAudioEnabled: boolean;
51
+ isVideoEnabled: boolean;
52
+ isLocalParticipant: boolean;
53
+ stream: (MediaStream & {
54
+ inboundId?: string;
55
+ }) | null;
56
+ streams: Stream[];
57
+ newJoiner: boolean;
58
+ presentationStream: (MediaStream & {
59
+ inboundId?: string;
60
+ }) | null;
148
61
  }
149
62
  declare class LocalParticipant extends RoomParticipant {
150
63
  readonly isLocalParticipant = true;
@@ -154,193 +67,695 @@ interface WaitingParticipant {
154
67
  id: string;
155
68
  displayName: string | null;
156
69
  }
157
- declare class Screenshare {
158
- readonly participantId: string;
159
- readonly id: string;
160
- readonly hasAudioTrack: boolean;
161
- readonly stream?: MediaStream;
162
- readonly isLocal: boolean;
163
- constructor({ participantId, id, hasAudioTrack, stream, isLocal }: Screenshare);
164
- }
165
-
166
- type Logger = Pick<Console, "debug" | "error" | "log" | "warn" | "info">;
167
- interface RoomConnectionOptions {
168
- displayName?: string;
169
- localMediaOptions?: LocalMediaOptions;
170
- roomKey?: string;
171
- logger?: Logger;
172
- localMedia?: LocalMedia;
173
- externalId?: string;
174
- }
175
- type ChatMessage = Pick<ChatMessage$1, "senderId" | "timestamp" | "text">;
176
- type ConnectionStatus = "initializing" | "connecting" | "connected" | "room_locked" | "knocking" | "disconnecting" | "disconnected" | "knock_rejected";
177
- type CloudRecordingState = {
178
- error?: string;
179
- status: "recording" | "requested" | "error";
180
- startedAt?: number;
181
- };
182
- type LiveStreamState = {
183
- status: "streaming";
184
- startedAt: number;
185
- };
186
- type RoomJoinedEvent = {
187
- localParticipant: LocalParticipant;
188
- remoteParticipants: RemoteParticipant[];
189
- waitingParticipants: WaitingParticipant[];
190
- };
191
- type ConnectionStatusChangedEvent = {
192
- connectionStatus: ConnectionStatus;
193
- };
194
- type ParticipantJoinedEvent = {
195
- remoteParticipant: RemoteParticipant;
196
- };
197
- type ParticipantLeftEvent = {
198
- participantId: string;
199
- };
200
- type ParticipantStreamAddedEvent = {
201
- participantId: string;
202
- stream: MediaStream;
203
- streamId: string;
204
- };
205
- type ParticipantAudioEnabledEvent = {
206
- participantId: string;
207
- isAudioEnabled: boolean;
208
- };
209
- type ParticipantVideoEnabledEvent = {
210
- participantId: string;
211
- isVideoEnabled: boolean;
212
- };
213
- type ParticipantMetadataChangedEvent = {
214
- participantId: string;
215
- displayName: string;
216
- };
217
- type ScreenshareStartedEvent = {
70
+ interface Screenshare {
218
71
  participantId: string;
219
72
  id: string;
220
73
  hasAudioTrack: boolean;
221
- stream: MediaStream;
74
+ stream?: MediaStream;
222
75
  isLocal: boolean;
76
+ }
77
+
78
+ type Json = string | number | boolean | null | Array<Json> | {
79
+ [key: string]: Json;
223
80
  };
224
- type ScreenshareStoppedEvent = {
225
- participantId: string;
226
- id: string;
227
- };
228
- type WaitingParticipantJoinedEvent = {
229
- participantId: string;
230
- displayName: string | null;
81
+ interface ResponseOptions {
82
+ data?: Json;
83
+ headers?: Record<string, unknown>;
84
+ status?: number;
85
+ statusText?: string;
86
+ url?: string | null;
87
+ }
88
+ declare class Response {
89
+ data: Json;
90
+ headers: Record<string, unknown>;
91
+ status: number;
92
+ statusText: string;
93
+ url: string | null;
94
+ constructor(initialValues?: ResponseOptions);
95
+ }
96
+
97
+ declare class EmbeddedFreeTierStatus {
98
+ isExhausted: boolean;
99
+ renewsAt: Date;
100
+ totalMinutesLimit: number;
101
+ totalMinutesUsed: number;
102
+ constructor({ isExhausted, renewsAt, totalMinutesLimit, totalMinutesUsed, }: {
103
+ isExhausted: boolean;
104
+ renewsAt: Date;
105
+ totalMinutesLimit: number;
106
+ totalMinutesUsed: number;
107
+ });
108
+ static fromJson(data: Record<string, unknown>): EmbeddedFreeTierStatus;
109
+ }
110
+
111
+ interface AccountProps {
112
+ basePlanId: string | null;
113
+ isDeactivated: boolean;
114
+ isOnTrial: boolean;
115
+ onTrialUntil: Date | null;
116
+ trialStatus: string | null;
117
+ embeddedFreeTierStatus: EmbeddedFreeTierStatus | null;
118
+ }
119
+ declare class Account {
120
+ basePlanId: string | null;
121
+ embeddedFreeTierStatus: EmbeddedFreeTierStatus | null;
122
+ isDeactivated: boolean;
123
+ isOnTrial: boolean;
124
+ onTrialUntil: Date | null;
125
+ trialStatus: string | null;
126
+ constructor({ basePlanId, embeddedFreeTierStatus, isDeactivated, isOnTrial, onTrialUntil, trialStatus, }: AccountProps);
127
+ static fromJson(data: Record<string, unknown>): Account;
128
+ }
129
+
130
+ interface OrganizationPermissionAction {
131
+ isAllowed: boolean;
132
+ isSupported: boolean;
133
+ }
134
+ interface FullOrganizationPermissions {
135
+ images: {
136
+ logoImageUrl: {
137
+ set: OrganizationPermissionAction;
138
+ reset: OrganizationPermissionAction;
139
+ };
140
+ roomBackgroundImageUrl: {
141
+ set: OrganizationPermissionAction;
142
+ reset: OrganizationPermissionAction;
143
+ };
144
+ roomKnockPageBackgroundImageUrl: {
145
+ set: OrganizationPermissionAction;
146
+ reset: OrganizationPermissionAction;
147
+ };
148
+ };
149
+ invitations: {
150
+ add: OrganizationPermissionAction;
151
+ delete: OrganizationPermissionAction;
152
+ list: OrganizationPermissionAction;
153
+ };
154
+ roles: {
155
+ set: OrganizationPermissionAction;
156
+ remove: OrganizationPermissionAction;
157
+ removeSelf: OrganizationPermissionAction;
158
+ list: OrganizationPermissionAction;
159
+ };
160
+ users: {
161
+ signUpWithoutInvitation: OrganizationPermissionAction;
162
+ };
163
+ rooms: {
164
+ customize: OrganizationPermissionAction;
165
+ customizeSelf: OrganizationPermissionAction;
166
+ list: OrganizationPermissionAction;
167
+ lock: OrganizationPermissionAction;
168
+ unclaim: OrganizationPermissionAction;
169
+ unclaimSelf: OrganizationPermissionAction;
170
+ };
171
+ subscriptions: {
172
+ add: OrganizationPermissionAction;
173
+ list: OrganizationPermissionAction;
174
+ payLatestInvoice: OrganizationPermissionAction;
175
+ updatePlan: OrganizationPermissionAction;
176
+ };
177
+ browserExtension: {
178
+ install: OrganizationPermissionAction;
179
+ };
180
+ }
181
+ type OrganizationPermissions = Partial<FullOrganizationPermissions>;
182
+ interface OrganizationLimits {
183
+ maxNumberOfInvitationsAndUsers: number | null;
184
+ maxNumberOfClaimedRooms: number | null;
185
+ maxRoomLimitPerOrganization: number | null;
186
+ trialMinutesLimit: number | null;
187
+ includedUnits: number | null;
188
+ }
189
+ interface OrganizationOnboardingSurvey {
190
+ name: string;
191
+ value: unknown;
192
+ }
193
+ type OrganizationPreferences = Record<string, boolean | string | null | number>;
194
+ declare class Organization {
195
+ static GLOBAL_ORGANIZATION_ID: string;
196
+ organizationId: string;
197
+ organizationName: string;
198
+ subdomain: string;
199
+ permissions: OrganizationPermissions;
200
+ limits: OrganizationLimits;
201
+ account: Account | null;
202
+ logoImageUrl: string | null;
203
+ roomBackgroundImageUrl: string | null;
204
+ roomBackgroundThumbnailUrl: string | null;
205
+ roomKnockPageBackgroundImageUrl: string | null;
206
+ roomKnockPageBackgroundThumbnailUrl: string | null;
207
+ preferences: OrganizationPreferences | null;
208
+ onboardingSurvey: OrganizationOnboardingSurvey | null;
209
+ type: string | null;
210
+ constructor(properties: {
211
+ account: Account | null;
212
+ organizationId: string;
213
+ organizationName: string;
214
+ subdomain: string;
215
+ permissions: OrganizationPermissions;
216
+ limits: OrganizationLimits;
217
+ logoImageUrl: string | null;
218
+ roomBackgroundImageUrl: string | null;
219
+ roomBackgroundThumbnailUrl: string | null;
220
+ roomKnockPageBackgroundImageUrl: string | null;
221
+ roomKnockPageBackgroundThumbnailUrl: string | null;
222
+ preferences: OrganizationPreferences | null;
223
+ onboardingSurvey: OrganizationOnboardingSurvey | null;
224
+ type: string | null;
225
+ });
226
+ static fromJson(data: Json): Organization;
227
+ }
228
+
229
+ type HttpClientRequestConfig = AxiosRequestConfig | {
230
+ [key: string]: unknown;
231
231
  };
232
- type WaitingParticipantLeftEvent = {
233
- participantId: string;
232
+ interface IHttpClient {
233
+ request(url: string, options: HttpClientRequestConfig): Promise<Response>;
234
+ }
235
+ /**
236
+ * Class used for making http calls. This is just a pure
237
+ * wrapper around the http lib that we decide to use,
238
+ * so that we can switch implementations.
239
+ */
240
+ declare class HttpClient implements IHttpClient {
241
+ _baseUrl: string;
242
+ /**
243
+ * Creates an HttpClient instance.
244
+ *
245
+ * @param {string} [baseUrl] - The base URL where all requests are made.
246
+ */
247
+ constructor({ baseUrl }: {
248
+ baseUrl: string;
249
+ });
250
+ private _requestAxios;
251
+ /**
252
+ * Wrapper for the axios API
253
+ *
254
+ * @param {string} url - Required. URL (appended to base URL) where API call will be made
255
+ * @param {object} options - Required. Contains the data needed for the fetch API
256
+ * @return {Promise<Response>} - A promise which will return a Response object (https://developer.mozilla.org/en-US/docs/Web/API/Response)
257
+ */
258
+ request(url: string, options: HttpClientRequestConfig): Promise<Response>;
259
+ }
260
+
261
+ /**
262
+ * ApiClient for doing multipart/form-data requests.
263
+ */
264
+ declare class MultipartHttpClient implements IHttpClient {
265
+ _httpClient: IHttpClient;
266
+ constructor({ httpClient }: {
267
+ httpClient: IHttpClient;
268
+ });
269
+ /**
270
+ * Convert the provided object to a FormData object containing the same keys and values.
271
+ * @param {object} data - the data to convert.
272
+ * @returns {FormData}
273
+ */
274
+ static dataToFormData(data: Record<string, string>): FormData;
275
+ /**
276
+ * Request a resource using multipart/form-data encoding.
277
+ *
278
+ * @param {string} url - the url to request
279
+ * @param {object} options - Required. Contains the data needed for the fetch API
280
+ * @return {Promise<Response>} - A promise which will return a Response object (https://developer.mozilla.org/en-US/docs/Web/API/Response)
281
+ */
282
+ request(url: string, options?: HttpClientRequestConfig): Promise<Response>;
283
+ }
284
+
285
+ interface CredentialsOptions {
286
+ uuid: string;
287
+ hmac: string;
288
+ userId?: string;
289
+ }
290
+ declare class Credentials {
291
+ credentials: {
292
+ uuid: CredentialsOptions["uuid"];
293
+ };
294
+ hmac: CredentialsOptions["hmac"];
295
+ userId: CredentialsOptions["userId"];
296
+ constructor(uuid: CredentialsOptions["uuid"], hmac: CredentialsOptions["hmac"], userId?: CredentialsOptions["userId"]);
297
+ toJson(): Json;
298
+ static fromJson(json: Json): Credentials;
299
+ }
300
+
301
+ interface AuthenticatedHttpClientOptions {
302
+ httpClient: HttpClient;
303
+ fetchDeviceCredentials: () => Promise<Credentials | null>;
304
+ }
305
+ declare class AuthenticatedHttpClient {
306
+ private _httpClient;
307
+ private _fetchDeviceCredentials;
308
+ constructor({ httpClient, fetchDeviceCredentials }: AuthenticatedHttpClientOptions);
309
+ request(url: string, options: HttpClientRequestConfig): Promise<Response>;
310
+ }
311
+ interface ApiClientOptions {
312
+ baseUrl?: string;
313
+ fetchDeviceCredentials?: AuthenticatedHttpClientOptions["fetchDeviceCredentials"];
314
+ }
315
+ /**
316
+ * Class used for all Whereby API calls.
317
+ */
318
+ declare class ApiClient {
319
+ authenticatedHttpClient: AuthenticatedHttpClient;
320
+ authenticatedFormDataHttpClient: MultipartHttpClient;
321
+ /**
322
+ * Create an ApiClient instance.
323
+ */
324
+ constructor({ baseUrl, fetchDeviceCredentials, }?: ApiClientOptions);
325
+ /**
326
+ * Wrapper for the fetch API
327
+ */
328
+ request(url: string, options: HttpClientRequestConfig): Promise<Response>;
329
+ /**
330
+ * Performs a multipart request where data is multipart/form-data encoded.
331
+ */
332
+ requestMultipart(url: string, options: HttpClientRequestConfig): Promise<Response>;
333
+ }
334
+
335
+ /**
336
+ * Related to device calls needed to obtain credentials
337
+ */
338
+ declare class DeviceService {
339
+ _apiClient: ApiClient;
340
+ constructor({ apiClient }: {
341
+ apiClient: ApiClient;
342
+ });
343
+ /**
344
+ * Get's the device credentials needed for most of the other API services
345
+ *
346
+ * @return {Promise} A promise which is fulfilled or failed based on the
347
+ * response.
348
+ */
349
+ getCredentials(): Promise<Credentials | null>;
350
+ }
351
+
352
+ interface AbstractStore {
353
+ loadOrDefault(defaultValue: Json): Promise<Json>;
354
+ save(value: Json): Promise<void>;
355
+ }
356
+
357
+ declare class CredentialsService extends EventEmitter {
358
+ _deviceService: DeviceService;
359
+ _credentialsStore: AbstractStore;
360
+ credentialsPromise?: Promise<Credentials | null>;
361
+ /**
362
+ * Service to manage Whereby's Rest API credentials.
363
+ *
364
+ * @param {ObjectStore} credentialsStore - Store to manage the credentials.
365
+ */
366
+ constructor({ deviceService, credentialsStore, }: {
367
+ deviceService: DeviceService;
368
+ credentialsStore: AbstractStore;
369
+ });
370
+ static create({ baseUrl, storeName, storeType, }: {
371
+ baseUrl: string;
372
+ storeName?: string;
373
+ storeType?: "localStorage" | "chromeStorage";
374
+ }): CredentialsService;
375
+ /**
376
+ * Contacts the REST API to get new credentials. DO NOT USE directly, call getCredentials() instead.
377
+ *
378
+ * @see getCredentials
379
+ * @returns {Promise.<Credentials>} - Promise that resolves with the credentials.
380
+ */
381
+ _fetchNewCredentialsFromApi(): Promise<Credentials | null>;
382
+ /**
383
+ * Returns the current credentials without triggering an API request to get new ones.
384
+ * If no credentials are currently available it will return null.
385
+ *
386
+ * @returns {?Credentials} - The credentials currently in use, null otherwise.
387
+ */
388
+ getCurrentCredentials(): Promise<Credentials | null>;
389
+ /**
390
+ * Returns a promise that will contain the credentials for this client.
391
+ * If no credentials are available in local storage, new ones will be fetched from the server.
392
+ *
393
+ * @returns {Promise.<Credentials>} - Promise that resolves with the credentials.
394
+ */
395
+ getCredentials(): Promise<Credentials | null>;
396
+ /**
397
+ * Saves new credentials which replace the existing ones and abort any pending request to get new ones.
398
+ *
399
+ * @param {Credentials} credentials - New credentials to store.
400
+ */
401
+ saveCredentials(credentials: Credentials): Promise<Credentials>;
402
+ /**
403
+ * It will set the userId for the current credentials.
404
+ *
405
+ * @param userId - The user id to set.
406
+ */
407
+ setUserId(userId: string | null): Promise<void>;
408
+ }
409
+
410
+ type UserConsentAction = "accepted" | "rejected" | null;
411
+ type ConsentGrantRequest = {
412
+ readonly consentRevisionId: string;
413
+ readonly action: UserConsentAction;
234
414
  };
235
- type LocalCameraEnabledEvent = {
236
- enabled: boolean;
415
+
416
+ declare class OrganizationService {
417
+ _apiClient: ApiClient;
418
+ constructor({ apiClient }: {
419
+ apiClient: ApiClient;
420
+ });
421
+ /**
422
+ * Creates an organization.
423
+ */
424
+ createOrganization({ organizationName, subdomain, owner, }: {
425
+ organizationName: string;
426
+ subdomain: string;
427
+ owner: {
428
+ email: string;
429
+ displayName: string;
430
+ verificationCode: string;
431
+ consents?: ReadonlyArray<ConsentGrantRequest>;
432
+ } | {
433
+ idToken: string;
434
+ displayName: string;
435
+ consents?: ReadonlyArray<ConsentGrantRequest>;
436
+ };
437
+ }): Promise<string>;
438
+ /**
439
+ * Retrieves the organization based on the subdomain.
440
+ */
441
+ getOrganizationBySubdomain(subdomain: string): Promise<Organization | null>;
442
+ /**
443
+ * Retrieves the organization based on the organizationId.
444
+ *
445
+ * Note: This endpoint should only be used to retrieve an organization when the device is linked
446
+ * to a user in that organization. Use getOrganizationBySubdomain instead if you just want the information
447
+ * about an organization that is mapped to a given subdomain.
448
+ */
449
+ getOrganizationByOrganizationId(organizationId: string): Promise<Organization | null>;
450
+ /**
451
+ * Retrieves the organizations that contain a user
452
+ * matching provided the email+code or phoneNumber+code
453
+ * combination.
454
+ */
455
+ getOrganizationsByContactPoint(options: {
456
+ email: string;
457
+ code: string;
458
+ } | {
459
+ phoneNumber: string;
460
+ code: string;
461
+ }): Promise<ReadonlyArray<Organization>>;
462
+ /**
463
+ * Retrieves the organizations that contain a user
464
+ * matching provided the idToken
465
+ */
466
+ getOrganizationsByIdToken({ idToken }: {
467
+ idToken: string;
468
+ }): Promise<ReadonlyArray<Organization>>;
469
+ /**
470
+ * Retrieves the organizations containing a user
471
+ * with either the email or phoneNumber matching the logged in user.
472
+ *
473
+ * This is useful for showing the possible organization that the current
474
+ * user could log in to.
475
+ */
476
+ getOrganizationsByLoggedInUser(): Promise<ReadonlyArray<Organization>>;
477
+ /**
478
+ * Checks if a subdomain is available and verifies its format.
479
+ */
480
+ getSubdomainAvailability(subdomain: string): Promise<{
481
+ status: string;
482
+ }>;
483
+ /**
484
+ * Updates preferences of the organization.
485
+ */
486
+ updatePreferences({ organizationId, preferences, }: {
487
+ organizationId: string;
488
+ preferences: OrganizationPreferences;
489
+ }): Promise<undefined>;
490
+ /**
491
+ * Delete organization
492
+ */
493
+ deleteOrganization({ organizationId }: {
494
+ organizationId: string;
495
+ }): Promise<undefined>;
496
+ }
497
+
498
+ /**
499
+ * Reducer
500
+ */
501
+ interface StreamingState {
502
+ isStreaming: boolean;
503
+ error: unknown;
504
+ startedAt?: number;
505
+ }
506
+
507
+ /**
508
+ * Reducer
509
+ */
510
+ interface rtcAnalyticsState {
511
+ reportedValues: {
512
+ [key: string]: unknown;
513
+ };
514
+ }
515
+
516
+ interface LocalScreenshareState {
517
+ status: "" | "starting" | "active";
518
+ stream: MediaStream | null;
519
+ error: unknown | null;
520
+ }
521
+
522
+ interface LocalParticipantState$1 extends LocalParticipantState {
523
+ isScreenSharing: boolean;
524
+ roleName: string;
525
+ }
526
+
527
+ /**
528
+ * Reducer
529
+ */
530
+ interface CloudRecordingState$1 {
531
+ isRecording: boolean;
532
+ error: unknown;
533
+ status?: "recording" | "requested" | "error";
534
+ startedAt?: number;
535
+ }
536
+
537
+ type ChatMessage$1 = Pick<ChatMessage$2, "senderId" | "timestamp" | "text">;
538
+ /**
539
+ * Reducer
540
+ */
541
+ interface ChatState {
542
+ chatMessages: ChatMessage$1[];
543
+ }
544
+
545
+ /**
546
+ * Reducer
547
+ */
548
+ interface AppState {
549
+ wantsToJoin: boolean;
550
+ roomUrl: string | null;
551
+ roomName: string | null;
552
+ roomKey: string | null;
553
+ displayName: string | null;
554
+ sdkVersion: string | null;
555
+ externalId: string | null;
556
+ }
557
+
558
+ /**
559
+ * Reducer
560
+ */
561
+ interface DeviceCredentialsState {
562
+ isFetching: boolean;
563
+ data?: Credentials | null;
564
+ }
565
+
566
+ /**
567
+ * Reducer
568
+ */
569
+ interface OrganizationState {
570
+ data: Organization | null | undefined;
571
+ isFetching: boolean;
572
+ error: unknown;
573
+ }
574
+
575
+ /**
576
+ * Reducer
577
+ */
578
+ interface RemoteParticipantState$1 {
579
+ remoteParticipants: RemoteParticipant[];
580
+ }
581
+
582
+ type ConnectionStatus$1 = "initializing" | "connecting" | "connected" | "reconnect" | "room_locked" | "knocking" | "disconnecting" | "disconnected" | "knock_rejected";
583
+ /**
584
+ * Reducer
585
+ */
586
+ interface RoomConnectionState$1 {
587
+ session: {
588
+ createdAt: string;
589
+ id: string;
590
+ } | null;
591
+ status: ConnectionStatus$1;
592
+ error: unknown;
593
+ }
594
+
595
+ /**
596
+ * Reducer
597
+ */
598
+ interface StreamResolutionUpdate {
599
+ streamId: string;
600
+ width: number;
601
+ height: number;
602
+ }
603
+ interface RtcConnectionState {
604
+ dispatcherCreated: boolean;
605
+ error: unknown;
606
+ isCreatingDispatcher: boolean;
607
+ reportedStreamResolutions: {
608
+ [streamId: string]: Omit<StreamResolutionUpdate, "streamId">;
609
+ };
610
+ rtcManager: RtcManager | null;
611
+ rtcManagerDispatcher: RtcManagerDispatcher | null;
612
+ rtcManagerInitialized: boolean;
613
+ status: "" | "ready" | "reconnect";
614
+ isAcceptingStreams: boolean;
615
+ }
616
+
617
+ /**
618
+ * Reducer
619
+ */
620
+ interface SignalConnectionState {
621
+ deviceIdentified: boolean;
622
+ isIdentifyingDevice: boolean;
623
+ status: "connected" | "connecting" | "disconnected" | "reconnect" | "";
624
+ socket: _whereby_jslib_media_src_utils_ServerSocket | null;
625
+ }
626
+
627
+ declare function createServices(): {
628
+ credentialsService: CredentialsService;
629
+ apiClient: ApiClient;
630
+ organizationService: OrganizationService;
631
+ fetchOrganizationFromRoomUrl: (roomUrl: string) => Promise<Organization | null>;
237
632
  };
238
- type LocalMicrophoneEnabledEvent = {
239
- enabled: boolean;
633
+
634
+ declare const createStore: ({ preloadedState, injectServices, }: {
635
+ preloadedState?: Partial<{
636
+ app: AppState;
637
+ chat: ChatState;
638
+ cloudRecording: CloudRecordingState$1;
639
+ deviceCredentials: DeviceCredentialsState;
640
+ localMedia: LocalMediaState$1;
641
+ localParticipant: LocalParticipantState$1;
642
+ localScreenshare: LocalScreenshareState;
643
+ organization: OrganizationState;
644
+ remoteParticipants: RemoteParticipantState$1;
645
+ roomConnection: RoomConnectionState$1;
646
+ rtcAnalytics: rtcAnalyticsState;
647
+ rtcConnection: RtcConnectionState;
648
+ signalConnection: SignalConnectionState;
649
+ streaming: StreamingState;
650
+ waitingParticipants: WaitingParticipantsState;
651
+ }> | undefined;
652
+ injectServices: ReturnType<typeof createServices>;
653
+ }) => _reduxjs_toolkit.EnhancedStore<{
654
+ app: AppState;
655
+ chat: ChatState;
656
+ cloudRecording: CloudRecordingState$1;
657
+ deviceCredentials: DeviceCredentialsState;
658
+ localMedia: LocalMediaState$1;
659
+ localParticipant: LocalParticipantState$1;
660
+ localScreenshare: LocalScreenshareState;
661
+ organization: OrganizationState;
662
+ remoteParticipants: RemoteParticipantState$1;
663
+ roomConnection: RoomConnectionState$1;
664
+ rtcAnalytics: rtcAnalyticsState;
665
+ rtcConnection: RtcConnectionState;
666
+ signalConnection: SignalConnectionState;
667
+ streaming: StreamingState;
668
+ waitingParticipants: WaitingParticipantsState;
669
+ }, redux.UnknownAction, _reduxjs_toolkit.Tuple<[redux.StoreEnhancer<{
670
+ dispatch: ((action: redux.Action<"listenerMiddleware/add">) => _reduxjs_toolkit.UnsubscribeListener) & redux_thunk.ThunkDispatch<{
671
+ app: AppState;
672
+ chat: ChatState;
673
+ cloudRecording: CloudRecordingState$1;
674
+ deviceCredentials: DeviceCredentialsState;
675
+ localMedia: LocalMediaState$1;
676
+ localParticipant: LocalParticipantState$1;
677
+ localScreenshare: LocalScreenshareState;
678
+ organization: OrganizationState;
679
+ remoteParticipants: RemoteParticipantState$1;
680
+ roomConnection: RoomConnectionState$1;
681
+ rtcAnalytics: rtcAnalyticsState;
682
+ rtcConnection: RtcConnectionState;
683
+ signalConnection: SignalConnectionState;
684
+ streaming: StreamingState;
685
+ waitingParticipants: WaitingParticipantsState;
686
+ }, {
687
+ services: {
688
+ credentialsService: CredentialsService;
689
+ apiClient: ApiClient;
690
+ organizationService: OrganizationService;
691
+ fetchOrganizationFromRoomUrl: (roomUrl: string) => Promise<Organization | null>;
692
+ };
693
+ }, redux.UnknownAction>;
694
+ }, {}>, redux.StoreEnhancer<{}, {}>]>>;
695
+ type Store = ReturnType<typeof createStore>;
696
+
697
+ /**
698
+ * Reducer
699
+ */
700
+ interface WaitingParticipantsState {
701
+ waitingParticipants: WaitingParticipant[];
702
+ }
703
+
704
+ type LocalMediaOptions = {
705
+ audio: boolean;
706
+ video: boolean;
240
707
  };
241
- interface RoomEventsMap {
242
- chat_message: (e: CustomEvent<ChatMessage>) => void;
243
- cloud_recording_request_started: (e: CustomEvent<CloudRecordingState>) => void;
244
- cloud_recording_started: (e: CustomEvent<CloudRecordingState>) => void;
245
- cloud_recording_started_error: (e: CustomEvent<CloudRecordingState>) => void;
246
- cloud_recording_stopped: (e: CustomEvent<CloudRecordingState>) => void;
247
- local_camera_enabled: (e: CustomEvent<LocalCameraEnabledEvent>) => void;
248
- local_microphone_enabled: (e: CustomEvent<LocalMicrophoneEnabledEvent>) => void;
249
- participant_audio_enabled: (e: CustomEvent<ParticipantAudioEnabledEvent>) => void;
250
- participant_joined: (e: CustomEvent<ParticipantJoinedEvent>) => void;
251
- participant_left: (e: CustomEvent<ParticipantLeftEvent>) => void;
252
- participant_metadata_changed: (e: CustomEvent<ParticipantMetadataChangedEvent>) => void;
253
- participant_stream_added: (e: CustomEvent<ParticipantStreamAddedEvent>) => void;
254
- participant_video_enabled: (e: CustomEvent<ParticipantVideoEnabledEvent>) => void;
255
- connection_status_changed: (e: CustomEvent<ConnectionStatusChangedEvent>) => void;
256
- room_joined: (e: CustomEvent<RoomJoinedEvent>) => void;
257
- screenshare_started: (e: CustomEvent<ScreenshareStartedEvent>) => void;
258
- screenshare_stopped: (e: CustomEvent<ScreenshareStoppedEvent>) => void;
259
- streaming_started: (e: CustomEvent<LiveStreamState>) => void;
260
- streaming_stopped: (e: CustomEvent<LiveStreamState>) => void;
261
- waiting_participant_joined: (e: CustomEvent<WaitingParticipantJoinedEvent>) => void;
262
- waiting_participant_left: (e: CustomEvent<WaitingParticipantLeftEvent>) => void;
263
- }
264
- interface RoomEventTarget extends EventTarget {
265
- addEventListener<K extends keyof RoomEventsMap>(type: K, listener: RoomEventsMap[K], options?: boolean | AddEventListenerOptions): void;
266
- addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
267
- removeEventListener<K extends keyof RoomEventsMap>(type: K, listener: RoomEventsMap[K], options?: boolean | EventListenerOptions): void;
268
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
269
- }
270
- declare const TypedEventTarget: new () => RoomEventTarget;
271
- declare class RoomConnection extends TypedEventTarget {
272
- localMedia: LocalMedia;
273
- localParticipant?: LocalParticipant;
274
- roomUrl: URL;
275
- remoteParticipants: RemoteParticipant[];
276
- screenshares: Screenshare[];
277
- readonly localMediaConstraints?: MediaStreamConstraints;
278
- readonly roomName: string;
279
- private organizationId;
280
- private credentialsService;
281
- private apiClient;
282
- private organizationService;
283
- private organizationServiceCache;
284
- private organizationApiClient;
285
- private roomService;
286
- private _deviceCredentials;
287
- private signalSocket;
288
- private signalSocketManager;
289
- private rtcManagerDispatcher?;
290
- private rtcManager?;
291
- private connectionStatus;
292
- private selfId;
293
- private logger;
294
- private _ownsLocalMedia;
295
- private displayName?;
296
- private externalId?;
297
- private _roomKey;
298
- constructor(roomUrl: string, { displayName, localMedia, localMediaOptions: localMediaConstraints, logger, roomKey, externalId, }: RoomConnectionOptions);
299
- get roomKey(): string | null;
300
- private _handleNewChatMessage;
301
- private _handleCloudRecordingStarted;
302
- private _handleRecorderClientJoined;
303
- private _handleStreamingStarted;
304
- private _handleNewClient;
305
- private _handleClientLeft;
306
- private _handleClientAudioEnabled;
307
- private _handleClientVideoEnabled;
308
- private _handleClientMetadataReceived;
309
- private _handleKnockHandled;
310
- private _handleKnockerLeft;
311
- private _handleRoomJoined;
312
- private _handleRoomKnocked;
313
- private _handleReconnect;
314
- private _handleDisconnect;
315
- private _handleCloudRecordingStopped;
316
- private _handleStreamingStopped;
317
- private _handleScreenshareStarted;
318
- private _handleScreenshareStopped;
319
- private _handleRtcEvent;
320
- private _handleRtcManagerCreated;
321
- private _handleRtcManagerDestroyed;
322
- private _handleAcceptStreams;
323
- private _handleStreamAdded;
324
- private _joinRoom;
325
- join(): Promise<void>;
326
- knock(): void;
327
- leave(): void;
328
- sendChatMessage(text: string): void;
329
- setDisplayName(displayName: string): void;
330
- acceptWaitingParticipant(participantId: string): void;
331
- rejectWaitingParticipant(participantId: string): void;
332
- updateStreamResolution({ streamId, width, height }: {
333
- streamId?: string;
334
- width: number;
335
- height: number;
336
- }): void;
337
- startScreenshare(): Promise<void>;
338
- stopScreenshare(): void;
339
- startCloudRecording(): void;
340
- stopCloudRecording(): void;
708
+ /**
709
+ * Reducer
710
+ */
711
+ interface LocalMediaState$1 {
712
+ busyDeviceIds: string[];
713
+ cameraDeviceError?: unknown;
714
+ cameraEnabled: boolean;
715
+ currentCameraDeviceId?: string;
716
+ currentMicrophoneDeviceId?: string;
717
+ devices: MediaDeviceInfo[];
718
+ isSettingCameraDevice: boolean;
719
+ isSettingMicrophoneDevice: boolean;
720
+ isTogglingCamera: boolean;
721
+ microphoneDeviceError?: unknown;
722
+ microphoneEnabled: boolean;
723
+ options?: LocalMediaOptions;
724
+ status: "" | "stopped" | "starting" | "started" | "error";
725
+ startError?: unknown;
726
+ stream?: MediaStream;
727
+ isSwitchingStream: boolean;
728
+ onDeviceChange?: () => void;
341
729
  }
342
730
 
343
- type RemoteParticipantState = Omit<RemoteParticipant, "updateStreamState" | "newJoiner" | "streams" | "addStream" | "removeStream">;
731
+ interface LocalMediaState {
732
+ currentCameraDeviceId?: string;
733
+ currentMicrophoneDeviceId?: string;
734
+ cameraDeviceError: unknown;
735
+ cameraDevices: MediaDeviceInfo[];
736
+ isSettingCameraDevice: boolean;
737
+ isSettingMicrophoneDevice: boolean;
738
+ isStarting: boolean;
739
+ localStream?: MediaStream;
740
+ microphoneDeviceError: unknown;
741
+ microphoneDevices: MediaDeviceInfo[];
742
+ speakerDevices: MediaDeviceInfo[];
743
+ startError: unknown;
744
+ }
745
+ interface LocalMediaActions {
746
+ setCameraDevice: (deviceId: string) => void;
747
+ setMicrophoneDevice: (deviceId: string) => void;
748
+ toggleCameraEnabled: (enabled?: boolean) => void;
749
+ toggleMicrophoneEnabled: (enabled?: boolean) => void;
750
+ }
751
+ type UseLocalMediaResult = {
752
+ state: LocalMediaState;
753
+ actions: LocalMediaActions;
754
+ store: Store;
755
+ };
756
+ type UseLocalMediaOptions = LocalMediaOptions;
757
+
758
+ type RemoteParticipantState = Omit<RemoteParticipant, "newJoiner" | "streams">;
344
759
  type LocalParticipantState = LocalParticipant;
345
760
  interface WaitingParticipantState {
346
761
  id: string;
@@ -353,6 +768,17 @@ interface ChatMessageState {
353
768
  }
354
769
  type ScreenshareState = Screenshare;
355
770
  type LocalScreenshareStatus = "starting" | "active";
771
+ type ChatMessage = Pick<ChatMessage$2, "senderId" | "timestamp" | "text">;
772
+ type ConnectionStatus = "initializing" | "connecting" | "connected" | "reconnect" | "room_locked" | "knocking" | "disconnecting" | "disconnected" | "knock_rejected";
773
+ type CloudRecordingState = {
774
+ error?: string;
775
+ status: "recording" | "requested" | "error";
776
+ startedAt?: number;
777
+ };
778
+ type LiveStreamState = {
779
+ status: "streaming";
780
+ startedAt?: number;
781
+ };
356
782
  interface RoomConnectionState {
357
783
  chatMessages: ChatMessage[];
358
784
  cloudRecording?: CloudRecordingState;
@@ -364,8 +790,15 @@ interface RoomConnectionState {
364
790
  liveStream?: LiveStreamState;
365
791
  waitingParticipants: WaitingParticipantState[];
366
792
  }
793
+ interface RoomConnectionOptions {
794
+ displayName?: string;
795
+ localMediaOptions?: LocalMediaOptions;
796
+ roomKey?: string;
797
+ localMedia?: UseLocalMediaResult;
798
+ externalId?: string;
799
+ }
367
800
  interface UseRoomConnectionOptions extends Omit<RoomConnectionOptions, "localMedia"> {
368
- localMedia?: LocalMediaRef;
801
+ localMedia?: UseLocalMediaResult;
369
802
  }
370
803
  interface RoomConnectionActions {
371
804
  sendChatMessage(text: string): void;
@@ -380,6 +813,7 @@ interface RoomConnectionActions {
380
813
  stopCloudRecording(): void;
381
814
  stopScreenshare(): void;
382
815
  }
816
+
383
817
  type VideoViewComponentProps = Omit<React.ComponentProps<typeof _default>, "onResize">;
384
818
  interface RoomConnectionComponents {
385
819
  VideoView: (props: VideoViewComponentProps) => ReturnType<typeof _default>;
@@ -388,10 +822,12 @@ type RoomConnectionRef = {
388
822
  state: RoomConnectionState;
389
823
  actions: RoomConnectionActions;
390
824
  components: RoomConnectionComponents;
391
- _ref: RoomConnection;
825
+ _ref: Store;
392
826
  };
393
827
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions?: UseRoomConnectionOptions): RoomConnectionRef;
394
828
 
829
+ declare function useLocalMedia(optionsOrStream?: UseLocalMediaOptions | MediaStream): UseLocalMediaResult;
830
+
395
831
  declare const sdkVersion = "__SDK_VERSION__";
396
832
 
397
- export { type ChatMessageState as ChatMessage, type LocalParticipantState as LocalParticipant, type RemoteParticipantState as RemoteParticipant, type RoomConnectionState as RoomConnection, type ScreenshareState as Screenshare, type LocalMediaRef as UseLocalMediaResult, _default as VideoView, type WaitingParticipantState as WaitingParticipant, sdkVersion, useLocalMedia, useRoomConnection };
833
+ export { type ChatMessageState as ChatMessage, type LocalParticipantState as LocalParticipant, type RemoteParticipantState as RemoteParticipant, type RoomConnectionState as RoomConnection, type ScreenshareState as Screenshare, type UseLocalMediaResult, _default as VideoView, type WaitingParticipantState as WaitingParticipant, sdkVersion, useLocalMedia, useRoomConnection };