@defcomm/meetingsdk 0.7.1 → 0.7.2
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/README.md +1 -0
- package/dist/index.js +8 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -473,9 +473,9 @@ var SFUClient = class {
|
|
|
473
473
|
this.publisherRevision = 0;
|
|
474
474
|
this.screenShareGeneration = 0;
|
|
475
475
|
this.currentParticipantId = null;
|
|
476
|
-
//
|
|
476
|
+
// Token supplied by the application for REST and SFU authentication.
|
|
477
477
|
this.authToken = null;
|
|
478
|
-
//
|
|
478
|
+
// Token used for the current WebSocket session.
|
|
479
479
|
this.token = null;
|
|
480
480
|
this.room = null;
|
|
481
481
|
this.resumeToken = null;
|
|
@@ -766,7 +766,8 @@ var SFUClient = class {
|
|
|
766
766
|
}
|
|
767
767
|
);
|
|
768
768
|
}
|
|
769
|
-
async
|
|
769
|
+
async join(roomCode, options = {}) {
|
|
770
|
+
if (!this.authToken) throw new Error("Authentication token is required");
|
|
770
771
|
const nextRoom = roomCode.trim();
|
|
771
772
|
if (this.room && this.room !== nextRoom) {
|
|
772
773
|
this.resumeToken = null;
|
|
@@ -784,33 +785,7 @@ var SFUClient = class {
|
|
|
784
785
|
if (!this.resumeToken) {
|
|
785
786
|
this.resumeToken = this.loadResumeToken(this.room);
|
|
786
787
|
}
|
|
787
|
-
|
|
788
|
-
method: "POST",
|
|
789
|
-
body: JSON.stringify({
|
|
790
|
-
room_code: this.room,
|
|
791
|
-
user_id: this.participantId,
|
|
792
|
-
display_name: options.displayName,
|
|
793
|
-
avatar_url: options.avatarUrl
|
|
794
|
-
})
|
|
795
|
-
});
|
|
796
|
-
this.token = data?.token;
|
|
797
|
-
if (!this.token) throw new Error("Token endpoint returned no token");
|
|
798
|
-
return this.connect(this.token, this.joinOptions);
|
|
799
|
-
}
|
|
800
|
-
async refreshAccessToken() {
|
|
801
|
-
if (!this.room) throw new Error("Cannot refresh token without a room");
|
|
802
|
-
const data = await this.request(`${this.apiBase}/token`, {
|
|
803
|
-
method: "POST",
|
|
804
|
-
body: JSON.stringify({
|
|
805
|
-
room_code: this.room,
|
|
806
|
-
user_id: this.participantId,
|
|
807
|
-
display_name: this.joinOptions.displayName,
|
|
808
|
-
avatar_url: this.joinOptions.avatarUrl
|
|
809
|
-
})
|
|
810
|
-
});
|
|
811
|
-
if (!data?.token) throw new Error("Token refresh returned no token");
|
|
812
|
-
this.token = data.token;
|
|
813
|
-
return this.token;
|
|
788
|
+
return this.connect(this.authToken, this.joinOptions);
|
|
814
789
|
}
|
|
815
790
|
connect(token, options = {}) {
|
|
816
791
|
this.token = token;
|
|
@@ -900,15 +875,9 @@ var SFUClient = class {
|
|
|
900
875
|
this.reconnectBaseMs * Math.pow(2, this.reconnectAttempt - 1)
|
|
901
876
|
);
|
|
902
877
|
this.onReconnecting(this.reconnectAttempt);
|
|
903
|
-
this.reconnectTimer = setTimeout(
|
|
878
|
+
this.reconnectTimer = setTimeout(() => {
|
|
904
879
|
this.reconnectTimer = null;
|
|
905
|
-
|
|
906
|
-
await this.refreshAccessToken();
|
|
907
|
-
this.openWebSocket(this.joinOptions);
|
|
908
|
-
} catch (error) {
|
|
909
|
-
this.onError(error);
|
|
910
|
-
this.scheduleReconnect();
|
|
911
|
-
}
|
|
880
|
+
this.openWebSocket(this.joinOptions);
|
|
912
881
|
}, delay);
|
|
913
882
|
}
|
|
914
883
|
failJoin(error) {
|
|
@@ -2683,7 +2652,7 @@ var VideoSDKCore = class {
|
|
|
2683
2652
|
);
|
|
2684
2653
|
}
|
|
2685
2654
|
this.sfuClient.setLocalStream(this.localStream);
|
|
2686
|
-
await this.sfuClient.
|
|
2655
|
+
await this.sfuClient.join(roomId, {
|
|
2687
2656
|
displayName: name,
|
|
2688
2657
|
participantId: this.myId,
|
|
2689
2658
|
audioMuted: !(this.localStream?.getAudioTracks()[0]?.enabled ?? false),
|