@whereby.com/browser-sdk 2.0.0-beta3 → 2.0.0-beta4

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,691 @@ 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
+ status: ConnectionStatus$1;
588
+ error: unknown;
589
+ }
590
+
591
+ /**
592
+ * Reducer
593
+ */
594
+ interface StreamResolutionUpdate {
595
+ streamId: string;
596
+ width: number;
597
+ height: number;
598
+ }
599
+ interface RtcConnectionState {
600
+ dispatcherCreated: boolean;
601
+ error: unknown;
602
+ isCreatingDispatcher: boolean;
603
+ reportedStreamResolutions: {
604
+ [streamId: string]: Omit<StreamResolutionUpdate, "streamId">;
605
+ };
606
+ rtcManager: RtcManager | null;
607
+ rtcManagerDispatcher: RtcManagerDispatcher | null;
608
+ rtcManagerInitialized: boolean;
609
+ status: "" | "ready" | "reconnect";
610
+ isAcceptingStreams: boolean;
611
+ }
612
+
613
+ /**
614
+ * Reducer
615
+ */
616
+ interface SignalConnectionState {
617
+ deviceIdentified: boolean;
618
+ isIdentifyingDevice: boolean;
619
+ status: "connected" | "connecting" | "disconnected" | "reconnect" | "";
620
+ socket: _whereby_jslib_media_src_utils_ServerSocket | null;
621
+ }
622
+
623
+ declare function createServices(): {
624
+ credentialsService: CredentialsService;
625
+ apiClient: ApiClient;
626
+ organizationService: OrganizationService;
627
+ fetchOrganizationFromRoomUrl: (roomUrl: string) => Promise<Organization | null>;
237
628
  };
