@poolse/sdk 2.8.3 → 2.9.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.
- package/dist/index.cjs +52 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +52 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -526,6 +526,20 @@ interface VoiceRoomOptions {
|
|
|
526
526
|
* TURN server for participants behind symmetric NAT.
|
|
527
527
|
*/
|
|
528
528
|
iceServers?: VoiceIceServer[];
|
|
529
|
+
/**
|
|
530
|
+
* Resolve ICE servers just before connecting, overriding `iceServers`.
|
|
531
|
+
*
|
|
532
|
+
* TURN credentials expire, so they cannot be handed over once at
|
|
533
|
+
* construction and reused for the life of the app — by the second call
|
|
534
|
+
* they would be rejected. `PoolseRealtime` supplies a provider backed
|
|
535
|
+
* by `GET /v1/ice-servers`, which is what makes TURN work without any
|
|
536
|
+
* app wiring.
|
|
537
|
+
*
|
|
538
|
+
* Failures are non-fatal: the room falls back to `iceServers` (or the
|
|
539
|
+
* default STUN) rather than refusing to connect. Degraded beats dead —
|
|
540
|
+
* without TURN a call still works on most networks.
|
|
541
|
+
*/
|
|
542
|
+
iceServersProvider?: () => Promise<VoiceIceServer[]>;
|
|
529
543
|
/** Platform WebRTC binding. Defaults to the browser implementation. */
|
|
530
544
|
webrtc?: WebRtcAdapter;
|
|
531
545
|
/**
|
|
@@ -694,7 +708,8 @@ declare class VoiceRoom {
|
|
|
694
708
|
readonly conversationId: string;
|
|
695
709
|
private readonly socket;
|
|
696
710
|
private readonly webrtc;
|
|
697
|
-
private
|
|
711
|
+
private iceServers;
|
|
712
|
+
private readonly iceServersProvider;
|
|
698
713
|
private readonly detectSpeaking;
|
|
699
714
|
private channel;
|
|
700
715
|
private localStream;
|
|
@@ -737,6 +752,15 @@ declare class VoiceRoom {
|
|
|
737
752
|
setMuted(muted: boolean): boolean;
|
|
738
753
|
toggleMute(): boolean;
|
|
739
754
|
private bindChannel;
|
|
755
|
+
/**
|
|
756
|
+
* Refresh ICE servers from the provider, if there is one.
|
|
757
|
+
*
|
|
758
|
+
* Never throws. A room that refused to connect because the ICE
|
|
759
|
+
* endpoint was briefly unreachable would be a worse outcome than one
|
|
760
|
+
* that connects without TURN — which is exactly how calls behaved
|
|
761
|
+
* before TURN existed, and works on most networks.
|
|
762
|
+
*/
|
|
763
|
+
private resolveIceServers;
|
|
740
764
|
/**
|
|
741
765
|
* Glare control: both sides learn about each other simultaneously, so
|
|
742
766
|
* without a rule both would offer at once. The lexicographically lower
|
|
@@ -884,11 +908,18 @@ interface RealtimeOptions {
|
|
|
884
908
|
* swapping http(s) → ws(s).
|
|
885
909
|
*/
|
|
886
910
|
wsUrl?: string;
|
|
911
|
+
/**
|
|
912
|
+
* Resolves ICE servers for voice rooms. Wired by `Poolse` to
|
|
913
|
+
* `GET /v1/ice-servers` so TURN reaches every room without the app
|
|
914
|
+
* plumbing anything.
|
|
915
|
+
*/
|
|
916
|
+
iceServersProvider?: () => Promise<VoiceIceServer[]>;
|
|
887
917
|
}
|
|
888
918
|
declare class PoolseRealtime {
|
|
889
919
|
private readonly config;
|
|
890
920
|
private readonly tokenCache;
|
|
891
921
|
private readonly socketPath;
|
|
922
|
+
private readonly iceServersProvider;
|
|
892
923
|
private readonly wsUrl;
|
|
893
924
|
private socket;
|
|
894
925
|
private readonly conversations;
|
|
@@ -1391,6 +1422,25 @@ declare class UsersResource {
|
|
|
1391
1422
|
private notify;
|
|
1392
1423
|
}
|
|
1393
1424
|
|
|
1425
|
+
interface IceServerResponse {
|
|
1426
|
+
ice_servers: VoiceIceServer[];
|
|
1427
|
+
ttl_seconds: number;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* `/v1/ice-servers` — STUN, and TURN when the deployment has it.
|
|
1431
|
+
*
|
|
1432
|
+
* Fetched rather than configured because TURN credentials are
|
|
1433
|
+
* deliberately short-lived. A client that held a static one could not
|
|
1434
|
+
* refresh it, and a TURN password compiled into a mobile binary is
|
|
1435
|
+
* extractable by anyone who wants it.
|
|
1436
|
+
*/
|
|
1437
|
+
declare class IceServersResource {
|
|
1438
|
+
private readonly client;
|
|
1439
|
+
constructor(client: RestClient);
|
|
1440
|
+
/** GET /v1/ice-servers */
|
|
1441
|
+
list(signal?: AbortSignal): Promise<IceServerResponse>;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1394
1444
|
declare class Poolse {
|
|
1395
1445
|
/** `/v1/me` — current End User. */
|
|
1396
1446
|
readonly me: MeResource;
|
|
@@ -1429,6 +1479,8 @@ declare class Poolse {
|
|
|
1429
1479
|
* `config.wsUrl`.
|
|
1430
1480
|
*/
|
|
1431
1481
|
readonly realtime: PoolseRealtime;
|
|
1482
|
+
/** STUN/TURN servers for WebRTC — see `IceServersResource`. */
|
|
1483
|
+
readonly iceServers: IceServersResource;
|
|
1432
1484
|
private readonly resolved;
|
|
1433
1485
|
private readonly tokenCache;
|
|
1434
1486
|
constructor(config: PoolseConfig);
|
|
@@ -1494,8 +1546,8 @@ declare class AuthError extends ApiError {
|
|
|
1494
1546
|
declare function isWebRtcAvailable(): boolean;
|
|
1495
1547
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1496
1548
|
|
|
1497
|
-
declare const version = "2.
|
|
1549
|
+
declare const version = "2.9.0";
|
|
1498
1550
|
|
|
1499
1551
|
declare function safeUuid(): string;
|
|
1500
1552
|
|
|
1501
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1553
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -526,6 +526,20 @@ interface VoiceRoomOptions {
|
|
|
526
526
|
* TURN server for participants behind symmetric NAT.
|
|
527
527
|
*/
|
|
528
528
|
iceServers?: VoiceIceServer[];
|
|
529
|
+
/**
|
|
530
|
+
* Resolve ICE servers just before connecting, overriding `iceServers`.
|
|
531
|
+
*
|
|
532
|
+
* TURN credentials expire, so they cannot be handed over once at
|
|
533
|
+
* construction and reused for the life of the app — by the second call
|
|
534
|
+
* they would be rejected. `PoolseRealtime` supplies a provider backed
|
|
535
|
+
* by `GET /v1/ice-servers`, which is what makes TURN work without any
|
|
536
|
+
* app wiring.
|
|
537
|
+
*
|
|
538
|
+
* Failures are non-fatal: the room falls back to `iceServers` (or the
|
|
539
|
+
* default STUN) rather than refusing to connect. Degraded beats dead —
|
|
540
|
+
* without TURN a call still works on most networks.
|
|
541
|
+
*/
|
|
542
|
+
iceServersProvider?: () => Promise<VoiceIceServer[]>;
|
|
529
543
|
/** Platform WebRTC binding. Defaults to the browser implementation. */
|
|
530
544
|
webrtc?: WebRtcAdapter;
|
|
531
545
|
/**
|
|
@@ -694,7 +708,8 @@ declare class VoiceRoom {
|
|
|
694
708
|
readonly conversationId: string;
|
|
695
709
|
private readonly socket;
|
|
696
710
|
private readonly webrtc;
|
|
697
|
-
private
|
|
711
|
+
private iceServers;
|
|
712
|
+
private readonly iceServersProvider;
|
|
698
713
|
private readonly detectSpeaking;
|
|
699
714
|
private channel;
|
|
700
715
|
private localStream;
|
|
@@ -737,6 +752,15 @@ declare class VoiceRoom {
|
|
|
737
752
|
setMuted(muted: boolean): boolean;
|
|
738
753
|
toggleMute(): boolean;
|
|
739
754
|
private bindChannel;
|
|
755
|
+
/**
|
|
756
|
+
* Refresh ICE servers from the provider, if there is one.
|
|
757
|
+
*
|
|
758
|
+
* Never throws. A room that refused to connect because the ICE
|
|
759
|
+
* endpoint was briefly unreachable would be a worse outcome than one
|
|
760
|
+
* that connects without TURN — which is exactly how calls behaved
|
|
761
|
+
* before TURN existed, and works on most networks.
|
|
762
|
+
*/
|
|
763
|
+
private resolveIceServers;
|
|
740
764
|
/**
|
|
741
765
|
* Glare control: both sides learn about each other simultaneously, so
|
|
742
766
|
* without a rule both would offer at once. The lexicographically lower
|
|
@@ -884,11 +908,18 @@ interface RealtimeOptions {
|
|
|
884
908
|
* swapping http(s) → ws(s).
|
|
885
909
|
*/
|
|
886
910
|
wsUrl?: string;
|
|
911
|
+
/**
|
|
912
|
+
* Resolves ICE servers for voice rooms. Wired by `Poolse` to
|
|
913
|
+
* `GET /v1/ice-servers` so TURN reaches every room without the app
|
|
914
|
+
* plumbing anything.
|
|
915
|
+
*/
|
|
916
|
+
iceServersProvider?: () => Promise<VoiceIceServer[]>;
|
|
887
917
|
}
|
|
888
918
|
declare class PoolseRealtime {
|
|
889
919
|
private readonly config;
|
|
890
920
|
private readonly tokenCache;
|
|
891
921
|
private readonly socketPath;
|
|
922
|
+
private readonly iceServersProvider;
|
|
892
923
|
private readonly wsUrl;
|
|
893
924
|
private socket;
|
|
894
925
|
private readonly conversations;
|
|
@@ -1391,6 +1422,25 @@ declare class UsersResource {
|
|
|
1391
1422
|
private notify;
|
|
1392
1423
|
}
|
|
1393
1424
|
|
|
1425
|
+
interface IceServerResponse {
|
|
1426
|
+
ice_servers: VoiceIceServer[];
|
|
1427
|
+
ttl_seconds: number;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* `/v1/ice-servers` — STUN, and TURN when the deployment has it.
|
|
1431
|
+
*
|
|
1432
|
+
* Fetched rather than configured because TURN credentials are
|
|
1433
|
+
* deliberately short-lived. A client that held a static one could not
|
|
1434
|
+
* refresh it, and a TURN password compiled into a mobile binary is
|
|
1435
|
+
* extractable by anyone who wants it.
|
|
1436
|
+
*/
|
|
1437
|
+
declare class IceServersResource {
|
|
1438
|
+
private readonly client;
|
|
1439
|
+
constructor(client: RestClient);
|
|
1440
|
+
/** GET /v1/ice-servers */
|
|
1441
|
+
list(signal?: AbortSignal): Promise<IceServerResponse>;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1394
1444
|
declare class Poolse {
|
|
1395
1445
|
/** `/v1/me` — current End User. */
|
|
1396
1446
|
readonly me: MeResource;
|
|
@@ -1429,6 +1479,8 @@ declare class Poolse {
|
|
|
1429
1479
|
* `config.wsUrl`.
|
|
1430
1480
|
*/
|
|
1431
1481
|
readonly realtime: PoolseRealtime;
|
|
1482
|
+
/** STUN/TURN servers for WebRTC — see `IceServersResource`. */
|
|
1483
|
+
readonly iceServers: IceServersResource;
|
|
1432
1484
|
private readonly resolved;
|
|
1433
1485
|
private readonly tokenCache;
|
|
1434
1486
|
constructor(config: PoolseConfig);
|
|
@@ -1494,8 +1546,8 @@ declare class AuthError extends ApiError {
|
|
|
1494
1546
|
declare function isWebRtcAvailable(): boolean;
|
|
1495
1547
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1496
1548
|
|
|
1497
|
-
declare const version = "2.
|
|
1549
|
+
declare const version = "2.9.0";
|
|
1498
1550
|
|
|
1499
1551
|
declare function safeUuid(): string;
|
|
1500
1552
|
|
|
1501
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1553
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
package/dist/index.js
CHANGED
|
@@ -334,6 +334,7 @@ var VoiceRoom = class {
|
|
|
334
334
|
socket;
|
|
335
335
|
webrtc;
|
|
336
336
|
iceServers;
|
|
337
|
+
iceServersProvider;
|
|
337
338
|
detectSpeaking;
|
|
338
339
|
channel = null;
|
|
339
340
|
localStream = null;
|
|
@@ -365,6 +366,7 @@ var VoiceRoom = class {
|
|
|
365
366
|
this.socket = socket;
|
|
366
367
|
this.webrtc = opts.webrtc ?? createBrowserWebRtcAdapter();
|
|
367
368
|
this.iceServers = opts.iceServers ?? DEFAULT_ICE_SERVERS;
|
|
369
|
+
this.iceServersProvider = opts.iceServersProvider ?? null;
|
|
368
370
|
this.detectSpeaking = opts.detectSpeaking ?? true;
|
|
369
371
|
}
|
|
370
372
|
// ── observation ────────────────────────────────────────────────────
|
|
@@ -399,6 +401,7 @@ var VoiceRoom = class {
|
|
|
399
401
|
}
|
|
400
402
|
this.holders += 1;
|
|
401
403
|
this.setStatus("connecting");
|
|
404
|
+
await this.resolveIceServers();
|
|
402
405
|
try {
|
|
403
406
|
this.localStream = await this.webrtc.getUserMedia();
|
|
404
407
|
} catch (err) {
|
|
@@ -512,6 +515,23 @@ var VoiceRoom = class {
|
|
|
512
515
|
this.emitError(new Error(`voice error: ${payload?.reason ?? "unknown"}`));
|
|
513
516
|
});
|
|
514
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* Refresh ICE servers from the provider, if there is one.
|
|
520
|
+
*
|
|
521
|
+
* Never throws. A room that refused to connect because the ICE
|
|
522
|
+
* endpoint was briefly unreachable would be a worse outcome than one
|
|
523
|
+
* that connects without TURN — which is exactly how calls behaved
|
|
524
|
+
* before TURN existed, and works on most networks.
|
|
525
|
+
*/
|
|
526
|
+
async resolveIceServers() {
|
|
527
|
+
if (!this.iceServersProvider) return;
|
|
528
|
+
try {
|
|
529
|
+
const servers = await this.iceServersProvider();
|
|
530
|
+
if (servers.length > 0) this.iceServers = servers;
|
|
531
|
+
} catch (err) {
|
|
532
|
+
this.emitError(new Error(`ice servers unavailable, continuing without: ${String(err)}`));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
515
535
|
// ── negotiation ────────────────────────────────────────────────────
|
|
516
536
|
/**
|
|
517
537
|
* Glare control: both sides learn about each other simultaneously, so
|
|
@@ -694,6 +714,7 @@ var PoolseRealtime = class {
|
|
|
694
714
|
config;
|
|
695
715
|
tokenCache;
|
|
696
716
|
socketPath;
|
|
717
|
+
iceServersProvider;
|
|
697
718
|
wsUrl;
|
|
698
719
|
socket = null;
|
|
699
720
|
conversations = /* @__PURE__ */ new Map();
|
|
@@ -706,6 +727,7 @@ var PoolseRealtime = class {
|
|
|
706
727
|
this.config = config;
|
|
707
728
|
this.tokenCache = tokenCache;
|
|
708
729
|
this.socketPath = opts.socketPath ?? "/socket";
|
|
730
|
+
this.iceServersProvider = opts.iceServersProvider ?? null;
|
|
709
731
|
this.wsUrl = opts.wsUrl ?? deriveWsUrl(config.apiUrl);
|
|
710
732
|
}
|
|
711
733
|
/** Current connection status. */
|
|
@@ -831,7 +853,10 @@ var PoolseRealtime = class {
|
|
|
831
853
|
if (!this.socket) {
|
|
832
854
|
throw new PoolseError("socket not initialised \u2014 call connect() first");
|
|
833
855
|
}
|
|
834
|
-
const room = new VoiceRoom(conversationId, this.socket,
|
|
856
|
+
const room = new VoiceRoom(conversationId, this.socket, {
|
|
857
|
+
...this.iceServersProvider ? { iceServersProvider: this.iceServersProvider } : {},
|
|
858
|
+
...opts
|
|
859
|
+
});
|
|
835
860
|
this.voiceRooms.set(conversationId, room);
|
|
836
861
|
return room;
|
|
837
862
|
}
|
|
@@ -1595,6 +1620,22 @@ var UsersResource = class {
|
|
|
1595
1620
|
}
|
|
1596
1621
|
};
|
|
1597
1622
|
|
|
1623
|
+
// src/resources/ice-servers.ts
|
|
1624
|
+
var IceServersResource = class {
|
|
1625
|
+
constructor(client) {
|
|
1626
|
+
this.client = client;
|
|
1627
|
+
}
|
|
1628
|
+
client;
|
|
1629
|
+
/** GET /v1/ice-servers */
|
|
1630
|
+
list(signal) {
|
|
1631
|
+
return this.client.request({
|
|
1632
|
+
method: "GET",
|
|
1633
|
+
path: "/v1/ice-servers",
|
|
1634
|
+
...signal ? { signal } : {}
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1598
1639
|
// src/rest-client.ts
|
|
1599
1640
|
var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET"]);
|
|
1600
1641
|
var RestClient = class {
|
|
@@ -1845,6 +1886,8 @@ var Poolse = class {
|
|
|
1845
1886
|
* `config.wsUrl`.
|
|
1846
1887
|
*/
|
|
1847
1888
|
realtime;
|
|
1889
|
+
/** STUN/TURN servers for WebRTC — see `IceServersResource`. */
|
|
1890
|
+
iceServers;
|
|
1848
1891
|
resolved;
|
|
1849
1892
|
tokenCache;
|
|
1850
1893
|
constructor(config) {
|
|
@@ -1861,9 +1904,14 @@ var Poolse = class {
|
|
|
1861
1904
|
this.messages = new MessagesResource(this.rest);
|
|
1862
1905
|
this.attachments = new AttachmentsResource(this.rest, cachedConfig.fetch);
|
|
1863
1906
|
this.users = new UsersResource(cachedConfig);
|
|
1907
|
+
this.iceServers = new IceServersResource(this.rest);
|
|
1864
1908
|
this.realtime = new PoolseRealtime(cachedConfig, this.tokenCache, {
|
|
1865
1909
|
...this.resolved.wsUrl !== void 0 ? { wsUrl: this.resolved.wsUrl } : {},
|
|
1866
|
-
socketPath: this.resolved.socketPath
|
|
1910
|
+
socketPath: this.resolved.socketPath,
|
|
1911
|
+
// Re-fetched on every room join rather than cached here: TURN
|
|
1912
|
+
// credentials expire, and a stale one is rejected silently — the
|
|
1913
|
+
// call connects and carries no media.
|
|
1914
|
+
iceServersProvider: async () => (await this.iceServers.list()).ice_servers
|
|
1867
1915
|
});
|
|
1868
1916
|
}
|
|
1869
1917
|
/**
|
|
@@ -1878,8 +1926,8 @@ var Poolse = class {
|
|
|
1878
1926
|
};
|
|
1879
1927
|
|
|
1880
1928
|
// src/version.ts
|
|
1881
|
-
var version = "2.
|
|
1929
|
+
var version = "2.9.0";
|
|
1882
1930
|
|
|
1883
|
-
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, MeResource, MessageHandle, MessagesResource, NetworkError, POOLSE_API_URL, Poolse, PoolseError, PoolseRealtime, RateLimitedError, UserChannel, UsersResource, VoiceRoom, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1931
|
+
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, IceServersResource, MeResource, MessageHandle, MessagesResource, NetworkError, POOLSE_API_URL, Poolse, PoolseError, PoolseRealtime, RateLimitedError, UserChannel, UsersResource, VoiceRoom, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1884
1932
|
//# sourceMappingURL=index.js.map
|
|
1885
1933
|
//# sourceMappingURL=index.js.map
|