@formant/data-sdk 0.0.59 → 0.0.60
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/data-sdk.es.js
CHANGED
|
@@ -17982,6 +17982,25 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17982
17982
|
return r2.sort((e3, t3) => n2(t3) - n2(e3)).map((e3) => Z(e3));
|
|
17983
17983
|
});
|
|
17984
17984
|
}
|
|
17985
|
+
getSessions() {
|
|
17986
|
+
return K(this, void 0, void 0, function* () {
|
|
17987
|
+
if (this.config.lanOnlyMode)
|
|
17988
|
+
throw new Error("getPeers method cannot be used in local-only mode.");
|
|
17989
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => K(this, void 0, void 0, function* () {
|
|
17990
|
+
try {
|
|
17991
|
+
return yield e2.getPeers(new C.GetPeersRequest(), yield this.getMetadata({}));
|
|
17992
|
+
} catch (e3) {
|
|
17993
|
+
_.a.warn("Error when getting peers", { error: e3 });
|
|
17994
|
+
}
|
|
17995
|
+
}))();
|
|
17996
|
+
if (!t2)
|
|
17997
|
+
return {};
|
|
17998
|
+
const r2 = t2.getPeersList(), n2 = {};
|
|
17999
|
+
for (const e3 of r2)
|
|
18000
|
+
n2[e3.getPeerId()] = e3.getSessionIdsList();
|
|
18001
|
+
return n2;
|
|
18002
|
+
});
|
|
18003
|
+
}
|
|
17985
18004
|
getPing(e2) {
|
|
17986
18005
|
const t2 = this.getActiveConnection(e2);
|
|
17987
18006
|
if (t2)
|
|
@@ -18378,8 +18397,13 @@ const _Authentication = class {
|
|
|
18378
18397
|
const tokenData = JSON.parse(atob(token.split(".")[1]));
|
|
18379
18398
|
try {
|
|
18380
18399
|
let userId;
|
|
18381
|
-
_Authentication.isShareToken = tokenData["formant:claims"].type == "share";
|
|
18382
|
-
|
|
18400
|
+
_Authentication.isShareToken = tokenData["formant:claims"] && tokenData["formant:claims"].type == "share";
|
|
18401
|
+
if (tokenData["formant:claims"]) {
|
|
18402
|
+
_Authentication.currentOrganization = tokenData["formant:claims"].organizationId;
|
|
18403
|
+
}
|
|
18404
|
+
if (tokenData["custom:organization_id"]) {
|
|
18405
|
+
_Authentication.currentOrganization = tokenData["custom:organization_id"];
|
|
18406
|
+
}
|
|
18383
18407
|
if (!_Authentication.isShareToken) {
|
|
18384
18408
|
userId = tokenData.sub;
|
|
18385
18409
|
}
|
|
@@ -19149,6 +19173,20 @@ const _Fleet = class {
|
|
|
19149
19173
|
const allDevices = await _Fleet.getDevices();
|
|
19150
19174
|
return allDevices.filter((_) => onlineIds.includes(_.id));
|
|
19151
19175
|
}
|
|
19176
|
+
static async getRealtimeSessions() {
|
|
19177
|
+
if (!Authentication.token) {
|
|
19178
|
+
throw new Error("Not authenticated");
|
|
19179
|
+
}
|
|
19180
|
+
const rtcClient = new dist.exports.RtcClient({
|
|
19181
|
+
signalingClient: new dist.exports.SignalingPromiseClient(FORMANT_API_URL, null, null),
|
|
19182
|
+
getToken: async () => {
|
|
19183
|
+
return defined(Authentication.token, "Realtime when user isn't authorized");
|
|
19184
|
+
},
|
|
19185
|
+
receive: () => {
|
|
19186
|
+
}
|
|
19187
|
+
});
|
|
19188
|
+
return await rtcClient.getSessions();
|
|
19189
|
+
}
|
|
19152
19190
|
static async getRealtimeDevices() {
|
|
19153
19191
|
if (!Authentication.token) {
|
|
19154
19192
|
throw new Error("Not authenticated");
|