238
- type LocalMicrophoneEnabledEvent = {
239
- enabled: boolean;
629
+
630
+ declare const createStore: ({ preloadedState, injectServices, }: {
631
+ preloadedState?: Partial<{
632
+ app: AppState;
633
+ chat: ChatState;
634
+ cloudRecording: CloudRecordingState$1;
635
+ deviceCredentials: DeviceCredentialsState;
636
+ localMedia: LocalMediaState$1;
637
+ localParticipant: LocalParticipantState$1;
638
+ localScreenshare: LocalScreenshareState;
639
+ organization: OrganizationState;
640
+ remoteParticipants: RemoteParticipantState$1;
641
+ roomConnection: RoomConnectionState$1;
642
+ rtcAnalytics: rtcAnalyticsState;
643
+ rtcConnection: RtcConnectionState;
644
+ signalConnection: SignalConnectionState;
645
+ streaming: StreamingState;
646
+ waitingParticipants: WaitingParticipantsState;
647
+ }> | undefined;
648
+ injectServices: ReturnType<typeof createServices>;
649
+ }) => _reduxjs_toolkit.EnhancedStore<{
650
+ app: AppState;
651
+ chat: ChatState;
652
+ cloudRecording: CloudRecordingState$1;
653
+ deviceCredentials: DeviceCredentialsState;
654
+ localMedia: LocalMediaState$1;
655
+ localParticipant: LocalParticipantState$1;
656
+ localScreenshare: LocalScreenshareState;
657
+ organization: OrganizationState;
658
+ remoteParticipants: RemoteParticipantState$1;
659
+ roomConnection: RoomConnectionState$1;
660
+ rtcAnalytics: rtcAnalyticsState;
661
+ rtcConnection: RtcConnectionState;
662
+ signalConnection: SignalConnectionState;
663
+ streaming: StreamingState;
664
+ waitingParticipants: WaitingParticipantsState;
665
+ }, redux.UnknownAction, _reduxjs_toolkit.Tuple<[redux.StoreEnhancer<{
666
+ dispatch: ((action: redux.Action<"listenerMiddleware/add">) => _reduxjs_toolkit.UnsubscribeListener) & redux_thunk.ThunkDispatch<{
667
+ app: AppState;
668
+ chat: ChatState;
669
+ cloudRecording: CloudRecordingState$1;
670
+ deviceCredentials: DeviceCredentialsState;
671
+ localMedia: LocalMediaState$1;
672
+ localParticipant: LocalParticipantState$1;
673
+ localScreenshare: LocalScreenshareState;
674
+ organization: OrganizationState;
675
+ remoteParticipants: RemoteParticipantState$1;
676
+ roomConnection: RoomConnectionState$1;
677
+ rtcAnalytics: rtcAnalyticsState;
678
+ rtcConnection: RtcConnectionState;
679
+ signalConnection: SignalConnectionState;
680
+ streaming: StreamingState;
681
+ waitingParticipants: WaitingParticipantsState;
682
+ }, {
683
+ services: {
684
+ credentialsService: CredentialsService;
685
+ apiClient: ApiClient;
686
+ organizationService: OrganizationService;
687
+ fetchOrganizationFromRoomUrl: (roomUrl: string) => Promise<Organization | null>;
688
+ };
689
+ }, redux.UnknownAction>;
690
+ }, {}>, redux.StoreEnhancer<{}, {}>]>>;
691
+ type Store = ReturnType<typeof createStore>;
692
+
693
+ /**
694
+ * Reducer
695
+ */
696
+ interface WaitingParticipantsState {
697
+ waitingParticipants: WaitingParticipant[];
698
+ }
699
+
700
+ type LocalMediaOptions = {
701
+ audio: boolean;
702
+ video: boolean;
240
703
  };
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;
704
+ /**
705
+ * Reducer
706
+ */
707
+ interface LocalMediaState$1 {
708
+ busyDeviceIds: string[];
709
+ cameraDeviceError?: unknown;
710
+ cameraEnabled: boolean;
711
+ currentCameraDeviceId?: string;
712
+ currentMicrophoneDeviceId?: string;
713
+ devices: MediaDeviceInfo[];
714
+ isSettingCameraDevice: boolean;
715
+ isSettingMicrophoneDevice: boolean;
716
+ isTogglingCamera: boolean;
717
+ microphoneDeviceError?: unknown;
718
+ microphoneEnabled: boolean;
719
+ options?: LocalMediaOptions;
720
+ status: "" | "stopped" | "starting" | "started" | "error";
721
+ startError?: unknown;
722
+ stream?: MediaStream;
723
+ isSwitchingStream: boolean;
724
+ onDeviceChange?: () => void;
341
725
  }
342
726
 
343
- type RemoteParticipantState = Omit<RemoteParticipant, "updateStreamState" | "newJoiner" | "streams" | "addStream" | "removeStream">;
727
+ interface LocalMediaState {
728
+ currentCameraDeviceId?: string;
729
+ currentMicrophoneDeviceId?: string;
730
+ cameraDeviceError: unknown;
731
+ cameraDevices: MediaDeviceInfo[];
732
+ isSettingCameraDevice: boolean;
733
+ isSettingMicrophoneDevice: boolean;
734
+ isStarting: boolean;
735
+ localStream?: MediaStream;
736
+ microphoneDeviceError: unknown;
737
+ microphoneDevices: MediaDeviceInfo[];
738
+ speakerDevices: MediaDeviceInfo[];
739
+ startError: unknown;
740
+ }
741
+ interface LocalMediaActions {
742
+ setCameraDevice: (deviceId: string) => void;
743
+ setMicrophoneDevice: (deviceId: string) => void;
744
+ toggleCameraEnabled: (enabled?: boolean) => void;
745
+ toggleMicrophoneEnabled: (enabled?: boolean) => void;
746
+ }
747
+ type UseLocalMediaResult = {
748
+ state: LocalMediaState;
749
+ actions: LocalMediaActions;
750
+ store: Store;
751
+ };
752
+ type UseLocalMediaOptions = LocalMediaOptions;
753
+
754
+ type RemoteParticipantState = Omit<RemoteParticipant, "newJoiner" | "streams">;
344
755
  type LocalParticipantState = LocalParticipant;
345
756
  interface WaitingParticipantState {
346
757
  id: string;
@@ -353,6 +764,17 @@ interface ChatMessageState {
353
764
  }
354
765
  type ScreenshareState = Screenshare;
355
766
  type LocalScreenshareStatus = "starting" | "active";
767
+ type ChatMessage = Pick<ChatMessage$2, "senderId" | "timestamp" | "text">;
768
+ type ConnectionStatus = "initializing" | "connecting" | "connected" | "reconnect" | "room_locked" | "knocking" | "disconnecting" | "disconnected" | "knock_rejected";
769
+ type CloudRecordingState = {
770
+ error?: string;
771
+ status: "recording" | "requested" | "error";
772
+ startedAt?: number;
773
+ };
774
+ type LiveStreamState = {
775
+ status: "streaming";
776
+ startedAt?: number;
777
+ };
356
778
  interface RoomConnectionState {
357
779
  chatMessages: ChatMessage[];
358
780
  cloudRecording?: CloudRecordingState;
@@ -364,8 +786,15 @@ interface RoomConnectionState {
364
786
  liveStream?: LiveStreamState;
365
787
  waitingParticipants: WaitingParticipantState[];
366
788
  }
789
+ interface RoomConnectionOptions {
790
+ displayName?: string;
791
+ localMediaOptions?: LocalMediaOptions;
792
+ roomKey?: string;
793
+ localMedia?: UseLocalMediaResult;
794
+ externalId?: string;
795
+ }
367
796
  interface UseRoomConnectionOptions extends Omit<RoomConnectionOptions, "localMedia"> {
368
- localMedia?: LocalMediaRef;
797
+ localMedia?: UseLocalMediaResult;
369
798
  }
370
799
  interface RoomConnectionActions {
371
800
  sendChatMessage(text: string): void;
@@ -380,6 +809,7 @@ interface RoomConnectionActions {
380
809
  stopCloudRecording(): void;
381
810
  stopScreenshare(): void;
382
811
  }
812
+
383
813
  type VideoViewComponentProps = Omit<React.ComponentProps<typeof _default>, "onResize">;
384
814
  interface RoomConnectionComponents {
385
815
  VideoView: (props: VideoViewComponentProps) => ReturnType<typeof _default>;
@@ -388,10 +818,12 @@ type RoomConnectionRef = {
388
818
  state: RoomConnectionState;
389
819
  actions: RoomConnectionActions;
390
820
  components: RoomConnectionComponents;
391
- _ref: RoomConnection;
821
+ _ref: Store;
392
822
  };
393
823
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions?: UseRoomConnectionOptions): RoomConnectionRef;
394
824
 
825
+ declare function useLocalMedia(optionsOrStream?: UseLocalMediaOptions | MediaStream): UseLocalMediaResult;
826
+
395
827
  declare const sdkVersion = "__SDK_VERSION__";
396
828
 
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 };
829
+ 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 };