sabha-meetings-react 0.1.5 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,10 +2,11 @@ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  type SabhaTokens = {
5
- /** Optional bearer token (Postman-style). Live API primarily uses `vm_session` cookie. */
5
+ /** Bearer access token from login `token` (Postman `accessToken`). */
6
6
  accessToken?: string;
7
+ /** Refresh token from login `refreshToken` (Postman). */
7
8
  refreshToken?: string;
8
- /** Session cookie value when running outside the browser (Node / RN). */
9
+ /** Optional legacy `vm_session` cookie / x-sabha-session bridge. */
9
10
  sessionCookie?: string;
10
11
  };
11
12
  type SabhaConfig = {
@@ -19,11 +20,11 @@ type SabhaConfig = {
19
20
  /** Optional bearer access token */
20
21
  accessToken?: string;
21
22
  refreshToken?: string;
22
- /** Persist/reuse `vm_session` (also sent as x-sabha-session for proxies). */
23
+ /** Optional legacy `vm_session` (also sent as x-sabha-session for proxies). */
23
24
  sessionCookie?: string;
24
25
  /**
25
- * Persist `vm_session` in localStorage after login and restore on configure.
26
- * Default true in browsers.
26
+ * Persist access/refresh tokens (and optional vm_session) after login and restore on configure.
27
+ * Matches Postman collection variables. Default true.
27
28
  */
28
29
  persistSession?: boolean;
29
30
  /** Send cookies (`credentials: "include"`). Default true. */
@@ -145,10 +146,13 @@ type UpdateMeetingInput = {
145
146
  [key: string]: unknown;
146
147
  };
147
148
  type MeetingConnectionState = "disconnected" | "connecting" | "connected" | "joined" | "error";
149
+ /** Host publishes A/V; participants join to view the host only. */
150
+ type MeetingRole = "host" | "participant";
148
151
  type MeetingParticipant = {
149
152
  id: string;
150
153
  displayName?: string;
151
154
  username?: string;
155
+ role?: MeetingRole;
152
156
  audioEnabled?: boolean;
153
157
  videoEnabled?: boolean;
154
158
  screenSharing?: boolean;
@@ -187,6 +191,8 @@ type MeetingRoomEventMap = {
187
191
  reason?: string;
188
192
  };
189
193
  mediaState: LocalMediaState;
194
+ /** Host media received by a participant (one-way). */
195
+ remoteStream: MediaStream | null;
190
196
  captureAttempt: {
191
197
  type: "screenshot" | "recording" | "visibility";
192
198
  at: string;
@@ -268,6 +274,10 @@ type MeetingConnectionOptions = {
268
274
  socketPath?: string;
269
275
  events?: Partial<SabhaSocketEvents>;
270
276
  mediaPolicy?: Partial<MediaPolicy>;
277
+ /** Host publishes A/V; participant receives host stream only. Default host. */
278
+ role?: MeetingRole;
279
+ /** Stable id for WebRTC signaling (usually Sabha userId). */
280
+ selfId?: string;
271
281
  };
272
282
  declare class MeetingConnection {
273
283
  private readonly options;
@@ -275,15 +285,21 @@ declare class MeetingConnection {
275
285
  private state;
276
286
  private readonly events;
277
287
  private readonly mediaPolicy;
288
+ private readonly role;
289
+ private readonly selfId;
278
290
  readonly media: MediaController;
279
291
  readonly protection: ContentProtection;
280
292
  private readonly listeners;
281
293
  private mediaUnsub;
282
294
  private captureUnsub;
295
+ private readonly peers;
296
+ private remoteStream;
283
297
  constructor(options: MeetingConnectionOptions);
284
298
  get meetingId(): string;
299
+ get meetingRole(): MeetingRole;
285
300
  get connectionState(): MeetingConnectionState;
286
301
  getMediaState(): LocalMediaState;
302
+ getRemoteStream(): MediaStream | null;
287
303
  on<K extends keyof MeetingRoomEventMap>(event: K, listener: Listener<MeetingRoomEventMap[K]>): () => void;
288
304
  connect(): Promise<void>;
289
305
  setAudioEnabled(enabled: boolean): Promise<LocalMediaState>;
@@ -297,6 +313,13 @@ declare class MeetingConnection {
297
313
  private teardownMedia;
298
314
  private join;
299
315
  private bindServerEvents;
316
+ private sendSignal;
317
+ private handleSignal;
318
+ private createHostOffer;
319
+ private getOrCreatePeer;
320
+ private attachLocalTracks;
321
+ private refreshHostTracks;
322
+ private closePeer;
300
323
  private setState;
301
324
  private emit;
302
325
  }
@@ -343,10 +366,13 @@ declare class SabhaClient {
343
366
  meeting: Meeting;
344
367
  connection: MeetingConnection;
345
368
  }>;
346
- connect(meetingId: string): Promise<MeetingConnection>;
369
+ connect(meetingId: string, options?: {
370
+ role?: MeetingRole;
371
+ }): Promise<MeetingConnection>;
347
372
  getConnection(): MeetingConnection | null;
348
373
  leaveMeeting(): Promise<void>;
349
374
  private applySession;
375
+ private persistTokens;
350
376
  private persistSessionCookie;
351
377
  private tryRefresh;
352
378
  private getOrigin;
@@ -405,7 +431,9 @@ declare function useSabhaMeetings(): {
405
431
  meeting: Meeting;
406
432
  connection: MeetingConnection;
407
433
  }>;
408
- connect: (meetingId: string) => Promise<MeetingConnection>;
434
+ connect: (meetingId: string, options?: {
435
+ role?: MeetingRole;
436
+ }) => Promise<MeetingConnection>;
409
437
  leaveMeeting: () => Promise<void>;
410
438
  connection: MeetingConnection | null;
411
439
  connectionState: MeetingConnectionState;
@@ -435,9 +463,14 @@ declare function normalizeMeeting(raw: unknown): Meeting;
435
463
 
436
464
  /** Readable session bridge header (browsers cannot set the Cookie request header). */
437
465
  declare const SABHA_SESSION_HEADER = "x-sabha-session";
466
+ /** @deprecated Prefer SABHA_TOKENS_STORAGE_KEY — kept for one-time migration. */
438
467
  declare const SABHA_SESSION_STORAGE_KEY = "sabha_vm_session";
468
+ /** Persists Postman-style `accessToken` / `refreshToken` (+ optional vm_session). */
469
+ declare const SABHA_TOKENS_STORAGE_KEY = "sabha_auth_tokens";
470
+ declare function readStoredTokens(): SabhaTokens | null;
471
+ declare function writeStoredTokens(tokens: SabhaTokens | null): void;
439
472
  declare function readStoredSessionCookie(): string | null;
440
473
  declare function writeStoredSessionCookie(value: string | null): void;
441
474
 
442
- export { ContentProtection, DEFAULT_BASE_URL, DEFAULT_MEDIA_POLICY, MediaController, MeetingConnection, SABHA_SESSION_HEADER, SABHA_SESSION_STORAGE_KEY, SabhaClient, SabhaError, SabhaProvider, createSabhaClient, normalizeMeeting, readStoredSessionCookie, toSabhaError, useSabha, useSabhaMeetings, writeStoredSessionCookie };
443
- export type { AuthSession, AuthUser, CaptureAttemptType, CreateMeetingInput, LocalMediaState, LoginInput, MediaPolicy, MediaTrackKind, Meeting, MeetingConnectionOptions, MeetingConnectionState, MeetingInvitee, MeetingOrganizer, MeetingParticipant, MeetingRoomEventMap, RegisterInput, SabhaClientStatus, SabhaConfig, SabhaContextValue, SabhaOrg, SabhaProviderProps, SabhaSocketEvents, SabhaTokens, UpdateMeetingInput, VerifyEmailInput };
475
+ export { ContentProtection, DEFAULT_BASE_URL, DEFAULT_MEDIA_POLICY, MediaController, MeetingConnection, SABHA_SESSION_HEADER, SABHA_SESSION_STORAGE_KEY, SABHA_TOKENS_STORAGE_KEY, SabhaClient, SabhaError, SabhaProvider, createSabhaClient, normalizeMeeting, readStoredSessionCookie, readStoredTokens, toSabhaError, useSabha, useSabhaMeetings, writeStoredSessionCookie, writeStoredTokens };
476
+ export type { AuthSession, AuthUser, CaptureAttemptType, CreateMeetingInput, LocalMediaState, LoginInput, MediaPolicy, MediaTrackKind, Meeting, MeetingConnectionOptions, MeetingConnectionState, MeetingInvitee, MeetingOrganizer, MeetingParticipant, MeetingRole, MeetingRoomEventMap, RegisterInput, SabhaClientStatus, SabhaConfig, SabhaContextValue, SabhaOrg, SabhaProviderProps, SabhaSocketEvents, SabhaTokens, UpdateMeetingInput, VerifyEmailInput };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,11 @@ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  type SabhaTokens = {
5
- /** Optional bearer token (Postman-style). Live API primarily uses `vm_session` cookie. */
5
+ /** Bearer access token from login `token` (Postman `accessToken`). */
6
6
  accessToken?: string;
7
+ /** Refresh token from login `refreshToken` (Postman). */
7
8
  refreshToken?: string;
8
- /** Session cookie value when running outside the browser (Node / RN). */
9
+ /** Optional legacy `vm_session` cookie / x-sabha-session bridge. */
9
10
  sessionCookie?: string;
10
11
  };
11
12
  type SabhaConfig = {
@@ -19,11 +20,11 @@ type SabhaConfig = {
19
20
  /** Optional bearer access token */
20
21
  accessToken?: string;
21
22
  refreshToken?: string;
22
- /** Persist/reuse `vm_session` (also sent as x-sabha-session for proxies). */
23
+ /** Optional legacy `vm_session` (also sent as x-sabha-session for proxies). */
23
24
  sessionCookie?: string;
24
25
  /**
25
- * Persist `vm_session` in localStorage after login and restore on configure.
26
- * Default true in browsers.
26
+ * Persist access/refresh tokens (and optional vm_session) after login and restore on configure.
27
+ * Matches Postman collection variables. Default true.
27
28
  */
28
29
  persistSession?: boolean;
29
30
  /** Send cookies (`credentials: "include"`). Default true. */
@@ -145,10 +146,13 @@ type UpdateMeetingInput = {
145
146
  [key: string]: unknown;
146
147
  };
147
148
  type MeetingConnectionState = "disconnected" | "connecting" | "connected" | "joined" | "error";
149
+ /** Host publishes A/V; participants join to view the host only. */
150
+ type MeetingRole = "host" | "participant";
148
151
  type MeetingParticipant = {
149
152
  id: string;
150
153
  displayName?: string;
151
154
  username?: string;
155
+ role?: MeetingRole;
152
156
  audioEnabled?: boolean;
153
157
  videoEnabled?: boolean;
154
158
  screenSharing?: boolean;
@@ -187,6 +191,8 @@ type MeetingRoomEventMap = {
187
191
  reason?: string;
188
192
  };
189
193
  mediaState: LocalMediaState;
194
+ /** Host media received by a participant (one-way). */
195
+ remoteStream: MediaStream | null;
190
196
  captureAttempt: {
191
197
  type: "screenshot" | "recording" | "visibility";
192
198
  at: string;
@@ -268,6 +274,10 @@ type MeetingConnectionOptions = {
268
274
  socketPath?: string;
269
275
  events?: Partial<SabhaSocketEvents>;
270
276
  mediaPolicy?: Partial<MediaPolicy>;
277
+ /** Host publishes A/V; participant receives host stream only. Default host. */
278
+ role?: MeetingRole;
279
+ /** Stable id for WebRTC signaling (usually Sabha userId). */
280
+ selfId?: string;
271
281
  };
272
282
  declare class MeetingConnection {
273
283
  private readonly options;
@@ -275,15 +285,21 @@ declare class MeetingConnection {
275
285
  private state;
276
286
  private readonly events;
277
287
  private readonly mediaPolicy;
288
+ private readonly role;
289
+ private readonly selfId;
278
290
  readonly media: MediaController;
279
291
  readonly protection: ContentProtection;
280
292
  private readonly listeners;
281
293
  private mediaUnsub;
282
294
  private captureUnsub;
295
+ private readonly peers;
296
+ private remoteStream;
283
297
  constructor(options: MeetingConnectionOptions);
284
298
  get meetingId(): string;
299
+ get meetingRole(): MeetingRole;
285
300
  get connectionState(): MeetingConnectionState;
286
301
  getMediaState(): LocalMediaState;
302
+ getRemoteStream(): MediaStream | null;
287
303
  on<K extends keyof MeetingRoomEventMap>(event: K, listener: Listener<MeetingRoomEventMap[K]>): () => void;
288
304
  connect(): Promise<void>;
289
305
  setAudioEnabled(enabled: boolean): Promise<LocalMediaState>;
@@ -297,6 +313,13 @@ declare class MeetingConnection {
297
313
  private teardownMedia;
298
314
  private join;
299
315
  private bindServerEvents;
316
+ private sendSignal;
317
+ private handleSignal;
318
+ private createHostOffer;
319
+ private getOrCreatePeer;
320
+ private attachLocalTracks;
321
+ private refreshHostTracks;
322
+ private closePeer;
300
323
  private setState;
301
324
  private emit;
302
325
  }
@@ -343,10 +366,13 @@ declare class SabhaClient {
343
366
  meeting: Meeting;
344
367
  connection: MeetingConnection;
345
368
  }>;
346
- connect(meetingId: string): Promise<MeetingConnection>;
369
+ connect(meetingId: string, options?: {
370
+ role?: MeetingRole;
371
+ }): Promise<MeetingConnection>;
347
372
  getConnection(): MeetingConnection | null;
348
373
  leaveMeeting(): Promise<void>;
349
374
  private applySession;
375
+ private persistTokens;
350
376
  private persistSessionCookie;
351
377
  private tryRefresh;
352
378
  private getOrigin;
@@ -405,7 +431,9 @@ declare function useSabhaMeetings(): {
405
431
  meeting: Meeting;
406
432
  connection: MeetingConnection;
407
433
  }>;
408
- connect: (meetingId: string) => Promise<MeetingConnection>;
434
+ connect: (meetingId: string, options?: {
435
+ role?: MeetingRole;
436
+ }) => Promise<MeetingConnection>;
409
437
  leaveMeeting: () => Promise<void>;
410
438
  connection: MeetingConnection | null;
411
439
  connectionState: MeetingConnectionState;
@@ -435,9 +463,14 @@ declare function normalizeMeeting(raw: unknown): Meeting;
435
463
 
436
464
  /** Readable session bridge header (browsers cannot set the Cookie request header). */
437
465
  declare const SABHA_SESSION_HEADER = "x-sabha-session";
466
+ /** @deprecated Prefer SABHA_TOKENS_STORAGE_KEY — kept for one-time migration. */
438
467
  declare const SABHA_SESSION_STORAGE_KEY = "sabha_vm_session";
468
+ /** Persists Postman-style `accessToken` / `refreshToken` (+ optional vm_session). */
469
+ declare const SABHA_TOKENS_STORAGE_KEY = "sabha_auth_tokens";
470
+ declare function readStoredTokens(): SabhaTokens | null;
471
+ declare function writeStoredTokens(tokens: SabhaTokens | null): void;
439
472
  declare function readStoredSessionCookie(): string | null;
440
473
  declare function writeStoredSessionCookie(value: string | null): void;
441
474
 
442
- export { ContentProtection, DEFAULT_BASE_URL, DEFAULT_MEDIA_POLICY, MediaController, MeetingConnection, SABHA_SESSION_HEADER, SABHA_SESSION_STORAGE_KEY, SabhaClient, SabhaError, SabhaProvider, createSabhaClient, normalizeMeeting, readStoredSessionCookie, toSabhaError, useSabha, useSabhaMeetings, writeStoredSessionCookie };
443
- export type { AuthSession, AuthUser, CaptureAttemptType, CreateMeetingInput, LocalMediaState, LoginInput, MediaPolicy, MediaTrackKind, Meeting, MeetingConnectionOptions, MeetingConnectionState, MeetingInvitee, MeetingOrganizer, MeetingParticipant, MeetingRoomEventMap, RegisterInput, SabhaClientStatus, SabhaConfig, SabhaContextValue, SabhaOrg, SabhaProviderProps, SabhaSocketEvents, SabhaTokens, UpdateMeetingInput, VerifyEmailInput };
475
+ export { ContentProtection, DEFAULT_BASE_URL, DEFAULT_MEDIA_POLICY, MediaController, MeetingConnection, SABHA_SESSION_HEADER, SABHA_SESSION_STORAGE_KEY, SABHA_TOKENS_STORAGE_KEY, SabhaClient, SabhaError, SabhaProvider, createSabhaClient, normalizeMeeting, readStoredSessionCookie, readStoredTokens, toSabhaError, useSabha, useSabhaMeetings, writeStoredSessionCookie, writeStoredTokens };
476
+ export type { AuthSession, AuthUser, CaptureAttemptType, CreateMeetingInput, LocalMediaState, LoginInput, MediaPolicy, MediaTrackKind, Meeting, MeetingConnectionOptions, MeetingConnectionState, MeetingInvitee, MeetingOrganizer, MeetingParticipant, MeetingRole, MeetingRoomEventMap, RegisterInput, SabhaClientStatus, SabhaConfig, SabhaContextValue, SabhaOrg, SabhaProviderProps, SabhaSocketEvents, SabhaTokens, UpdateMeetingInput, VerifyEmailInput };